jqplot 円グラフをレンダリングするために、以下のコードを使用しました。何らかの理由で、円グラフにパーセンテージが正しく表示されませんでした。
$array= array(array("Males", $males),array("Female", $females));
json_encode($array);
json ファイルの出力は次のとおりです。
[["Books","8"],["Female","0"]]
しかし、円グラフの表示は 100 ではなく 10% を示しています。これは私の円グラフのレンダラーです。
$.getJSON('jqPlot.php', function (data) {
var plot1 = jQuery.jqplot('chart1', [data], {
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' }});
});
});
しかし、json ファイルを[["Books","8"]]
円グラフに変更すると、完全に機能します。