我的highcharts代码如下:几乎总是从01开始,并且显示一月和二月
我确实查阅了 highcharts 文档,但我不知道如何使这件事发挥作用,因为每次都需要+1。意思是如果从第5个开始,它将显示5 6 7 8 9 基于系列值的数量。 该图表显示每天的总浏览量。无论如何,你给我指出了正确的方向?
$('#arpv').highcharts({exporting: { enabled: false } ,
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
day: '%d. '
},pointInterval: 24 * 3600 * 1000
},
yAxis: {
floor: 0,
title: {
text: 'Pageviews'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
title: {
text: 'Pagesviews Summary',
x: -20 //center
},
subtitle: {
// text: 'pageviews over time',
x: -20
},
tooltip: {
valueSuffix: ' Pageviews',
crosshairs: true,
formatter: function() {
var date = new Date(this.x);
var year = date.getFullYear();
return '<span style="color:'+this.series.color+'">'+ this.series.name +'</span>: '+ this.y + ' pageviews';
},
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [ { name: 'Pageviews', data: [ 26562,5793,26585,2203,1444,2150,2833,2416,10114,13564,16234,15253,5415,10340,18184,12830,14340,21520,18883,41571,23913,16013,16681,10499,18557,18692,14550,6655,17490,46258,26671,5739,26585,49114,30038,25998,19076,26577,10231,24110 ],pointInterval: 24 * 3600 * 1000 } ]
});
</script>
最佳答案
在 xAxis 配置中,您使用的是 pointInterval
,它应该是 tickInterval
。
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
day: '%d. '
},
tickInterval: 24 * 3600 * 1000
}
示例 fiddle .
关于javascript - highcharts x 轴显示错误的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26898534/