所以基本上图表中的点位置是正确的,唯一的问题是曲线的形状,因为它应该只遵循整数值。
外观:
它应该是什么样子
)
图表代码
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: [{% for value in x %} '{{value}}', {% endfor %}],
datasets: [{
label: '# Des employes',
data: [{% for c in y %} '{{c}}', {% endfor %} ],
fill: true,
backgroundColor: [
'rgba(54, 162, 235, 0.5)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true,
ticks:{stepSize:1}
}
}
}
});
1条答案
按热度按时间nsc4cvqm1#
将
stepped
设置为after
(or(一个月两个月一次,一个月三个月一次,一个月四个月一次):