Column charts with data from a MySQL database

183 views
Skip to first unread message

John

unread,
Jul 25, 2016, 4:20:55 AM7/25/16
to Google Visualization API
Hello guys,

I've been trying to use the Google charts in order to make a column chart but I have been unsuccessful in displaying the plot.
A white page loads when I output the results.

I made two files. One that gets the data from the database and encodes it in a json format and the 2nd one uses the javascript to output the plot, as instructed by the documentation.
Both files are attached. Certain data was replaced with "xxx.." to hide sensitive information.

The output of my getData.php is :

{"cols":[{"label":"Curent","type":"number"},{"label":"Tensiune","type":"number"},{"label":"Energie_generata","type":"number"}],
"rows":[{"c":[{"v":10},{"v":15},{"v":3}]},{"c":[{"v":12},{"v":11},{"v":2}]},{"c":[{"v":10},{"v":15},{"v":3}]},{"c":[{"v":12},{"v":11},{"v":2}]},{"c":[{"v":0},{"v":0},{"v":0}]},{"c":[{"v":14},{"v":12},{"v":5}]},{"c":[{"v":0},{"v":0},{"v":0}]},{"c":[{"v":14},{"v":12},{"v":5}]}]}

I won't paste the index.php code since it can be viewed when opening the file.

For sure I am not seeing something and for sure I am making a mistake but I just can't see it and I can't understand why the plot isn't displayed.
I would appreciate any piece of advice.

Many thanks ! :D
getData.php
index.php

Daniel LaLiberte

unread,
Jul 25, 2016, 9:57:20 AM7/25/16
to Google Visualization API
John,

We can't process you php code, so in order to help you, we need you to point us at a web page (privately if you wish) or create an example html from your page that hides your data.

If your want to debug this on your own, look in your browser's javascript debugger and note whether there are any errors reported.

Another useful technique is to display a Table with your data, just to see that you are getting the data you expected.


--
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/76753e6a-19a2-48ef-a833-04654a26eb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

John

unread,
Jul 26, 2016, 9:30:23 AM7/26/16
to Google Visualization API
Hello Daniel,

First of all many thanks for the reply.
I managed to display the chart, by apparently changing only the source for jquery.

There is a twist though :

I can only display the chart when accessing the website from outside the localhost. All happened today since I only worked on the localhost until now.

The twist is that when I try to access the site in the localhost's browser i get the  "Invalid data table format:must have at least 2 columns"  error.
It works from let's say "external" but it doesn't work internally.
I have to say that I am bit baffled by this fact.

Any advice or thought regarding what leads to the error mentioned above when opening the web page in the localhoost's browser ?
I don't know what information would be viable in diagnosing this issue so please let me know if possible if certain data is needed.

The platform on which i have the web server (Apache) is a Raspberry PI2 with Debian Jessie as operating system.
Reply all
Reply to author
Forward
0 new messages