问题
I am using ng2-google-chart
and it works fine. Now I want to use some checkboxes to choose which data is shown in the graph.
My graph is connected to the array chartData
, which is updated correct after the selection. But the graph does not change. This is my graph
<div #graph [chartData]="this.chartData" chartType="AreaChart" GoogleChart></div>
Is there a way to rerender it after the data is changed?
回答1:
In the mean time I solved this:
In angular2-google/directives/angular2-google-chart.directive.ts import OnChanges
and implment it like this:
ngOnChanges(changes) {
if (googleLoaded)
{
this.drawGraph(this.chartOptions,this.chartType,this.chartData,this._element);
}
}
//edit: This is now fixed in the newest library version.
来源:https://stackoverflow.com/questions/43206371/rerender-ng2-google-chart-after-programmatically-changing-the-data