Chart.js: Negative Y Axis when data series is all zero

Created on 3 May 2016  路  5Comments  路  Source: chartjs/Chart.js

Hi,

if there some way to not show negative y-axis values when the data series is all set to zero?

I have tried setting

ticks: {
    beginAtZero:true,
    min: 0
}

for the y-axis scale but it doesn't appear to do the trick.

chart-negative-y-axis

enhancement

Most helpful comment

$scope.chart_line_options = {
                scales: {
                    yAxes: [
                        {
                            id: 'y-axis-1',
                            type: 'linear',
                            display: true,
                            position: 'left',
                            ticks: {
                                beginAtZero: true
                            }
                        }
                    ]
                }
            };

All 5 comments

We'd need to do some work to support this. As a work around set ticks.max to be a positive number and this won't happen. It only occurs if at the end of finding the max and min, min === max.

OK thanks

But what is if you dont know max?
Why is this closed? The bug still exists.

$scope.chart_line_options = {
                scales: {
                    yAxes: [
                        {
                            id: 'y-axis-1',
                            type: 'linear',
                            display: true,
                            position: 'left',
                            ticks: {
                                beginAtZero: true
                            }
                        }
                    ]
                }
            };
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true
                }
            }]
        }
    }
Was this page helpful?
0 / 5 - 0 ratings