As I am trying to create a dynamic streaming Chart in Highcharts API, I came up with a strange problem.
1st thing to keep in mind is that I need to show the X-axis data as category
that's why I have turned the date
to a string format for this example.
The problem arises is that the X-axis label is not showing correctly only one point in x-axis is visible and that is also changing its values rather than shifting.
Here is the JS Code that I have tried.
Highcharts.chart('container', {
chart: {
type: 'line',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function() {
var series = this.series[0],
chart = this;
var count = 0;
var draw = setInterval(function() {
x = countval();
// var counter = j;
// console.log("Count: ", counter);
y = next();
console.log("CountVal : ", x);
console.log("DataPoints: ", y);
/* if (counter == 1300) {
clearInterval(draw);
return;
}
*/
if (counter > 1000) {
series.addPoint([x, y], true, true, false);
} else {
series.addPoint([x, y], true, false, false);
}
}, 1000/130 );
}
}
},
time: {
useUTC: false
},
title: {
text: 'ECG Graph Plot From MySQl Data'
},
xAxis: {
type: 'category',
tickInterval: 200,
/*/ labels: {
format: '{value:%H:%M:%S}',
range: false,
},/*/
// plotLines: generateDynamicPlotLines(),
// crosshair: false
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
enabled: false,
/*/ headerFormat: '<b>{series.name}</b><br/>',
pointFormat: '{point.x:%Y-%m-%d %H:%M:%S}<br/>{point.y:.2f}'/*/
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
plotOptions: {
series: {
marker: {
enabled: false
},
states: {
hover: {
enabled: false
}
}
}
},
series: [{
animation: false,
name: 'ECG Graph Plot From MySQl Data',
dataGrouping: {
enabled: false
},
data: []
},
]
});
For further understanding, you can check this fiddle that I have which shows my problem. you can see the problem with X-axis.
https://jsfiddle.net/abnitchauhan/8jtz2fwy/
I set the tickInterval
to 200 it does not plot any point. and if I put tickPixelInterval
. the X-axis points just updating their no's rather than shifting.
尝试将 xAxis.type 设置为 'datetime' 代替 'category'。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.