Google Column Chart and set column color - Javascript Google Chart

Javascript examples for Google Chart:Column Chart

Description

Google Column Chart and set column color

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <script type="text/javascript">
      google.charts.load('visualization', '1.1', {packages: ['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {//from   ww  w .ja v a  2 s.  co m
        var data = google.visualization.arrayToDataTable([
          ['Class', 'Total',{role: 'style'}],
          ['A', 10,'color: #b0120a'],
          ['B', 30,'color: #004411'],
          ['C', 20,'color: #ffab91'],
          ['D', 30,'color: #004411']
        ]);
        var options = {
          isStacked: false,
          title: 'Class wise total students',
         };
        var chart = new google.visualization.ColumnChart(document.getElementById('columnchart_material'));
        chart.draw(data, options);
      }
    
      </script> 
   </head> 
   <body> 
      <div id="columnchart_material" style="width: 100%; height: 100%;"></div>  
   </body>
</html>

Related Tutorials