Javascript examples for Google Chart:Chart Configuration
Show JSON on a google chart in real time
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> window.onload=function(){//from www .j a v a 2 s .c o m google.charts.load('current', { 'packages': ['gauge'] }); google.charts.setOnLoadCallback(drawGauge); var gaugeOptions = { min: 0, max: 280, yellowFrom: 200, yellowTo: 250, redFrom: 250, redTo: 280, minorTicks: 5 }; var gauge; var gaugeData; function drawGauge() { gaugeData = new google.visualization.DataTable(); gaugeData.addColumn('number', 'Temperature'); gaugeData.addColumn('number', 'Humidity'); gaugeData.addRows(2); gaugeData.setCell(0, 0, 120); gaugeData.setCell(0, 1, 80); gauge = new google.visualization.Gauge(document.getElementById('gauge_div')); gauge.draw(gaugeData, gaugeOptions); repeat(); } function repeat() { var dir = Math.floor((Math.random() * 10) + 1); gaugeData.setValue(0, 0, dir * 25); gaugeData.setValue(0, 1, dir * 20); gauge.draw(gaugeData, gaugeOptions); setTimeout(repeat, 5000); } } </script> </head> <body> <div id="gauge_div" style="width:280px; height: 140px;"></div> </body> </html>