Chartjs-ChartJs – Labelling minimum and maximum value of the Y Axis

0👍

You can specify min and max directly, Please check https://www.chartjs.org/docs/latest/axes/cartesian/linear.html#step-size

e.g

var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        yAxes: [{
            ticks: {
                // Include a dollar sign in the ticks
                callback: function(value, index, values) {
                    return '$' + value;
                },
             min: 1,
             max: 100
            }
        }]
    }
}});

You can also use axis range settings, It is only change the data values that are used to scale the axis and useful for extending the range of the axis while maintaining the auto fit behaviour.
https://www.chartjs.org/docs/latest/axes/cartesian/linear.html#axis-range-settings

e.g.

var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        yAxes: [{
            ticks: {
                // Include a dollar sign in the ticks
                callback: function(value, index, values) {
                    return '$' + value;
                },
             suggestedMin: 1,
             suggestedMax: 100
            }
        }]
    }
}});

Leave a comment