Gauge Chart Example

An example of a Google Gauge Chart.

by ashleycam3ron

HTML

<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['gauge']}]}"></script>
       <div id="chart_div" style="width:500px; height: 220px;"></div>

JavaScript

google.setOnLoadCallback(drawChart);
      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Label', 'Value'],
          ['Ryan', 8],
          ['Conference Room Guy', 5.5],
          ['John', 6],
          ['Todd', 3], 
          ['Intern', 4],
        ]);
        var rowData1 = [['Month', 'Ryan', 'Conference Room Guy', 'John', 'Todd  Intern','Average'],
                    ['2004/05', 10, 8, 5, 9, 4, 1.6],
                    ['2005/06', 1, 9, 5, 9, 4, 1.6],
                    ['2006/07', 1, 9, 5, 9, 4, 1.6],
                    ['2007/08', 1, 9, 5, 9, 4, 1.6],
                    ['2008/09', 1, 9, 5, 9, 4, 1.6]];
                                                         
                                                         
        var options = {
          width: 400, height: 120,
                                                         greenFrom:0, greenTo: 1,
          redFrom: 9, redTo: 10,
          yellowFrom:8, yellowTo: 9,
            max:10, min:0,
          minorTicks: 1,
         animation:{
        duration: 1000,
        easing: 'out'
      },
        };

        var chart = new google.visualization.Gauge(document.getElementById('chart_div'));

        chart.draw(data, options);

        setInterval(function() {
          data.setValue(0, 1, 40 + Math.round(60 * Math.random()));
          chart.draw(data, options);
        }, 13000);
        setInterval(function() {
          data.setValue(1, 1, 40 + Math.round(60 * Math.random()));
          chart.draw(data, options);
        }, 5000);
        setInterval(function() {
          data.setValue(2, 1, 60 + Math.round(20 * Math.random()));
          chart.draw(data, options);
        }, 26000);
      }