Agreed that works. Many thanks. Do you know why the google.load doesn't
work within the function. Is it to do with scope in Javascript?

On 10 September 2014 16:22, 'Jon Orwant' via Google Visualization API <
google-visualization-api@googlegroups.com> wrote:

> Why not move the google.load call above dspChart(), remove dspChart(), and
> use onclick="drawChart();" ?
>
> Jon
>
> On Wed, Sep 10, 2014 at 10:21 AM, <isaachorro...@gmail.com> wrote:
>
>> This is probably so simple it's an insult to your intelligence, but
>> what's wrong with this code. I want the chart to display when clicking the
>> button - it just hangs. If I take away the definition of the dspChart
>> function the chart draws fine.
>>
>> <html>
>> <head>
>>
>> <!--Load the AJAX API-->
>> <script type="text/javascript" src="https://www.google.com/jsapi
>> "></script>
>> <script type="text/javascript">
>>
>> function dspChart() {
>> google.load('visualization', '1', {'packages':['corechart']});
>> google.setOnLoadCallback(drawChart);
>> }
>>
>> function drawChart() {
>> // Create our data table.
>> var data = new google.visualization.DataTable();
>> data.addColumn('string', 'Topping');
>> data.addColumn('number', 'Slices');
>> data.addRows([
>>   ['Mushrooms', 3],
>>   ['Onions', 1]
>>   ]);
>> // Instantiate and draw our chart, passing in some options.
>> var chart = new
>> google.visualization.PieChart(document.getElementById('fig'));
>> chart.draw(data, null);
>> }
>>
>> </script>
>> </head>
>>
>> <body>
>> <input type="button" value="display chart" onclick="dspChart();">
>> <div id="fig"></div>
>> </body>
>> </html>
>>
>>
>>
>>  --
>> 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 google-visualization-api+unsubscr...@googlegroups.com.
>> To post to this group, send email to
>> google-visualization-api@googlegroups.com.
>> Visit this group at
>> http://groups.google.com/group/google-visualization-api.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Visualization API" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-visualization-api/xXxPljzWWRA/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> google-visualization-api+unsubscr...@googlegroups.com.
> To post to this group, send email to
> google-visualization-api@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/google-visualization-api.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to