How to set max and min value for Y axis

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

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

As you can see max value (1

17条回答
  •  醉话见心
    2020-11-27 11:31

    This is for Charts.js 2.0:

    The reason some of these are not working is because you should declare your options when you create your chart like so:

    $(function () {
        var ctxLine = document.getElementById("myLineChart");
        var myLineChart = new Chart(ctxLine, {
            type: 'line',
            data: dataLine,
            options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            min: 0,
                            beginAtZero: true
                        }
                    }]
                }
            }
    
        });
    })
    

    Documentation for this is here: http://www.chartjs.org/docs/#scales

提交回复
热议问题