我的代码看起来是:
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下发挥作用之外。:)
发布于 2017-02-28 12:52:53
getSelection()是图表方法,而不是ChartWrapper方法
而是..。
this.chart.getChart().getSelection()
https://stackoverflow.com/questions/42498083
复制相似问题