jqplot を使用して円グラフをプロットする際に問題が発生しています。
PHP から結果を取得した後、json_encode を使用して結果を json に変換しました。出力は
{"a":2,"b":1,"c":5,"d":650}
今、これらの結果を私のjavascriptに入れようとすると
<script class="code" type="text/javascript">
$(document).ready(function(){
// method 1
//var data1 = document.getElementById("dataArray").value;
//eval('data1 = '+data+';');
// method 2
var data1 = <?php echo json_encode($data); ?>;
var plot1 = jQuery.jqplot ('Chart', [data1],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});
</script>
私は 2 つの方法を試しました。1 つは非表示フィールド内に配置する方法で、もう 1 つは PHP から直接取得する方法です。どちらもUncaught. No plot target specified
Chrome コンソールでエラーが発生します。
ここで私が間違っているのは何ですか?
みんなありがとう。