Javascript examples for Google Chart:Pie Chart
Google Charts Pie from Json data
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> window.onload=function(){/*from www . j a va2 s . co m*/ var jsonData = { "cols": [{ "id": "", "label": "Topping", "pattern": "", "type": "string" }, { "id": "", "label": "Slices", "pattern": "", "type": "number" }], "rows": [{ "c": [{ "v": "Homme", "f": null }, { "v": 2, "f": null }] }, { "c": [{ "v": "Femme", "f": null }, { "v": 1, "f": null }] }] } function drawSexChart() { var data = new google.visualization.DataTable(jsonData); console.log(jsonData); var chart = new google.visualization.PieChart(document.getElementById('chartUsersBySex')); chart.draw(data, null); } google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawSexChart); } </script> </head> <body> <div id="chartUsersBySex"> </div> </body> </html>