Remove negative scale ng2-charts

0

I am working with ng2-charts and I would like to know if there is any way to remove the negative scale de la graph cuando esta este en 0 , solamente ocupo que se muestren the positive scale , estoy utilizando Line Chart '.

this is the code of the graphic

public lineChartData:Array<any> = [
    { data: [], label: 'Litros'}
];


public lineChartLabels:Array<any> = [];
public lineChartOptions:any = {
    responsive: true
};

public lineChartColors:Array<any> = [
    { // grey
        backgroundColor: 'rgba(72, 208, 255, 0.5)',
        borderColor: 'rgba(72, 208, 255, 1)',
        pointBackgroundColor: 'rgba(148,159,177,1)',
        pointBorderColor: '#fff',
        pointHoverBackgroundColor: '#fff',
        pointHoverBorderColor: 'rgba(148,159,177,0.8)'
    }
];

public lineChartLegend:boolean = true;
public lineChartType:string = 'line';   
    
asked by pepe 09.07.2018 в 19:28
source

1 answer

1

NG2-Charts uses below the library chart.js and what you ask is solved from the options of the chart.

First of all, in your component you have to declare an object where you define the options that you want to apply to your graph. In this case, the part that interests you are the scales and the Y axis:

this.chartOptions = {
    scales: {
        yAxes: [{
            ticks: {
                beginAtZero: true
            }
        }]
    }
}

And then, pass that chartOptions to the object in your template:

<canvas [options]="chartOptions"...>
    
answered by 10.07.2018 / 09:20
source