Hi all, I want to be able to toggle between two data sets with a button, so each time the button gets clicked the pie chart changes to the other data set. I've found a solution to switch to another data set (see below) but I can't figure out how I van make it toggle back. I don't know if this is even possible. This would also imply that the button text changes (f.i. from "show data set 1" to "show data set 2").
<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(initialize); var v; function initialize() { var dt = new google.visualization.DataTable(); dt.addColumn('string'); dt.addColumn('number'); dt.addRows(3); dt.setCell(0, 0,'L1'); dt.setCell(1, 0,'L2'); dt.setCell(2, 0,'L3'); dt.setCell(0, 1,123); dt.setCell(1, 1,234); dt.setCell(2, 1,345); v = new google.visualization.PieChart(document.getElementById('chart_div')); v.draw(dt, {}); } function f1() { var dt = new google.visualization.DataTable(); dt.addColumn('string'); dt.addColumn('number'); dt.addRows(2); dt.setCell(0, 0,'NL1'); dt.setCell(1, 0,'NL2'); dt.setCell(0, 1,100); dt.setCell(1, 1,200); v.draw(dt, {}); } </script> </head> <body> <div id="chart_div" style="width: 400px; height: 300;"></div> <input type='button' onclick='f1()' value='test' /> </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]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
