Home › Forums › Chart Support › charts in ionic 2 y-axis labels changes › Reply To: charts in ionic 2 y-axis labels changes
my js file
public getSalesAndPurchase() {
this._companiesService.getSalesAndPurchase(<any>localStorage.getItem(“org_id”), this.fromDate, this.endDate).subscribe( data => { this.data = <ResponseModel>data if (this.data.success) { this.salesAndPurchases = this.data.payload; if(this.salesAndPurchases.stats!==undefined){ this.noRecord=false; let income = []; let expense = []; this.salesAndPurchases = this.data.payload; this.barChartData = []; this.barChartLabels = []; this.barChartColors=[ { backgroundColor:’rgb(123, 190, 234)’,
}, { backgroundColor:’#DE7D12′,
} ] // axisY: { // labelFormatter: addSymbols // }, this.totalExpense = 0; this.totalIncome = 0; this.salesAndPurchases.stats.forEach(stat => { this.totalIncome += stat.income == “” || stat.income == null ? 0 : parseFloat(stat.income); this.totalExpense += stat.expense == “” || stat.expense == null ? 0 : parseFloat(stat.expense); income.push(stat.income); expense.push(stat.expense);
this.barChartLabels.push(stat.month); }); this.barChartData.push({ data: income, label: ‘Income’ }, { data: expense, label: ‘Expense’ }) } else{ this.noRecord=true; } } else { this._toastService.presentToast(this.data.payload.message); } this.showBarChart = true;
}, error=>{ this.errorMessage = <any>error; this._toastService.callError(this.errorMessage);
}) }
html file
<canvas baseChart *ngIf=”showBarChart && !noRecord” class=”chart base-chart” [colors]=”barChartColors” [datasets]=”barChartData” [labels]=”barChartLabels” [options]=”barChartOptions” [legend]=”barChartLegend” [chartType]=”barChartType” (chartHover)=”chartHovered($event)” (chartClick)=”chartClicked($event)”></canvas>
HOw i use label formatter in this ?? please help