Google ビジュアライゼーションと php/mysql を使用してグラフを作成しようとしています。私のデータは次のようになります。
['RTI', 3],
['USAID', 1],
['Task Force', 1],
['DFID', 1],
['Other', 2]
$jdata を印刷すると、次のようになります。
[{"Response":"Other","Count":"3"},{"Response":"RTI","Count":"3"},{"Response":"USAID","Count":"4"}]
これはかなり近くに見えます。何かアドバイス?
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable(<?php $jdata ?>);
// Set chart options
var options = {'title':"Question1: I'm here to represent:",
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div1'));
chart.draw(data, options);
}
</script>