I was able to get going rendering data sets of time plots so I didn’t think graph problems would be that much more challenging, but for some reason I’m having real trouble outputting this properly.
Json data :
[{"data":[
{"label":"Times Appeared In Backpacks","data":45,"color":"#D9868C"},
{"label":" All Backpacks","data":10919,"color":"#86b5d9"}]
]}
Created by
$json_data[] = array('label' => "Times Appeared In Backpacks", 'data' => $appeared, 'color'=> "#D9868C");
$json_data[] = array('label' =>" All Backpacks", 'data' => $total, 'color' => "#86b5d9");
$mergedData[] = array('data' => $json_data);
echo json_encode($mergedData);
Which is called by
$.ajax({
url: "/whats/encode_pie_graph.php",
method: 'GET',
dataType: 'json',
success: onOutboundReceivedPie
});
function onOutboundReceivedPie(data) {
console.log(data);
$.plot($(".graph_pie"), data, {
series: {
pie: {
show: true
}
},
legend: {
show: false
}
});
}
At the minute nothing outputs.
Anything glaringly incorrect here?
Thanks.
Turns out isn’t necessary.
The data I have can simply be json_encode()’d to be read via ajax and accepted by flot.