[Chartjs]-Chartjs – multi axis line chart – cannot read property 'min' of undefined

1πŸ‘

βœ…

The issue is merely occurring due to the fact that, you have placed the options object/property, inside the data property, while it should be outside.

Here is the revised version of your code :

var ctx = document.getElementById("chart_canvas").getContext('2d')

var basic_line = new Chart(ctx, {
   type: 'line',
   data: {
      labels: data.labels,
      datasets: [{
         label: 'Price',
         yAxisID: 'B',
         fill: false,
         borderColor: ["#668cff"],
         data: data.price
      }, {
         label: 'Sales',
         yAxisID: 'A',
         fill: false,
         borderColor: ["grey"],
         data: data.sales
      }]
   },
   options: {
      scales: {
         yAxes: [{
            id: 'A',
            position: 'left',
            type: 'linear'
         }, {
            id: 'B',
            position: 'right',
            type: 'linear'
         }]
      },
      responsive: true,
      maintainAspectRatio: false
   }
});

Leave a comment