0

我的代码如下所示:

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);
}

图表画得很好,我的 evert 处理程序被击中,但 getSelection() 只返回 ["0"]。顺便说一句,createWrapped 正在使用 google.visualization.ChartWrapper。

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

4

1 回答 1

0

getSelection()Chart方法,而不是ChartWrapper方法

反而...

this.chart.getChart().getSelection()

于 2017-02-28T12:52:53.490 回答