Drawing a bar chart - Javascript Google Chart

Javascript examples for Google Chart:Bar Chart

Description

Drawing a bar chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <!--Load the AJAX API--> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {/*  w  ww  .  ja v a  2  s . c o m*/
var data = new google.visualization.DataTable();
data.addColumn('string', 'Date');
data.addColumn('number', '# of Orders');
data.addRows([
  ['01/02/17',1],
  ['01/03/17',4],
  ['01/04/17',9],
  ['01/05/17',6]
]);
var options = {
'title':'Orders over Time',
'width':500,
'height':500};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
      </script> 
   </head> 
   <body> 
      <div id="chart_div"></div>  
   </body>
</html>

Related Tutorials