Use GeoChart to display data from columnchart?

430 views
Skip to first unread message

Alex Stone

unread,
May 17, 2012, 3:15:13 PM5/17/12
to google-visua...@googlegroups.com
I'm wondering if it's possible to use a GeoChart to select and show data from a columnchart.

I'm pretty new to Google Viz and code in general, but I created this column chart using a dependent control thanks to the great examples: http://jsbin.com/okekil/2/edit#javascript,html

Is it possible to also render a GeoChart in which a user could click on a U.S. state and the relevant data would display?

Thanks in advance

asgallant

unread,
May 18, 2012, 9:39:30 AM5/18/12
to google-visua...@googlegroups.com
You can set up a 'select' event handler for the GeoChart and then draw the ColumnChart based on what the user clicks on.

​google.visualization.events.addListener(geoChart'select'function ({
    var selection geoChart.getSelection();
    // selection contains an array of objects {row, column}
    // representing each selected element in the DataTable
    // most visualizations allow only 1 selection, so it's
    // usually safe to access just selection[0]
    
    var value data.getValue(selection[0].rowselection[0].column);
    // do something with value
    
    // note: selecting the same element twice in a row deselects
    // the element unless you clear the selection in the event handler
    geoChart.setSelection(null);
}); 

Alex Stone

unread,
May 18, 2012, 4:57:02 PM5/18/12
to google-visua...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages