Chartjs-Chartjs bar chart ranges y-axis -1 to +1 if bars value zero

0👍

In your options, try setting suggestedMin: -1 instead of beginAtZero: true, like so:

 options: {
        scales: {
            yAxes: [{
                ticks: {
                    suggestedMin: -1,
                }
            }],
        }
    }

Furthermore, I would suggest updating the dataset instead of redrawing the chart each time by using the myChart.update() function.

Leave a comment