My code is the following.... the output of the php file is a json string.
it works when I reload the page. but I want to change the chart dynamically
each time i press the button. Although the page source shows the updated
information, the alert box will show me the old data. What am I missing?
<script type="text/javascript">
var data, options, chart;
google.load("visualization", "1", {packages:["corechart"]});
function drawChart() {
var jsonData = eval ( '<?php include 'datajson.php' ?>') ;
var data = new google.visualization.DataTable();
data.addColumn('string', 'A');
data.addColumn('number', 'B');
data.addColumn('number', 'C');
data.addColumn('number', 'D');
data.addColumn('number', 'E');
for (var i=0; i < jsonData.length; i++) {
data.addRow([jsonData[i].A,parseInt(jsonData[i].B),
parseFloat(jsonData[i].C),
parseInt(jsonData[i].D), parseFloat(jsonData[i].E)]);
};
alert(jsonData[1].A);
var options = {
title: 'abc',
bubble: {textStyle: {fontSize: 11}},
colorAxis: {colors: ['F7FDFA', 'FFD0D4']}
};
var chart = new
google.visualization.BubbleChart(document.getElementById('chart_div'));
chart.draw(data, options);
};
</script>
<body>
<div id="chart_div" style="width: 900px; height: 450px;"></div>
*<input type="button" value="draw" onclick="drawChart()">*
</body>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.