i want to show 3 data colomn in pie chart, but just showing 2 colomn. if i used bar, its working. i want to showing storage_type,storage_used and storage_free but just storage_type and storage_used.but if i test with bar chart its working, but cannot working with pie chart.
this is my db
this is my output
<?Php
require "configdashboard.php";// Database connection
if($stmt = $connection->query("SELECT ,storage_used,storage_free FROM storage WHERE storage_type ='fujitsu'")){
while ($row = $stmt->fetch_row()) {
$php_data_array[] = $row; // Adding to array
}}
echo "<script>
var my_2d = ".json_encode($php_data_array)."
</script>";
?>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load the Visualization API and the corechart package.
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'type');
data.addColumn('number', 'used');
data.addColumn('number', 'free');
for(i = 0; i < my_2d.length; i++)
data.addRow([my_2d[i][0], parseInt(my_2d[i][1]),parseInt(my_2d[i][2])]);
var options = {
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
Masukkan kode di sini...