Google Charts - Diff Column Chart

You are Here:

How to Draw a Diff Column Chart?

In this example, we will draw a diff column chart. Please hover the columns in the above chart to view particular details.


HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src=""></script> <style> #myDrawChart{ display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; align-items:center; margin:20px 0; } #myDrawChart > span{ width:450px; height:300px; } </style> </head> <body> <div id="myDrawChart"> <span id='columnchart_before'></span> <span id='columnchart_after'></span> <span id='columnchart_diff'></span> </div> <script> google.charts.load('current', {packages:['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var oldData = google.visualization.arrayToDataTable([ ['Name', 'Popularity'], ['Alex', 200], ['Blake', 4100], ['Charlie', 2700], ['Jade', 7200] ]); var newData = google.visualization.arrayToDataTable([ ['Name', 'Popularity'], ['Alex', 300], ['Blake', 650], ['Charlie', 1400], ['Jade', 5500] ]); var columnChartBefore = new google.visualization.ColumnChart(document.getElementById('columnchart_before')); var columnChartAfter = new google.visualization.ColumnChart(document.getElementById('columnchart_after')); var columnChartDiff = new google.visualization.ColumnChart(document.getElementById('columnchart_diff')); var options1 = { title:'Social Media Popularity 2019', titleTextStyle: { fontSize: 17, color: '#206020' }, legend: { position: 'top' }, }; var options2 = { title:'Social Media Popularity 2020', titleTextStyle: { fontSize: 17, color: '#5c5c3d' }, legend: { position: 'top' }, }; var options3 = { title:'Social Media Popularity 2019 vs 2020', titleTextStyle: { fontSize: 17, color: '#993300' }, legend: { position: 'top' }, }; columnChartBefore.draw(oldData, options1); columnChartAfter.draw(newData, options2); var diffData = columnChartDiff.computeDiff(oldData, newData); columnChartDiff.draw(diffData, options3); } </script> </body> </html>


Hi Developers, we almost covered 98% of Google Charts Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in Google Charts.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author