1 <html>2 <head>3 <!--Load the AJAX API-->4 <script type="text/javascript" src="https://www.google.com/jsapi"></script>5 <script type="text/javascript">6 7 // Load the Visualization API and the piechart package.8 google.load('visualization', '1.0', {'packages':['corechart']});9 10 // Set a callback to run when the Google Visualization API is loaded.11 google.setOnLoadCallback(drawChart);12 13 // Callback that creates and populates a data table,14 // instantiates the pie chart, passes in the data and15 // draws it.16 function drawChart() {17 18 // Create the data table.19 var data = new google.visualization.DataTable();20 data.addColumn('string', 'Topping');21 data.addColumn('number', 'Slices');22 data.addRows([23 ['Mushrooms', 3],24 ['Onions', 1],25 ['Olives', 1],26 ['Zucchini', 1],27 ['Pepperoni', 2]28 ]);29 30 // Set chart options31 var options = {'title':'How Much Pizza I Ate Last Night',32 'width':400,33 'height':300};34 35 // Instantiate and draw our chart, passing in some options.36 var chart = new google.visualization.PieChart(document.getElementById('chart_div'));37 chart.draw(data, options);38 }39 </script>40 </head>41 42 <body>43 <!--Div that will hold the pie chart-->44 <div id="chart_div"></div>45 </body>46 </html>47
Enlace
El enlace para compartir es: