刷新样条线Highchart,我不明白我做错了什么。我的代码是这样的:
(function($){
$(this.document).ready(function(){
//get local time
Highcharts.setOptions({
global: {
useUTC: false
}
});
var myChart = new Highcharts.Chart({
chart: {
type: 'spline',
//animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
renderTo: 'mychart',
zoomType: 'x',
events: {
load: function () {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function () {
var x = <?php echo strtotime($starttime)*1000;?>, // current time
y = 0;
series.addPoint([x, y], true, true);
}, 2000);
}
}
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
min: <?php echo strtotime($starttime) * 1000; ?>,
max: <?php echo strtotime($end) * 1000; ?>,
//min: Date.UTC(2015,5,22),
//max: Date.UTC(2013,4,23),
},
yAxis: [{
min: 0,
title: {
text: 'Data Volume (KB)'
},
}],
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
Highcharts.numberFormat(this.y, 2);
}
},
title: {
text: 'User Traffic'
},
series: [{
name:'Hourly traffic',
data:[<?php echo join(',',$traff); ?>],
//pointStart: Date.UTC(15, 05, 15),
// pointInterval: 24 * 3600 // one day
}]
});
});
})(jQuery);
我的系列看起来像这样:
[1432034700000, 95.23],[1434034700000, 65.2],[1435034700000, 40.23] etc
我认为我在setInterval中做错了什么。我没有以正确的形式或类似的方式解析数据。我也不熟悉语法。如果有人可以提供帮助,我会非常感激。 Thanx提前!