Here is a code example that is working well for me, with a dynamic loading
of the API.
For those that are not in the details:
Note that the point here is that sometimes you want to load the API after
the page was fully loaded, and so calling setOnLoadCallback() is meaningless
(since this event was already triggered by the browser).
For these cases, you can use the dynamic API loading as in the example here.
In this case you specify the callback function to be called as a parameter
to the google.load function.
VizGuy
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi
"></script>
<script type="text/javascript">
function init() {
google.load("visualization", "1", {packages:["areachart"], callback:
drawChart});
}
var chart;
var div;
var data;
function drawChart() {
data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addRows(3);
data.setValue(0, 0, '2004');
data.setValue(0, 1, 1000);
data.setValue(1, 0, '2005');
data.setValue(1, 1, 1170);
data.setValue(2, 0, '2006');
data.setValue(2, 1, 1660);
div = document.getElementById('chart_div');
div.innerHTML = '';
chart = new google.visualization.AreaChart(div);
chart.draw(data, {width: 400, height: 240});
}
</script>
</head>
<body>
<button onclick="init()">try now</button>
<div id="chart_div"></div>
</body>
</html>
On Sun, Nov 30, 2008 at 12:58 AM, jago <[EMAIL PROTECTED]> wrote:
>
> The callback works when I load the map-lib, but doesn't for the
> visualization lib. Does the visualization library support dynamic
> loading at all?
>
> Cheers,
> jago
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
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
-~----------~----~----~----~------~----~------~--~---