如果满足条件,我会遍历数据并创建标记。图表上的所有点都会出现,但是标记应该在哪里,因为它符合条件,仅显示空点并且图表中存在间隙。
for (i = 0; i < data.length; i++) {
if (parseFloat(data[i][2]) >= 0.99999) {
y_point = {
'marker': {
'enabled':true,
'lineWidth': 3,
'radius': 10,
'symbol': 'triangle'
},
'y': parseFloat(data[i][1])
}
} else {
y_point = parseFloat(data[i][1])
}
metricData.push([moment(data[i][0]).utc().unix() * 1000, y_point])
}
let chart = Highcharts.chart({
time: {
useUTC: false
},
chart: {
zoomType: 'x',
renderTo: this.$el,
width: null,
height: '60%'
},
title: {
text: sample.metric_name
},
xAxis: {
type: 'datetime'
},
legend: {
enabled: false
},
tooltip: {
enabled: true
},
plotOptions: {
series: {
dataGrouping: false
}
},
series: [{
type: 'spline',
name: '% CPU',
data: metricData,
color: '#787878',
turboThreshold: 0
}],
credits: false,
})