It is easy, you just need to assign the "onChange" event handler inside the
init function:
google.load('visualization', ...);
google.setOnLoadCallback(Init);
function Init() {
var data = new google.visualization.DataTable();
data.addColumn(...);
data.addRows(...);
dashboard = new google.visualization.Dashboard(
document.getElementById('dashboard_div'));
// <ControlWrapper / chart definitions, bindings>
dashboard.draw(data);
document.getElementById('myDropDown').onchange = function () {
// get the dropdown value and change settings as necessary
dashboard.draw(data);
};
};
On Monday, July 2, 2012 1:54:29 AM UTC-4, rtrigg wrote:
>
> Hi Google Vis gurus,
>
> This is probably dead easy, and I'm missing the obvious. I've got a
> google visualization dashboard with controllers and charts. I've built a
> menu outside the dashboard that lets the user choose between displaying
> total $ and counts. The charts in the dashboard dynamically re-configure
> themselves depending on that menu selection.
>
> My problem is that I want the draw method of the dashboard to be invoked
> when the user makes a selection in the menu, that is, from the menu's
> onChange function. I'm using the setonloadcallback method to invoke an
> Init function that contains the definition of the dashboard, data table,
> etc. How the heck do I invoke the draw method for that dashboard from
> outside the Init function? I tried declaring the dashboard var outside the
> Init function to no avail. Does the solution involve jquery?
>
> Here's the skeleton of my code:
>
> google.load('visualization', ...);
> google.setOnLoadCallback(Init);
>
> function Init () {
>
> var data = new google.visualization.DataTable();
> data.addColumn (...);
> data.addRows (...);
>
> dashboard = new google.visualization.Dashboard(
> document.getElementById('dashboard_div'));
>
> <ControlWrapper/chart definitions, bindings>
> dashboard.draw(data);
>
> };
>
> Thanks in advance!
>
> - Randy
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/AaFk-s4v2D0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.