You must be logged in to post your query.
Home › Forums › Chart Support › Chart update on button click in Angular
I work with CanvasJS in Angular and I try to update a chart when a button is pressed. Firstly, in component.ts file I render the chart in ngOnInit.
After that, in another method which is called when that button is pressed, I update the dataPoints like this: this.chart.data.dataPoints=newData and if I print these values using console.log(this.chart.data.dataPoints) the result looks suitable to be used by the chart:
But the chart is not updated and looks like this.
I also tried to call again this.chart.render() after the dataPoints update, but it doesn’t work.
Could you please help me with this issue?
In order to update chart, you need to either change chart-options and call render or use set method. In your case, updating dataPoints through chart-options seems to be working fine. Please take a look at this updated stackblitz code.
Considering this as duplicate of Chart update on button click in Angular, hence closing the same.
You must be logged in to reply to this topic. Login/Register