0

I have a chart where the values ​​can be 0 or 1, and in chartJs 2 or lower it works perfect, but I migrated to version 3.6 and now the -1 appears, even though I set BeginAtZero true, min 0 and max 1. I need to make the 0 at the beginning of the y axis (as in version 2), not in the middle (as in version 3.6) this is my code

var ctx = document.getElementById("test");
var myChart = new Chart(ctx, {
   type: 'line',
   data: {
      labels: ["ab", "cd", "ef", "gh", "ij"],
      datasets: [{ data: [0, 0, 0, 0, 0] }]
   },
   options: // SEE BELOW
});

this is the options for the previous version (works correctly)

scales: {
   yAxes: [{
       ticks: {
           beginAtZero: true,
           max: 1,
           min: 0
       }
   }]
}

and this is the code for version 3.6 (y axis is wrong)

scales: {
   y: {
      ticks: {
         beginAtZero: true,
         max: 1,
         min: 0
      }
  }
}
fehcps
  • 11
  • 2

0 Answers0