我有一个有效的示例,说明了如何使饼图与表进行交互。我想添加的是它们之间相关性的视觉提示。我看到的唯一示例是通过添加侦听器突出显示表行的位置。我想在表格中添加一个空单元格,其背景颜色是其对应的饼图的颜色。我如何捕获饼图的颜色?JSFiddle
我现在所拥有的:
google.load("visualization", "1", {packages:["corechart","table"]});
google.setOnLoadCallback(drawProductAllocationChart);
function drawProductAllocationChart() {
var data = google.visualization.arrayToDataTable([
['Name', 'Allocation'],
['Product A', 25],
['Product B', 50],
['Product C', 15],
['Product D', 10]
]);
var options = {
//title: 'My Daily Activities'
is3D: true
};
var productAllocationChart = new google.visualization.PieChart(document.getElementById('product-allocation-chart'));
productAllocationChart.draw(data, options);
var productAllocationTable = new google.visualization.Table(document.getElementById('product-allocation-table'));
productAllocationTable.draw(data, null);
// When the table is selected, update the orgchart.
google.visualization.events.addListener(productAllocationTable, 'select', function() {
portfolioAllocationChart.setSelection(productAllocationTable.getSelection());
});
// When the orgchart is selected, update the table …Run Code Online (Sandbox Code Playgroud)