I should really write that down, since I encounter a question involving some variant of improper loading a few times a week.
On Tuesday, November 19, 2013 1:31:56 PM UTC-5, Daniel LaLiberte wrote: > > Point of clarification: The google loader doesn't actually detect when it > is called from a function, but it does behave differently when it is called > after the document has finished loading, as opposed to while the document > is still loading. Typically, scripts don't call functions until all the > code is loaded, which is sometime after the document has finished loading. > It is possible to call google.load() either way, but you must use the > 'callback' option if the document has already finished loading. > > dan > > > On Fri, Nov 15, 2013 at 10:52 AM, asgallant > <[email protected]<javascript:> > > wrote: > >> This is likely due to a quirk in the google loader. When the google >> loader is called from within another function, it changes its behavior, and >> the most commonly used method of assigning a callback (via >> google.setOnLoadCallback) doesn't work. If you change the way the callback >> is assigned to set it directly in the google.load call, it should work. >> Here's a proof-of-concept: >> >> $(function () { >> $.getScript('http://www.google.com/jsapi', function(data, >> textStatus, jqxhr) { >> function drawChart() { >> var data = new google.visualization.DataTable(); >> data.addColumn('string', 'Name'); >> data.addColumn('number', 'Value'); >> data.addRows([ >> ['Foo', 3], >> ['Bar', 6], >> ['Baz', 4] >> ]); >> >> var chart = new >> google.visualization.PieChart(document.querySelector('#chart_div')); >> chart.draw(data, { >> height: 400, >> width: 600 >> }); >> } >> google.load('visualization', '1', {packages:['corechart'], >> callback: drawChart}); >> }); >> }); >> >> see it working here: http://jsfiddle.net/asgallant/6kLQj/ >> >> >> On Friday, November 15, 2013 3:33:49 AM UTC-5, Xavier Palacín Ayuso wrote: >>> >>> Hi, >>> >>> I need to load the script of Google Chart -> Org Charts (orgchart): >>> <script type='text/javascript' src='https://www.google.com/jsapi >>> '></script> >>> >>> My problem is that, I use a framework and only can load JavaScript files >>> from resourcer directory (/resources/js) calling framework API method to >>> load JavaScripts. >>> I test 2 cases: >>> >>> 1. Get JavaScript content from https://www.google.com/jsapi and put >>> on a file jsap.js and move to /resources/js/jsap.js and load with a >>> framework API method to load JavaScripts, the result is, when load a >>> script >>> pages goes to white page and remains loading and waiting fro >>> www.google.com. >>> 2. Load script with jQeury method getScript(), I pass the url >>> paremeter and in callback puts Org Charts load, and the result is the >>> same >>> as case 1: when load a script pages goes to white page and remains >>> loading >>> and waiting fro www.google.com. >>> >>> I read a FAQ and see that google don't allow to use charts offline or >>> download the chart code local. >>> >>> Thanks >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Google Visualization API" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]<javascript:> >> . >> To post to this group, send email to >> [email protected]<javascript:> >> . >> Visit this group at >> http://groups.google.com/group/google-visualization-api. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> > - 978-394-1058 > [email protected] <javascript:> 5CC, Cambridge MA > [email protected] <javascript:> 9 Juniper Ridge Road, Acton MA > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/groups/opt_out.
