Google visualization 谷歌可视化数据分组

Google visualization 谷歌可视化数据分组,google-visualization,aggregation,dashboard,Google Visualization,Aggregation,Dashboard,我有一个示例Google visualization dashboard,它有两个控件和两个柱状图,其中第二个柱状图是使用数据表聚合绘制的 'dataTable' : google.visualization.data.group(data, [0], [{'column': 2, 'aggregation': google.visualization.data.sum, 'type': 'number'}]) 使用中间表格图表重新绘制,如下所示: google.visualization.

我有一个示例Google visualization dashboard,它有两个控件和两个柱状图,其中第二个柱状图是使用数据表聚合绘制的

'dataTable' : google.visualization.data.group(data, [0],
 [{'column': 2, 'aggregation': google.visualization.data.sum, 'type': 'number'}])
使用中间表格图表重新绘制,如下所示:

google.visualization.events.addListener(divPicker, 'statechange',
 function(event) {
 // group the data of the filtered table and set the result in the pie chart.
 columnChart1.setDataTable( google.visualization.data.group(
 // get the filtered results
 table.getDataTable(),
 [0],
 [{'column': 2, 'aggregation': google.visualization.data.sum, 'type': 'number'}]
 ));

所有代码都正常工作。但问题是,当我选择控件时,聚合创建的图表没有正确更改。只有当我两次选择相同的控制选项时,它才会发生变化。

经过几个小时的裂头后,我终于解决了这个问题

为了解决这个问题,我使用了两个事件监听器,其中一个是readyevent,另一个是statechangeevent as

google.visualization.events.addListener(subdivPicker, 'ready',
function(event) {
// group the data of the filtered table and set the result in the pie chart.
columnChart1.setDataTable( google.visualization.data.group(
// get the filtered results
 table.getDataTable(),
 [0],
[{'column': 2, 'aggregation': google.visualization.data.sum, 'type': 'number'}]
));    
// redraw the pie chart to reflect changes
columnChart1.draw();
});

google.visualization.events.addListener(subdivPicker, 'statechange',
 function(event) {
 // group the data of the filtered table and set the result in the pie chart.
 columnChart1.setDataTable( google.visualization.data.group(
 // get the filtered results
 table.getDataTable(),
 [0],
 [{'column': 2, 'aggregation': google.visualization.data.sum, 'type': 'number'}]
 ));
 // redraw the pie chart to reflect changes
 columnChart1.draw();
 });
在中查找更新的代码

请注意:我的样品