🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to JavaScript Notes
Topic #253

JS Google Chart

From simple line charts to complex hierarchical tree maps, the Google Chart gallery provides a large number of ready-to-use chart types:

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

How to Use Google Chart?

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

Bar Charts

Source Code

function drawChart() {

// Set Data

const data = google.visualization.arrayToDataTable([

  ['Contry', 'Mhl'],

  ['Italy', 55],

  ['France', 49],

  ['Spain', 44],

  ['USA', 24],

  ['Argentina', 15]

]);

// Set Options

const options = {

  title: 'World Wide Wine Production'

};

// Draw

const chart = new google.visualization.BarChart(document.getElementById('myChart'));

chart.draw(data, options);

}

Pie Charts

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

const chart = new google.visualization.PieChart(document.getElementById('myChart'));

3D Pie

To display the Pie in 3D, just add is3D: true to the options:

const options = {

  title: 'World Wide Wine Production',

  is3D: true

};

Line Graph

Source Code

function drawChart() {

// Set Data

const data = google.visualization.arrayToDataTable([

  ['Price', 'Size'],

  [50,7],[60,8],[70,8],[80,9],[90,9],[100,9],

  [110,10],[120,11],[130,14],[140,14],[150,15]

  ]);

// Set Options

const options = {

  title: 'House Prices vs Size',

  hAxis: {title: 'Square Meters'},

  vAxis: {title: 'Price in Millions'},

  legend: 'none'

};

// Draw Chart

const chart = new google.visualization.LineChart(document.getElementById('myChart'));

chart.draw(data, options);

}

Scatter Plots

To scatter plot the same data, change google.visualization to ScatterChart:

const chart = new google.visualization.ScatterChart(document.getElementById('myChart'));

Want to go beyond the notes?

Join CodingNow 2.0's JavaScript course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

JS Google Chart – FAQs

Quick answers about learning JS Google Chart in JavaScript.

This free note from CodingNow 2.0 explains JS Google Chart in JavaScript — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every JavaScript topic on CodingNow 2.0, including JS Google Chart, is 100% free with no signup required.
With focused practice, most students grasp JS Google Chart in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now