[英]Highchart time interval in x-Axis
I'm working with Highcharts JS library, 我正在使用Highcharts JS库,
Now I need to create monthly report. 现在,我需要创建月度报告。 I have number of sales orders, which corresponding to days in month.
我有销售订单数量,对应于每月的天数。 For example at day 1, number of sales orders is 30, day 2 is 20....
例如,在第1天,销售订单数为30,第2天为20。
But I only want to show in x-Axis (day) something like 1, 5, 10, 15, 20, 25, 30 and information about sales orders of each day is still displayed. 但是我只想在x轴(天)中显示诸如1、5、10、15、20、25、30之类的内容,并且仍然显示每天的销售订单信息。
What option I have to use? 我必须使用什么选项?
Thank you very much. 非常感谢你。
EDIT 1 Here is my js code 编辑1这是我的js代码
<script>
var d = new Date();
var m = d.getMonth();
d.setMonth(d.getMonth() - 1);
if (d.getMonth() === m)
d.setDate(0);
d.setHours(0, 0, 0);
new Highcharts.Chart({
chart: {
renderTo: 'container_sales_report',
type: 'line',
height: 380,
width: 415,
zoomType: 'xy'
},
colors: ['#FF0000'],
title: {
text: 'Last 30 Days Reports',
x: -20 //center
},
xAxis: [{
type: 'datetime',
dateTimeLabelFormats: {
day: '%e of %b'
},
crosshair: true
}],
yAxis: [{
labels: {
format: '{value}',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: '',
style: {
color: Highcharts.getOptions().colors[1]
}
}
}],
tooltip: {
formatter: function () {
return Highcharts.dateFormat('%d/%m', this.x) + ' : ' + this.y;
}
},
legend: {
layout: 'horizontal',
align: 'bottom',
verticalAlign: 'bottom',
borderWidth: 0,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
plotOptions: {
spline: {
marker: {
enabled: false
}
}
},
series: [{
name: 'Cost',
type: 'spline',
data: [<?php echo $purchasesData; ?>],
pointStart: Date.UTC(d.getYear(), d.getMonth(), d.getDate()),
pointInterval: 24 * 3600 * 1000 // one day
}]
});
</script>
Now the time interval in x-Axis is 7 days. 现在,x轴的时间间隔为7天。 It's fine but I wonder is there anyway I can control this interval?
很好,但我想知道是否可以控制此间隔?
You can try tickInterval option for the x-axis. 您可以尝试对x轴使用tickInterval选项。 Eg
例如
xAxis: {
tickInterval: 5
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.