Google Gauge Chart with more than one yellow and red band

35 views
Skip to first unread message

Michael Thompson

unread,
Apr 19, 2018, 12:28:42 PM4/19/18
to Google Visualization API
I have a WWW page that gets a voltage from an AWS IoT sensor and displays the value in a Gauge Chart.

I would like to have one green band that indicates an acceptable voltage range, yellow bands above and below the green band that indicates that the voltage is a little high or a little low, and red bands above and below the yellow bands that indicates that the voltage is a too high or too low.

I have it working with one green, yellow, and red band.

How do I modify the gauge so that I can display two yellow and two red bands?

Cheryl Evans

unread,
Apr 19, 2018, 2:30:30 PM4/19/18
to google-visua...@googlegroups.com
google.setOnLoadCallback(drawChart);
      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Label', 'Value'],
          ['Memory', 80],
          ['CPU', 55],
          ['Network', 68]
        ]);

        var options = {
          width: 400, height: 120,
          redFrom: 30, redTo: 60, redColor:'#00FF00',
          greenFrom: 0, greenTo: 100, greenColor:'#FF0000',
          yellowFrom:10, yellowTo: 90,
          minorTicks: 5
        };

        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);
      }

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/96bdef36-f127-4bbb-aa75-aaf6abc075f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Thompson

unread,
Apr 20, 2018, 10:18:44 AM4/20/18
to Google Visualization API
Cheryl,

That works perfectly. I tried many variations of the "options" and could not get it to work the way that I wanted.
To post to this group, send email to google-visua...@googlegroups.com.

Cheryl Evans

unread,
Apr 20, 2018, 1:25:06 PM4/20/18
to google-visua...@googlegroups.com
Glad it worked out for you


Sent from my iPad
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
Reply all
Reply to author
Forward
0 new messages