newbie looking for example

41 views
Skip to first unread message

Roni Segoly

unread,
Jun 18, 2014, 7:50:38 AM6/18/14
to google-visua...@googlegroups.com
Hi

Can someone please show me an example for using Google chart in PHP web page while updating in a loop?
I have an example someone prepared for me using Ajax and JS, and all I need is addimg a bar chart to same page which will be updated same method.
If there is a better way to implement this it's even better
Design is irrelevant now.
Anyone?

Many thanks


Andrew Gallant

unread,
Jun 18, 2014, 1:15:45 PM6/18/14
to google-visua...@googlegroups.com
There are a ton of examples on this forum, if you search for them.  This thread has a large number to work with.

Roni Segoly

unread,
Jun 18, 2014, 4:02:14 PM6/18/14
to google-visua...@googlegroups.com
I saw many examples as well
This one is working
https://developers.google.com/chart/interactive/docs/php_example
But I need an example which is keep updating without refresh
Like  this page I use
http://yozmaportal.net/g.php

--
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/3K3umS58c-0/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 18, 2014, 5:00:45 PM6/18/14
to google-visua...@googlegroups.com
The PHP examples should show you how to construct the DataTable on the back-end.  If you set up a PHP page that echos the json version of the DataTable, you can use AJAX in javascript to call that page to refresh your data.

It looks like you page does something similar already, you're just not using the DataTable structure to transmit your data.  Perhaps it would help me to answer your question if you could explain what it is about your code that you want to function differently?
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

Roni Segoly

unread,
Jun 18, 2014, 5:09:54 PM6/18/14
to google-visua...@googlegroups.com
I am newbie so need to go slowly
My page does what it needs to to do and here is the source
https://www.dropbox.com/s/x7gw7sqhuyxpqxq/g.php
Someone helped me before and with these 4 gauges it works fine
I need to add to my page another chart (bar) which is also updated same method
So one PHP with two charts (4 gauges and bar), updated from external source every X seconds

I can deal with PHP but have no knowledge of JS and Ajax

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

Andrew Gallant

unread,
Jun 18, 2014, 6:00:08 PM6/18/14
to google-visua...@googlegroups.com
Does your BarChart use the same data as the Gauges, or is it different data?
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.

Roni Segoly

unread,
Jun 18, 2014, 11:02:29 PM6/18/14
to google-visua...@googlegroups.com

I need for different data

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

Andrew Gallant

unread,
Jun 19, 2014, 10:37:14 AM6/19/14
to google-visua...@googlegroups.com
I suggest making a PHP page that pulls your data from the database and serves up a json string representation of a DataTable, as shown in the other thread.  When you have a PHP page that can serve up the data, I'll help you work through the javascript to hook the data up to a chart.

Roni Segoly

unread,
Jun 19, 2014, 10:50:04 AM6/19/14
to google-visua...@googlegroups.com
That's the easy part as even in my page the data comes from a server as  a string
Although I used simple format values separated by comma
885,514,1061,0
function get_data()
{
    $homepage = file_get_contents('http://212.150.200.169:84/read_g_gauges.php/');
    return $homepage;
  
}
I know for gauges I need a number for every gauge
What do I need for bar? Assuming I have 3, just three numbers?
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

Andrew Gallant

unread,
Jun 19, 2014, 11:51:22 AM6/19/14
to google-visua...@googlegroups.com
The BarChart needs a DataTable with at least two columns of data: 1 for the y-values and 1 for each data series.  You can take a similar approach to your existing Gauges and just update a DataTable with the new values, in which case I suspect that your system of using a comma-separated list would be fine.
Reply all
Reply to author
Forward
0 new messages