使用<chart type>#setSelection
方法突出显示数据点。如果我正确理解你的数据结构,应该这样工作:
google.visualization.events.addListener(pieChart, 'select', function() {
var selection = pieChart.getSelection();
if (selection.length) {
// assumes the row in the PieChart's data corresponds to the data series in the ColumnChart, which is the nth + 1 column
columnChart.setSelection([{column: selection[0].row + 1}]);
}
});
google.visualization.events.addListener(columnChart, 'select', function() {
var selection = columnChart.getSelection();
if (selection.length) {
// assumes the data series in the ColumnChart's data corresponds to the row in the PieChart, which is the nth column - 1
pieChart.setSelection([{column: selection[0].column - 1}]);
}
});