Hi Sergey,

I was using that exact sample code, the pizza example. 

I copied the code directly from the 
website. https://developers.google.com/chart/interactive/docs/basic_load_libs

<html>
  <head>
    <!--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);

      // Callback that creates and populates a data table, 
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {

      // Create the data table.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Topping');
      data.addColumn('number', 'Slices');
      data.addRows([
        ['Mushrooms', 3],
        ['Onions', 1],
        ['Olives', 1], 
        ['Zucchini', 1],
        ['Pepperoni', 2]
      ]);

      // Set chart options
      var options = {'title':'How Much Pizza I Ate Last Night',
                     'width':400,
                     'height':300};

      // Instantiate and draw our chart, passing in some options.
      var chart = new 
google.visualization.PieChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
  </head>

  <body>
<!--Div that will hold the pie chart-->
    <div id="chart_div" style="width:400; height:300"></div>
  </body>
</html>


I am getting a syntax error here:

*google.load('visualization', '1.0', {'packages':['corechart']});*



------------


I am putting this directly into google scripts. Is this wrong?






On Wednesday, February 4, 2015 at 2:32:53 PM UTC-5, Sergey wrote:
>
> Hi, you're likely forgetting to either include the jsapi script or to do 
> the google.load call (or forgetting to specify your function as a callback 
> to the google load call so that it waits for the charts to load before 
> attempting to draw them). It's really hard to determine exactly where your 
> mistake is without getting a code sample from you, but here is a jsfiddle 
> that you can base your code on: http://jsfiddle.net/walkingeyerobot/aSRUx/
>
> Please note that the jsfiddle example does not have a reference to the 
> jsapi script in the HTML. This is not because it doesn't require jsapi, but 
> because it's hidden away under "External Resources". If you have any more 
> questions (or if I haven't answered this one clearly), please post back 
> with an example of where our charts don't work. We would prefer a jsfiddle, 
> but a full HTML page would work as well.
>
> On Wed Feb 04 2015 at 2:20:19 PM Lynn Tran <[email protected] 
> <javascript:>> wrote:
>
>> I've copied every sample code from 
>> https://developers.google.com/chart/interactive/docs/examples and none 
>> of them seem to work. I always get an error.
>>
>> For example, they have a line that reads:   var data = new 
>> google.visualization.DataTable();
>> And it keeps saying "ReferenceError: "google" is not defined. (line 2, 
>> file "Code")
>>
>>
>> And there just seems to be an error with all the examples. Is it me? Am I 
>> doing something wrong?
>>
>>
>>  

-- 
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/d/optout.

Reply via email to