I have my livedata.php(the time_stamp(named ts),ph,moist are data values in 
my database) in json format showing:


[{"ts":"12","ph":736,"moist":92},{"ts":"27","ph":0,"moist":0},{"ts":"21",
> "ph":192,"moist":24},{"ts":"15","ph":0,"moist":0}]
>
> That is "ts"(time stamp('d')) shows specific day of a month(this example 
the month is august)."ph" and "moisture" are the overall value of that 
specific day. Obviously I am making charts here and I know I am a dumb full 
of ambitions I am trying to create a live chart that looks like this  .

<https://lh3.googleusercontent.com/-b2bMU8qDEGQ/Wat2U4_ubII/AAAAAAAAD8g/3VxFApfXXIwjp7BIvDgslBFwut4mkSqjwCLcBGAs/s1600/dumbme.JPG>


Now my problem is with this code below I found which is working to their 
example but trying to my php json fails.


function drawChart() {

var jsonData = $.ajax({
url: 'livedata.php',
dataType: 'json',
async: false
}).done(function (results) {
var data = new google.visualization.DataTable(jsonData);
data.addColumn('datetime', 'time_stamp');
data.addColumn('number', 'ph');
data.addColumn('number', 'moist');
$.each(results, function (i, row) {
data.addRow([
(new Date(row.time_stamp)),
parseFloat(row.ph),
parseFloat(row.moist)
]);
});
var chart = new google.visualization.LineChart($('#chart').get(0));
chart.draw(data, {
title: 'Soil Analysis'
});
});
}
// load chart lib
google.load('visualization', '1', {
packages: ['corechart']
});
// call drawChart once google charts is loaded
google.setOnLoadCallback(drawChart);







-- 
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 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/ef60aca0-a9b0-4492-a9cd-1d5a7d78afa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to