You can either pre-populate your chart's data using server-side scripting
to fill the data into the javascript, or you can set up the charts to pull
data dynamically, and create a separate script that outputs the data in a
JSON structure. How you do the first depends on the scripting language you
use, here's a simple example using PHP:
<?php
// $data is an array of chart data
// $column is an array of column data
// $options is a JSON-encoded string of chart options
?>
function drawChart () {
var data = new google.visualization.DataTable();
data.addColumn('<?php echo $column[0]['type']; ?>', '<?php echo $column[
0]['label']; ?>');
data.addColumn('<?php echo $column[1]['type']; ?>', '<?php echo $column[
1]['label']; ?>');
<?php
foreach ($data as $row) {
echo "data.addRow(['{$row[0]}', {$row[1]});";
}
?>
var chart = new google.visualization.BarChart('chart_div');
chart.draw(data, <?php echo $options; ?>);
}
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/SWvE5AODHQgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.