jpMobile에서 제공하는 HTML 5 앱 내에서 jqPlot
라이브러리를 사용하여 일부 JSON
데이터를 플롯하려고합니다. html 페이지의 '본문'내에 다음 코드를 삽입합니다. 내가 여기서 누락 된 것이 있습니까?jqPlot을 사용하여 JSON 데이터 플롯
<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>
편집 : 새로운 플롯 방법 굵은의
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}
});
}
주먹눈에는 괜찮아 보입니다. 당신의 작업 전에 JSON은 어떻게 생겼습니까? 'plotData()'를 입력합니까? – Boro
콘솔이 오류 catch되지 않은 구문 에러를 던지고있다 : 예기치 않은 토큰 ( – Apollo
을 나는 또한에 대해이 오류가 데이터 예외 : ReferenceError가 : 데이터가 정의되지] – Apollo