因此,通常有两个问题。抱歉,如果它们太简单了,我只是一个初学者。
xAxis是时间刻度。目前,它仅显示月份的名称。客户要求我重新制作它,以便显示从2017年12月开始的一年的最后12个月。有没有办法做到这一点?
我必须用所有数据制作一张桌子。 chart.js
中是否有一个函数可以做到这一点?
这是我的代码:
var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Nevember", "December"];
var config = {
type: 'line',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Nevember", "December"],
datasets: [{
label: "Sales",
backgroundColor: window.chartColors.red,
borderColor: window.chartColors.red,
data: [
12,
20,
32,
31,
56,
58,
],
fill: false,
}]
},
options:
{
responsive: true,
title:{
display:true,
text:'Growth'
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Month'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Growth'
},
ticks:{
min: 0,
max: 100,
beginAtZero: true,
stepSize: 10
}
}]
}
}
};
window.onload = function() {
var ctx = document.getElementById("chart-0").getContext("2d");
window.myLine = new Chart(ctx, config);
};