Google Chart


The Google Chart gallery offers many types of charts ready to use, ranging from simple line charts to intricate hierarchical tree maps.

  • Scatter Chart
  • Line Chart
  • Bar / Column Chart
  • Area Chart
  • Pie Chart
  • Donut Chart
  • Org Chart
  • Map / Geo Chart

How to Use Google Chart?

1. Add a <div> element (with a unique id) in the HTML where you want to display the chart:

<div id="myChart" style="max-width:700px; height:400px"></div>

2. Add a link to the charts loader:

<script src="https://www.gstatic.com/charts/loader.js"></script>

3. Load the Graph API, and add the function to run when the API is loaded:

<script>
google.charts.load('current',{packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);

// Your Function
function drawChart() {
...
}
</script>

Bar Charts

World Wide Wine ProductionMhl0204060ItalyFranceSpainUSAArgentina
ContryMhl
Italy55
France49
Spain44
USA24
Argentina15

Pie Charts

World Wide Wine ProductionItalyFranceSpainUSAArgentina29.4%8%12.8%23.5%26.2%
ContryMhl
Italy55
France49
Spain44
USA24
Argentina15

To convert a Bar Chart to a Pie chart, just replace:google.visualization.BarChartwith:google.visualization.PieChart


3D Pie

World Wide Wine ProductionItalyFranceSpainUSAArgentina29.4%8%12.8%23.5%26.2%
ContryMhl
Italy55
France49
Spain44
USA24
Argentina15

To show the Pie in 3D, simply include is3D: true in the options.


Line Graph

House Prices vs. Size60801001201400.02.55.07.510.012.515.0Square MetersPrice in Millions
PriceSize
507
608
708
809
909
1009
11010
12011
13014
14014
15015

Scatter Plots

House Prices vs. Size0501001500.02.55.07.510.012.515.0Square MetersPrice in Millions
PriceSize
507
608
708
809
909
1009
11010
12011
13014
14014
15015

To create a scatter plot with the same data, switch "google.visualization" to "ScatterChart".