Rerender ng2-google-chart after programmatically changing the data

坚强是说给别人听的谎言 提交于 2020-02-24 12:33:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!