What is the recommended way to load the google visualization libraries?

25 views
Skip to first unread message

Ben

unread,
Aug 31, 2011, 2:48:25 PM8/31/11
to Google Visualization API
Hi,

What is the recommended way to load the visualization libraries?

I noticed in the documentations there are two methods:

OPTION 1
http://code.google.com/apis/chart/interactive/docs/quick_start.html

<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/
jsapi"></script>
<script type="text/javascript">

// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});

// Set a callback to run when the Google Visualization API is
loaded.
google.setOnLoadCallback(drawChart);


OPTION 2
<!-- One script tag loads all the required libraries! Do not
specify any chart types in the autoload statement. -->
<script type="text/javascript"
src='https://www.google.com/jsapi?autoload={"modules":
[{"name":"visualization","version":"1"}]}'>
</script>
<script type="text/javascript">
google.setOnLoadCallback(drawVisualization);

Which one should we use or which one is better?

thanks

asgallant

unread,
Aug 31, 2011, 3:02:49 PM8/31/11
to google-visua...@googlegroups.com
The first allows you to make some decisions about which module(s) to load programatically; I think the second method is a tiny bit faster (maybe a few milliseconds).  I don't think there is a "recommended" way to do it.  Use whichever you find easier.

Viz Kid

unread,
Sep 1, 2011, 7:55:54 AM9/1/11
to google-visua...@googlegroups.com

Indeed the second option is a bit faster as it reduces one round trip to Google servers. You can however specify all the options in both loading schemes (unlike the example you wrote where you did not load 'corechart' at all).
For easy usage of the second method, there is the auto loader wizard: http://code.google.com/apis/loader/autoloader-wizard.html

Hope this helps,
  Viz Kid

On Wed, Aug 31, 2011 at 10:02 PM, asgallant <drew_g...@abtassoc.com> wrote:
The first allows you to make some decisions about which module(s) to load programatically; I think the second method is a tiny bit faster (maybe a few milliseconds).  I don't think there is a "recommended" way to do it.  Use whichever you find easier.

--
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/-/v5zhKb7y8dIJ.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Reply all
Reply to author
Forward
0 new messages