O que é o Google Charts?
O Google Maps é uma API do Google
O Google Fonts é uma API do Google
O Google Charts é uma API do Google
Saiba como adicionar o Google Charts à sua página da web.
Exemplo
Gráfico de pizza do Google
Comece com uma página da web simples e básica.
Adicione um elemento <div> com o id "piechart":
Exemplo
<!DOCTYPE html>
<html>
<body>
<h1>My Web Page</h1>
<div id="piechart"></div>
</body>
<html>
Adicione uma referência à API de gráficos em google.com:
Exemplo
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
E adicione uma função JavaScript:
Exemplo
<script type="text/javascript">
// Load google charts
google.charts.load('current',
{'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
// Draw the chart and set the chart values
function drawChart() {
var data =
google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 8],
['Friends', 2],
['Eat', 2],
['TV',
2],
['Gym', 2],
['Sleep', 8]
]);
// Optional; add
a title and set the width and height of the chart
var options = {'title':'My
Average Day', 'width':550, 'height':400};
// Display the chart
inside the <div> element with id="piechart"
var chart = new
google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>