you shouldn't have to create a new google.visualization.PieChart object -- you should be able to call the draw() method on the old object (with the new/updated DataTable). is that not working for you? am I not understanding what you're trying to do?
On Tue, Feb 16, 2010 at 3:22 PM, tphone <[email protected]> wrote: > Hi all, > > I'm a new come'r to the google visualization API and wondered if > somebody could quick help me out. > > I have a pie chart & would like to update the row (sector) values from > within a seperate function. > > How do I interact with the created .chart to update & redraw the pie > chart opposed to creating a new one each time I update the row values? > > My current code is below... > > <html> > <head> > <script type="text/javascript" src="http://www.google.com/jsapi"></ > script> > <script type="text/javascript"> > google.load("visualization", "1", {packages:["piechart"]}); > google.setOnLoadCallback(drawChart); > function drawChart() { > var data = new google.visualization.DataTable(); > data.addColumn('string', 'Task'); > data.addColumn('number', 'Hours per Day'); > data.addRows(5); > data.setValue(0, 0, 'Work'); > data.setValue(0, 1, 11); > data.setValue(1, 0, 'Eat'); > data.setValue(1, 1, 2); > data.setValue(2, 0, 'Commute'); > data.setValue(2, 1, 2); > data.setValue(3, 0, 'Watch TV'); > data.setValue(3, 1, 2); > data.setValue(4, 0, 'Sleep'); > data.setValue(4, 1, 7); > > var chart = new > google.visualization.PieChart(document.getElementById('chart_div')); > chart.draw(data, {width: 400, height: 240, is3D: true, title: > 'My Daily Activities'}); > } > > function updateChart() { > > // I've tried a few ways to update the chart from here & redraw > but I failed :( ?? > > } > > </script> > </head> > > > Any help would be brilliant. > > Thanks all > <body> > <div id="chart_div"></div> > </body> > </html> > > -- > 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]<google-visualization-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > > -- 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.
