Re: [visualization-api] Syntax error with code

36 views
Skip to first unread message
Message has been deleted

Daniel LaLiberte

unread,
Nov 10, 2015, 8:51:20 AM11/10/15
to Google Visualization API
That code runs fine just by copy-pasting it into jsfiddle:  http://jsfiddle.net/dlaliberte/Ly71ea8f/

So perhaps you are not running what you think you are.  Perhaps your editor is causing some confusion.  Could you post a link to a page where we can see what you are doing?

On Tue, Nov 10, 2015 at 8:23 AM, Newbie <scott....@unitedbiscuits.com> wrote:
Hi,
I'm trying to create an interactive chart using apps script to embed on a Google site. I'm using the following code to try and experiment, but receiving the error message: Syntax error. (line 7, file "Code")
Does anyone know how I can get around this! I've looked online for a while and haven't been able to find anything but it's stopping me from being able to progress further. 
Thanks for your help!!

(Code)
<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"></div>
 
</body>
</html>

This e-mail and any attachments are confidential and solely for the use of
the intended recipient.  They may contain material protected by legal
professional or other privilege. If you receive it in error, please delete
it from your system, make no copies of it, do not disclose its contents to
any third party or use it for your own or any other person's benefit.
Please advise the sender of its receipt as soon as possible. Although this
email and its attachments are believed to be free of any virus or other
defect, it is the responsibility of the recipient to ensure that they are
virus free and no responsibility is accepted by the company for any loss or
damage arising from receipt or use thereof. Any opinions expressed that do
not relate to the official business of the company are those of the author,
not the United Biscuits group of companies.

United Biscuits (UK) Limited Registered in England number 2506007
Registered Office: Hayes Park, Hayes End Road, Hayes, Middlesex, UB4 8EE

--
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-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/7b026c92-8f64-48bb-a39d-005cc4b67b1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Scott Barnes

unread,
Nov 10, 2015, 9:33:57 AM11/10/15
to google-visua...@googlegroups.com
Hi Daniel, 

Yes you're right. Weirdly it works in JSFiddle but then when I put it into Google Apps Script, split it into the HTML and JS blocks, then try to Deploy it as a Web app I get an error code. 

I therefore feel like it might be the last step I'm stumbling on? 

--
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/giQjKnIgSIA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.



--
Kind regards,

Scott Barnes
IS Intern 
722 5319

United Biscuits
Hayes Park
Middlesex
UB4 8EE


Reply all
Reply to author
Forward
0 new messages