Google combo column chart - Javascript Google Chart

Javascript examples for Google Chart:Column Chart

Description

Google combo column chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Combo Chart Example</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <div id="chart_div" style="width: auto; height: 500px;"></div> 
      <script type="text/javascript">
      var examname = ["Test Name 1", "Full Test", "Knowledge Test"];
      var highestScore = ["8", "11", "10"];
      var userScore = ["6", "11"];
      google.charts.load('current', {
        'packages': ['corechart']
      });//  w ww. j ava2 s.  com
      google.charts.setOnLoadCallback(drawVisualization);
      function drawVisualization() {
        var graphData = new google.visualization.DataTable();
        graphData.addColumn('string', 'TestName');
        graphData.addColumn('number', 'Height');
        graphData.addColumn('number', 'YourScore');
        for (var i = 0; i < examname.length; i++) {
          if (userScore[i] === undefined) {
            userScore[i] = 0;
          }
          console.log(userScore[i]);
          graphData.addRow([
            examname[i],
            Number(highestScore[i]),
            Number(userScore[i])
          ]);
        }
        var options = {
          title: 'Score Dashboard',
          vAxis: {
            title: 'Score'
          },
          hAxis: {
            title: 'Exam Name'
          },
          seriesType: 'bars',
          series: {
            5: {
              type: 'line'
            }
          }
        };
        var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
        chart.draw(graphData, options);
      }

      </script>  
   </body>
</html>

Related Tutorials