Chartjs-How do I make the Line in ChartJS not exceed the maximum of yAxes

1👍

Given your code you can do something like:
Move your data to a var like

var myData = [730000, 1012000, 1220000, 1831000, 560000, 2012000, 890000];

Then change your data field to data: myData,
Then change your Ticks to

        ticks: {
          beginAtZero:true,
          max: Math.max.apply(Math, myData), //Sets the max to the max data you have
          min: 0,
          stepSize: 200000,
          callback: function(value, index, values) {
            return value / 1e6 + 'M';
          }
        },

You can add something to the max to make it a bit bigger.

Leave a comment