can I draw chart from Goole spreadsheet

70 views
Skip to first unread message

Roni Segoly

unread,
Jun 24, 2014, 6:04:40 AM6/24/14
to google-visua...@googlegroups.com
Google spreadsheet enable publishing charts as images or interactive scripts such as the example at the bottom

When I include the script in HTML it is displayed as expected, but not updated at all or after many minutes
In this page I included HTML refresh which is ugly solution
http://212.150.200.169:84/combo3.php

I can build the charts on my HTML page but when I need lots of data or nice design features it's easier to build on the sheet itself

I have the below example where chart  is built in PHP page and only data is retrieved and then refreshed and it's nice solution
http://212.150.200.169:84/g.php

So the question
For the below script can I use draw function based on the content of the script? For me it's Greek




<script type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js">
{"dataSourceUrl":"//docs.google.com/spreadsheet/tq?key=0ArVGQYDunAPqdEFiMFZuZTJGXzd4Zm55a3ZlcUd0ZGc&transpose=0&headers=1&range=B1%3AI104&gid=9&pub=1","options":{"titleTextStyle":{"bold":true,"color":"#000","fontSize":16},"vAxes":[{"title":null,"useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null},{"useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null}],"title":"\u05e9\u05d3\u05d4 \u05d1\u05d5\u05e7\u05e8 \u05d5\u05d2\u05d3\u05e8\u05d5\u05ea","curveType":"","booleanRole":"certainty","height":371,"animation":{"duration":0},"legend":"right","width":600,"lineWidth":2,"hAxis":{"useFormatFromData":true,"minValue":null,"viewWindowMode":null,"viewWindow":null,"maxValue":null},"tooltip":{}},"state":{},"view":{},"isDefaultVisualization":false,"chartType":"LineChart","chartName":"Chart2"}
</script>

Andrew Gallant

unread,
Jun 24, 2014, 12:36:50 PM6/24/14
to google-visua...@googlegroups.com
I suspect that all you need to do is add a "refreshInterval" property to the object in the script tag:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js">
{"dataSourceUrl":"//docs.google.com/spreadsheet/tq?key=0ArVGQYDunAPqdEFiMFZuZTJGXzd4Zm55a3ZlcUd0ZGc&transpose=0&headers=1&range=B1%3AI104&gid=9&pub=1","options":{"titleTextStyle":{"bold":true,"color":"#000","fontSize":16},"vAxes":[{"title":null,"useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null},{"useFormatFromData":true,"minValue":null,"viewWindow":{"min":null,"max":null},"maxValue":null}],"title":"\u05e9\u05d3\u05d4 \u05d1\u05d5\u05e7\u05e8 \u05d5\u05d2\u05d3\u05e8\u05d5\u05ea","curveType":"","booleanRole":"certainty","height":371,"animation":{"duration":0},"legend":"right","width":600,"lineWidth":2,"hAxis":{"useFormatFromData":true,"minValue":null,"viewWindowMode":null,"viewWindow":null,"maxValue":null},"tooltip":{}},"state":{},"view":{},"isDefaultVisualization":false,"chartType":"LineChart","chartName":"Chart2","refreshInterval":60}
</script>

refreshInterval takes an integer for the number of seconds between updates.

Roni Segoly

unread,
Jun 24, 2014, 1:10:08 PM6/24/14
to google-visua...@googlegroups.com
If I add it, it will not display at all.

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

Andrew Gallant

unread,
Jun 24, 2014, 2:03:55 PM6/24/14
to google-visua...@googlegroups.com
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

Roni Segoly

unread,
Jun 25, 2014, 2:54:40 AM6/25/14
to google-visua...@googlegroups.com

Will try again today

Roni Segoly
0546466264

To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

Roni Segoly

unread,
Jun 25, 2014, 3:42:29 PM6/25/14
to google-visua...@googlegroups.com
It shows all right but brings me to another issue
I created a chart and embedded it in HTML
And also displayed it as table query using the URL within

http://docs.google.com/spreadsheet/tq?key=0Am19V2tYPHDHdE1wbG5QLVJ2NUowUTBrODFGc3REbVE&transpose=0&headers=0&range=A1%3AD1&gid=0&pub=1

But then when I changed the data in the spreadsheet it was not updated in the table query nor in the chart, so no matter how often the chart in HTML is refreshed the data is not refreshed

So back to the method I use today.I use Python and PHP to extract the cell values and return it and build the chart on the fly, for charts that I want to show immediate changes, and use your proposed method for charts I do not need to show immediate udpats

Andrew Gallant

unread,
Jun 25, 2014, 4:15:19 PM6/25/14
to google-visua...@googlegroups.com
That sounds like a caching issue.  Open the page in Chrome, and check the network tab of the developer's console to see if the requeries are being served by cached data, or if the server is sending the same response over and over again.
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-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.

Roni Segoly

unread,
Jun 26, 2014, 1:43:34 AM6/26/14
to google-visua...@googlegroups.com
As far as I can see it sends requests to server and no update reason not_modified

Andrew Gallant

unread,
Jun 26, 2014, 9:59:59 AM6/26/14
to google-visua...@googlegroups.com
If you open the page and leave it alone to update by itself, does it eventually get the new data?

Your query string specifies a range on the spreadsheet (B1:I104); is your new data in that range?
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-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.

Roni Segoly

unread,
Jun 26, 2014, 10:04:54 AM6/26/14
to google-visua...@googlegroups.com

The range is correct and chart is updated after 2 minutes or more

Roni Segoly 0546466264

To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

Andrew Gallant

unread,
Jun 26, 2014, 11:45:06 AM6/26/14
to google-visua...@googlegroups.com
I suspect that the delay is just latency in the system.  There is a delay while changes to the spreadsheet are propagated to all of the Google Docs servers.  You will see the same data until the server your query is directed to gets the updated spreadsheet.

Roni Segoly

unread,
Jun 26, 2014, 12:00:38 PM6/26/14
to google-visua...@googlegroups.com
The delay is bearable now.
Thanks
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages