Displaying Google Line Charts - Javascript Google Chart

Javascript examples for Google Chart:Line Chart

Description

Displaying Google Line Charts

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from ww w  .j av a  2  s.c om*/
google.charts.load('current', {'packages':['line']});
google.charts.setOnLoadCallback(drawChart);
      function drawChart()
        {
var data = new google.visualization.DataTable();
data.addColumn('number', 'Months');
data.addColumn('number', 'Enrolled');
data.addColumn('number', 'Inactive');
data.addColumn('number', 'Guest');
data.addRows([
  [0,  700, 1200, 800],
  [1,  1000, 275, 1800],
  [2,  1250, 220, 1500],
  [3,  1100, 400, 600],
              ]);
var options = {
                        title: 'Demo Graph',
                        curveType: 'function',
                        legend: { position: 'bottom' }
              };
var chart = new google.charts.Line(document.getElementById('linechart_material'));
chart.draw(data, options);
  }
    }

      </script> 
   </head> 
   <body> 
      <div id="linechart_material" style="width: 900px; height: 500px"></div>  
   </body>
</html>

Related Tutorials