I am using canvasjs-chart in my angular to draw chart.(I am new in Angular)
here is my component ts code :
import { Component } from '@angular/core';
import { NgModule } from '@angular/core';
@Component({
selector: 'app-counter-component',
templateUrl: './counter.component.html'
})
export class CounterComponent {
public books = [{
title: "Life is good",
author: "benny",
category: "life"
}, {
title: 'Canned in',
author: "francis",
category: "style"
}];
chartOptions = {
title: {
text: "Basic Column Chart in Angular"
},
data: [{
type: "line",
dataPoints: [
{ label: "Apple", y: 121 },
{ label: "Orange", y: 15 },
{ label: "Banana", y: 25 },
{ label: "Mango", y: 30 },
{ label: "Grape", y: 28 }
]
}]
};
public changeChartData() {
this.chartOptions.data[0].dataPoints[0].y =20;
}
As you can see I have a books object which it passed to html :
<button class="btn btn-primary" (click)="changeChartData()">change chart Data</button>
<canvasjs-chart [options]="chartOptions"></canvasjs-chart>
The data is shown correctly but my problem is when I click on the change chart Data
to change the value of my books object I can’t see the changes in the chart .I think the problem is the chart is not binding to books object