i need help in adding $data into datatable data.setvalue where will be used to generate column chart. first column = x-axis while the rest of the columns = elements. thanks in advance.
<?php
$result=mssql_fetch_array($row);
// $result already in correct structure.
$data = json_encode($result);
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable(<?php echo $data ?>);
<?php foreach($data as $row): ?>
data.setValue(<?php echo $row['columnA']; ?>, <?php echo $row['columnB']; ?>,<?php echo $row['columnC']; ?>);
<?php endforeach; ?>
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240, title: 'Performance',
hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
});
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>