ChartJS 如何从曲线中移除斜率

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

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

它应该是什么样子



图表代码

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}

            }

        }
    }
});
nsc4cvqm

nsc4cvqm1#

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

...
  datasets: [{ 
    stepped: 'after',
      👆
...

相关问题