Hello everyone, im trying and it seems very painful the google api
with json.
Here is my code:
My php code:
<?php
$datos = array(
"cols" => array(
array("id"=>"dia", "label"=>"Dia", "type"=>"number"),
array("id"=>"juegos", "label"=>"Juegos", "type"=>"number"),
array("id"=>"programas", "label"=>"programas",
"type"=>"number")
),
"rows" => data(),
);
function data(){
$datos = array();
for($i=0;$i<10;$i++){
$datos[$i]=array("dia" => $i+1, "juegos" => rand(0,1000),
"programas" => rand(0,1000));
}
return $datos;
}
header('content-type: application/json');
echo json_encode($datos);
?>
my html
function drawChart() {
var jsonData = null;
var jsonDataRes = $.ajax({
url: "json_service.php",
dataType:"json",
async: false,
success: (
function(data) {
jsonData = data;
})
});
var data = google.visualization.arrayToDataTable(jsonData);
The error is "Not an array" on the firebug.
Any suggestions?
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
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.