以编程方式更改数据后重新渲染ng2-google-chart [英] Rerender ng2-google-chart after programmatically changing the data

查看:60
本文介绍了以编程方式更改数据后重新渲染ng2-google-chart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ng2-google-chart,它工作正常.现在,我想使用一些复选框来选择在图表中显示哪些数据.

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.

我的图形连接到数组chartData,在选择后该数组将正确更新.但是图形不会改变.这是我的图

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?

推荐答案

与此同时,我解决了这个问题:

In the mean time I solved this:

angular2-google/directives/angular2-google-chart.directive.ts 中导入OnChanges并实现它:

ngOnChanges(changes) {
  if (googleLoaded)
  {
    this.drawGraph(this.chartOptions,this.chartType,this.chartData,this._element);
  }
}

//edit:现在已在最新的库版本中修复.

//edit: This is now fixed in the newest library version.

这篇关于以编程方式更改数据后重新渲染ng2-google-chart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆