[Chartjs]-How to add afterDataLimits callback to chart.js

10👍

afterDataLimits callback should be added under options.scales.yAxes , like so :

options: {
   scales: {
      yAxes: [{
         afterDataLimits: function(axis) {
            axis.max += 1; // add 1px to top
            axis.min -= 1; // add 1px to bottom
         }
      }]
   }
}

also, you are not actually adding the pixels, so that should be corrected as well.

Leave a comment