[您好,我正在使用Highchart的折线图,请您帮助我让x轴在x轴上显示当月的LAST-X轴可以自动填充,无论需要多少个月日期。该日期是每月一次,因此例如在下面的安装中有8个数据点,我希望将12月显示为X轴上的第8个点,将4月显示为第一个点。但是,我不希望将其限制为8个月,理想情况下,希望将其限制为18个月。
非常感谢您阅读这篇长篇论文。:)!
Highcharts.chart('container', {
title: {
text: 'Solar Employment Growth by Sector, 2010-2016'
},
subtitle: {
text: 'Source: thesolarfoundation.com'
},
yAxis: {
title: {
text: 'Number of Employees'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: 2010
}
},
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}, {
name: 'Manufacturing',
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
据我所知-您想从12月1日的第一个日期开始第一个点,并将点间隔作为一天的时间。这是实现它的准则:
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: Date.UTC(2019, 11, 1),
pointInterval: 24 * 3600 * 1000 // one day
}
},
演示:https://jsfiddle.net/BlackLabel/fcbn5heo/1/
API:https://api.highcharts.com/highcharts/series.line.pointStart
API:https://api.highcharts.com/highcharts/series.line.pointInterval
这是您的初衷吗?