【问题标题】:Can't get google orgchart selection in Angular2无法在 Angular2 中选择 google orgchart
【发布时间】:2017-02-28 00:09:08
【问题描述】:

我的代码如下:

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 下工作之外,我的意思是。 :)

【问题讨论】:

    标签: charts google-visualization orgchart


    【解决方案1】:

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

    反而……

    this.chart.getChart().getSelection()

    【讨论】:

    • 谢谢。我想通了,并忙于让它工作的快乐。因此我忘了在这里更新。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-16
    • 1970-01-01
    • 2023-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多