The forum will no longer display the old thread for some reason, which
probably means I am getting close to figureing out the issue...
using your php (which outputs exactly the same thing as mine):
$myArray = array(
array('Sensor', 'Temp', array('role' => 'style')),
array('Baby', 71.15, 'green'),
array('Main', 71.2616, 'green'),
array('A', 75.425, 'green'),
array('C', 69.575, 'blue'),
array('D', 60.6866, 'blue')
);
echo json_encode($myArray);
and then :
var jsonData = $.ajax({
url: "getData-roombars2.php",
dataType:"json",
}) ;
var data = new google.visualization.arrayToDataTable( JSON.parse(jsonData)
);
it just crashes.
var parsed=JSON.parse(jsonData); also crashes. So there is still a basic
issue with getting the array passed. Im guessing the little extraneous
assoc array 'role=>style' bit is forcing json_encode to output an object
instead of an array... seems like I'll have to leave that cell in the array
blank in php, then have the javascript code manually define just that one
cell with the special formatting for arrayToDataTable.
Also, both your and my php is outputting:
[["Sensor","Temp",{"role":"style"}],["Baby",71.15,"green"],["Main",71.2616,"green"],["A",75.425,"green"],["C",69.575,"blue"],["D",60.6866,"blue"]]
which doesnt work even plugged in directly. The double quotes around the
color names have to be manually changed to single quotes and then it works
as :
var data = new
google.visualization.arrayToDataTable([["Sensor","Temp",{"role":"style"}],["Baby",71.15,'green'],["Main",71.2616,'green'],["A",75.425,'green'],["C",69.575,'blue'],["D",60.6866,'blue']]);
Not sure what special dance I need to do to make both JSON happy with
double quotes and arrayToDataTable happy with single quotes. It just seems
like Im reinventing the wheel just to pass an array.
--
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.