ChartJS 如何从曲线中移除斜率

gblwokeq  于 2022-11-06  发布在  Chart.js
关注(0)|答案(1)|浏览(181)

所以基本上图表中的点位置是正确的,唯一的问题是曲线的形状,因为它应该只遵循整数值。
外观:

它应该是什么样子



图表代码

  1. const ctx = document.getElementById('myChart').getContext('2d');
  2. const myChart = new Chart(ctx, {
  3. type: 'line',
  4. data: {
  5. labels: [{% for value in x %} '{{value}}', {% endfor %}],
  6. datasets: [{
  7. label: '# Des employes',
  8. data: [{% for c in y %} '{{c}}', {% endfor %} ],
  9. fill: true,
  10. backgroundColor: [
  11. 'rgba(54, 162, 235, 0.5)',
  12. ],
  13. borderColor: [
  14. 'rgba(54, 162, 235, 1)',
  15. ],
  16. borderWidth: 1
  17. }]
  18. },
  19. options: {
  20. scales: {
  21. y: {
  22. beginAtZero: true,
  23. ticks:{stepSize:1}
  24. }
  25. }
  26. }
  27. });
nsc4cvqm

nsc4cvqm1#

stepped设置为after
(or(一个月两个月一次,一个月三个月一次,一个月四个月一次):

  1. ...
  2. datasets: [{
  3. stepped: 'after',
  4. 👆
  5. ...

相关问题