Skip to content

Instantly share code, notes, and snippets.

@taytus
Created April 5, 2012 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taytus/2313063 to your computer and use it in GitHub Desktop.
Save taytus/2313063 to your computer and use it in GitHub Desktop.
Get events working with GoogleCharts
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows(5);
data.setValue(0, 0, 'Work');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Eat');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Commute');
data.setValue(2, 1, 2);
data.setValue(3, 0, 'Watch TV');
data.setValue(3, 1, 2);
data.setValue(4, 0, 'Sleep');
data.setValue(4, 1, 7);
// Create and draw the visualization.
var pie=new google.visualization.PieChart(document.getElementById('visualization'));
pie.draw(data, {title:"So, how was your day?"});
google.visualization.events.addListener(pie, 'select', selectHandler);
}
function selectHandler() {
alert("hi");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment