Google Charts - Trendlines Column Chart

You are Here:

How to Draw a Trendlines Column Chart?

Please wait google chart is loading...

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

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://www.gstatic.com/charts/loader.js"></script> </head> <body> <div id="point"> </div> <script> google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(drawTrendlines); function drawTrendlines() { var data = new google.visualization.DataTable(); data.addColumn('timeofday', 'Time of Day'); data.addColumn('number', 'Motivation Level'); data.addColumn('number', 'Energy Level'); data.addRows([ [{v: [8, 0, 0], f: '8 am'}, 1, .25], [{v: [9, 0, 0], f: '9 am'}, 2, .5], [{v: [10, 0, 0], f: '10 am'}, 3, 1], [{v: [11, 0, 0], f: '11 am'}, 4, 2.25], [{v: [12, 0, 0], f: '12 pm'}, 5, 2.25], [{v: [13, 0, 0], f: '1 pm'}, 6, 3], [{v: [14, 0, 0], f: '2 pm'}, 7, 4], [{v: [15, 0, 0], f: '3 pm'}, 8, 5.25], [{v: [16, 0, 0], f: '4 pm'}, 9, 7.5], [{v: [17, 0, 0], f: '5 pm'}, 10, 10], ]); var options = { title: 'Motivation and Energy Level Throughout the Day', trendlines: { 0: {type: 'linear', lineWidth: 2, opacity: .5}, 1: {type: 'exponential', lineWidth: 5, opacity: .4} }, hAxis: { title: 'Time of Day', format: 'h:mm a', viewWindow: { min: [7, 30, 0], max: [17, 30, 0] } }, vAxis: { title: 'Rating (scale of 1-10)' } }; var chart = new google.visualization.ColumnChart(document.getElementById('point')); chart.draw(data, options); } </script> </body> </html>

Reminder

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