无法在Angular2中获取google orgchart选择

时间:2017-02-28 00:09:08

标签: charts google-visualization google-chartwrapper orgchart

我的代码如下:

drawGraph() {
  let theChart;
  let handler = () => {
    let sel = theChart.getChart().getSelection();
    alert('selection occurred');
    console.log('selection event', sel, Object.keys(sel));
  };

  this.google = this.getGoogle();
  this.dataTable = this.getDataTable();
  this.orgData.fillDataTable(this.dataTable, 'PALA,SRINIVASRAO');
  console.log('data', this.dataTable);
  this.dataTable.setRowProperty(1, 'style', 'border: 0');
  this.chart = this.createWrapped('OrgChart', 'chartDiv', this.dataTable);
  theChart = this.chart;
  this.chart.draw();
  this.google.visualization.events.addListener(this.chart, 'select', handler);
}

图表绘制正常,我的外翻处理程序被点击但getSelection()只返回[“0”]。顺便说一下,createWrapped正在使用google.visualization.ChartWrapper。

那么我做错了什么?除了试图让我在TypeScript下工作,我的意思是。 :)

1 个答案:

答案 0 :(得分:0)

getSelection()图表方法,而不是 ChartWrapper 方法

而不是......

this.chart.getChart().getSelection()