I am having trouble getting my MySQL data to work with the google 
visualization API.

My php outputs the following json data using echo json_encode($data);
{"type":["A","B","C","D","E"],"totals":[276.36,23.56,42.06,0.06,6254.49]}

I generate it with the following php:

<?php
/* I'm leaving out the mysql connection and select statements, but those 
parts work fine as you can see from the echo below
$data = array(
"Type" => array
(
"A",
"B",
"C",
"D",
"E",
), 
"Totals" => array
(
$ts0,
$ts1,
$ts2,
$ts3,
$ts4,
),
);
/*
Echo $data; 
array(2) { ["Type"]=> array(5) { [0]=> string(2) "A" [1]=> string(3) "B" 
[2]=> string(3) "C" [3]=> string(3) "D" [4]=> string(3) "E" } 
  ["Totals"]=> array(5) { [0]=> float(3450.25) [1]=> float(294.09) [2]=> 
float(525.16) [3]=> float(0.77) [4]=> float(78084.22) } }
*/
/*
echo json_encode($data);
{"type":["A","B","C","D","E"],"totals":[276.36,23.56,42.06,0.06,6254.49]}
*/
?>

Now, I am just trying to create a table with this data.  I copy/paste the 
example from google code play on using json data, but no luck for me.

  function drawVisualization() {
      // Create and populate the data table.
      var JSONObject = {<?php echo json_encode($data); ?>};
      var data = new google.visualization.DataTable(JSONObject, 0.5);
    
      // Create and draw the visualization.
      visualization = new 
google.visualization.Table(document.getElementById('table'));
      visualization.draw(data, {'allowHtml': true});

What am I missing? Do I need to setup the JSON object columns first?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/ig5lpbv0544J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to