Dynamically invoke GeoChart

256 views
Skip to first unread message

Panayiotis Papadopoulos

unread,
May 3, 2012, 1:27:20 PM5/3/12
to google-visua...@googlegroups.com
Hi everyone, I am trying to draw a GeoChart but I don't want it to load on page load. I want to draw the graph only if the user clicks on a button and fetch some data with AJAX. Unfortunately it fails. It seems that google.visualization.arrayToDataTable is missing.

Do you have any tips on how to draw the data only after the page is loaded.

asgallant

unread,
May 4, 2012, 9:06:05 AM5/4/12
to google-visua...@googlegroups.com
You need to make sure that the API is loaded first, but otherwise, this should work fine.  Something like this would do the trick:

google.load('visualization''1'{'packages'['corechart']});
google.setOnLoadCallback(init);

function init ({
    document.getElementById('myButton').onclick function ({
        // draw the chart here, or call chart drawing function
    };
Reply all
Reply to author
Forward
0 new messages