Hi, I am new to the Visualization API. I am writing a simple column chart to display the "weight" data for a user, here is what my code looks like:
<?php //.... some php code to get data from database //...then data is formatted and put in a string called $chart_data $chart_data ='['2012-01-02', 58.6], ['2012-01-03', 60.6], ['2012-01-04', 61.6], ['2012-01-05', 63.6]'; ?> <html><head> <script type="text/javascript" src="https://www.google.com/jsapi"></ script> <script type="text/javascript"> google.load('visualization', '1.0', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Date'); data.addColumn('number', 'Kg'); data.addRows([ <?php echo $chart_data; ?> ]); var options = {'title':'Body Weight','width':750,'height': 300}; var chart = new google.visualization.LineChart(document.getElementById('chart')); chart.draw(data, options); } </script> </head> <body><div id="chart"></div></body> </html> I have some AJAX code to get a new set of data, but the question is : How to update the chart data after I get it updated from AJAX response? what I am thinking is to write another drawChart function which takes a parameter and pass the new data to it. I am not sure if this is the right direction, please help, thanks a lot! -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. 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.
