Warm tip: This article is reproduced from serverfault.com, please click

How to set max and min value for Y axis

发布于 2015-03-11 15:26:34

I am using line chart from http://www.chartjs.org/ enter image description here

As you can see max value (130) and min value (60) for Y axis are chosen automatically , I want max value = 500 and min value=0. Is this possible?

Questioner
Rajendra Thorat
Viewed
0
17.6k 2020-08-05 08:45:39

You have to overrride the scale, try this: (applies to ChartJS v1.x)

window.onload = function(){
    var ctx = document.getElementById("canvas").getContext("2d");
    window.myLine = new Chart(ctx).Line(lineChartData, {
        scaleOverride : true,
        scaleSteps : 10,
        scaleStepWidth : 50,
        scaleStartValue : 0 
    });
}