Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chartjs在运行时设置步长_Javascript_Chart.js_Chart.js3 - Fatal编程技术网

Javascript Chartjs在运行时设置步长

Javascript Chartjs在运行时设置步长,javascript,chart.js,chart.js3,Javascript,Chart.js,Chart.js3,我正在运行时计算步长,并将其设置为轴。 但在某些情况下,图表不会按照设置的步长显示刻度 对于具有负值的刻度,可以观察到此问题 var config = { type: 'line', data: { datasets: [], }, options: { scales: { xAxes: { beginAtZero: true, type: 'l

我正在运行时计算
步长
,并将其设置为轴。
但在某些情况下,图表不会按照设置的
步长显示
刻度

对于具有负值的刻度,可以观察到此问题

var config = {
    type: 'line',
    data: {
        datasets: [],
    },
    options: {
        scales: {
            xAxes: {
                beginAtZero: true,
                type: 'linear',
                min: 0,
                max: 100,
                ticks: {
                    stepSize: 10
                }
            },
            yAxes: {
                beginAtZero: true,
                type: 'linear',
                min: 0,
                max: 200,
                ticks: {
                    maxTicksLimit: 3
                }
            }
        }
    }
};
在运行时,我正在计算步长,以便将步长等分:

// Divide by 2 as I have max tick count set as 3.
chart.config.options.scales["yAxes"].min = minVal;
chart.config.options.scales["yAxes"].max = maxVal;
chart.config.options.scales["yAxes"].ticks.stepSize = ((maxVal + minVal) / 2); 
chart.update();
但是,当我的图表绘制任何负值时,
stepSize
不会按照设置的步长值进行更新,图表只是调整大小并绘制略低于0的负值,而不调整
stepSize