If you want to refresh the data without reloading the page, you need to use
an AJAX function to fetch the data from a data source. Since you already
have the JSON output done, changing it into an AJAX data source should be
easy. There are many examples for doing this in this forum if you need
assistance.
On Friday, September 20, 2013 4:45:13 PM UTC-4, Robert Gunter wrote:
>
> 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.