How to set max and min value for Y axis

后端 未结 17 2077
既然无缘
既然无缘 2020-11-27 11:08

I am using line chart from http://www.chartjs.org/ \"enter

As you can see max value (1

17条回答
  •  -上瘾入骨i
    2020-11-27 11:18

    There's so many conflicting answers to this, most of which had no effect for me.

    I was finally able to set (or retrieve current) X-axis minimum & maximum displayed values with chart.options.scales.xAxes[0].ticks.min (even if min & max are only a subset of the data assigned to the chart.)

    Using a time scale in my case, I used:

    chart.options.scales.xAxes[0].ticks.min = 1590969600000;  //Jun 1, 2020
    chart.options.scales.xAxes[0].ticks.max = 1593561600000;  //Jul 1, 2020
    chart.update();
    

    (I found no need to set the step values or beginAtZero, etc.)

提交回复
热议问题