Created
August 22, 2014 18:30
-
-
Save anonymous/f980bcb61858ec056e7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script type="text/javascript" src="https://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
google.load("visualization", "1", {packages:["gauge"]}); | |
google.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var gaugeData = new google.visualization.DataTable(); | |
gaugeData.addColumn('number', 'Engine'); | |
gaugeData.addColumn('number', 'Torpedo'); | |
gaugeData.addRows(2); | |
gaugeData.setCell(0, 0, 120); | |
gaugeData.setCell(0, 1, 80); | |
var gaugeOptions = {min: 0, max: 280, yellowFrom: 200, yellowTo: 250, | |
redFrom: 250, redTo: 280, minorTicks: 5}; | |
var gauge; | |
} | |
function drawGauge() { | |
gauge = new google.visualization.Gauge(document.getElementById('gauge_div')); | |
gauge.draw(gaugeData, gaugeOptions); | |
} | |
function changeTemp(dir) { | |
gaugeData.setValue(0, 0, gaugeData.getValue(0, 0) + dir * 25); | |
gaugeData.setValue(0, 1, gaugeData.getValue(0, 1) + dir * 20); | |
gauge.draw(gaugeData, gaugeOptions); | |
} | |
</script> | |
<input type='button' value='Go Faster' onclick='changeTemp(1)' /> | |
<input type='button' value='Slow down' onclick='changeTemp(-1)' /> | |
</head> | |
<body> | |
<div id="gauge_div"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment