I'm trying to plot some JSON
Data using the jqPlot
library within an HTML 5 app powered by jqMobile. I'm placing the following code within the 'body' of the html page. Is there something I'm missing here?
<script>
$(document).ready(function() {
// get the JSON data from server
$.getJSON("myspecialurl", function(data) {
success: function(data) {
plotData(data);
}
});
// plot the data
function plotData(data) {
ds = [];
$(data).find('latitude').each(function() {
ds.push([$(this).attr('answer'), parseInt($(this).attr('count'))]);
});
$.jqplot('chart1', [ds], {
seriesDefaults: {
renderer: $.jqplot.DonutRenderer
},
legend: {
show: true
}
});
}
}
</script>
Edit: New Plot Method
function plotData( data ) {
// ds = [];
// $(data).find('latitude').each( function() {
// ds.push( [ $(this).attr('answer'), parseInt( $(this).attr('count') ) ] );
// } );
var array = data.contacts;
$.jqplot('chart1', array[0].latitude, {
seriesDefaults:{
renderer:$.jqplot.DonutRenderer
},
legend: {show:true}
});
}