//Drill down
// create a dummy chart to serve as a placeholder
var dummy3 = new google.visualization.ChartWrapper({
chartType: 'Table',
containerId: 'dummy_div3',
options: {
width: '100px'
// },
//view: {
// rows: []
}
});
// create event handler for updating the chart
google.visualization.events.addListener(dummy3, 'ready', function () {
// get the filtered DataTable
var newData3 = dummy3.getDataTable();
// group Y by X
var grouped3 = google.visualization.data.group(newData3, [4], [{
type: 'number',
label: 'Value',
column: 6,
aggregation: google.visualization.data.sum
}]);
var topLevel = true;
var chart = new google.visualization.ChartWrapper({
'chartType': 'ColumnChart',
'containerId': 'ColumnChart_div',
'options': {
'height': 400,
'width': 600
}
});
function draw (category) {
if (topLevel) {
// rename the title
// options.title = 'Top Level data';
// draw the chart using the aggregate data
chart.draw(grouped3);
}
else {
var view = new google.visualization.DataView(data);
// use columns "Name" and "Value"
view.setColumns([5, 6]);
// filter the data based on the category
view.setRows(data.getFilteredRows([{column: 4, value: yearvalue}]));
// rename the title
// options.title = 'yearvalue: ' + yearvalue;
// draw the chart using the view
chart.draw(view);
}
google.visualization.events.addListener(chart, 'select', function () {
if (topLevel) {
var selection = chart.getSelection();
// drill down if the selection isn't empty
if (selection.length) {
var category = grouped3.getValue(selection[4].row,4);
topLevel = false;
draw(category);
}
}
else {
// go back to the top
topLevel = true;
// set the DataTable for the chart
// chart.setDataTable(grouped3);
chart.draw();
}
// set the DataTable for the chart
// chart.setDataTable(grouped3);
// draw the chart
// chart.draw();
});
this what em trying