Created
May 24, 2019 21:26
-
-
Save seanpat09/e0351c492c47d91adbfac2523f7f5075 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
google.charts.load('current', {'packages':['gauge']}); | |
google.charts.setOnLoadCallback(drawChart); | |
let voc_div = document.getElementById('voc_chart'); | |
let voc = parseInt(voc_div.dataset.level); | |
let voc_max = parseInt(voc_div.dataset.max); | |
let nox_div = document.getElementById('nox_chart'); | |
let nox = parseInt(nox_div.dataset.level); | |
let nox_max = parseInt(nox_div.dataset.max); | |
function drawChart() { | |
let voc_data = google.visualization.arrayToDataTable([ | |
['Label', 'Value'], | |
['VOC', voc] | |
]); | |
let nox_data = google.visualization.arrayToDataTable([ | |
['Label', 'Value'], | |
['NOX', nox] | |
]); | |
let voc_options = { | |
width: 800, height: 240, | |
redFrom: voc_max * .9, redTo: voc_max, | |
yellowFrom: voc_max * .75, yellowTo: voc_max * .9, | |
max: voc_max, | |
minorTicks: 5 | |
}; | |
let nox_options = { | |
width: 800, height: 240, | |
redFrom: nox_max * .9, redTo: nox_max, | |
yellowFrom: nox_max * .75, yellowTo: nox_max * .9, | |
max: nox_max, | |
minorTicks: 5 | |
}; | |
let voc_chart = new google.visualization.Gauge(voc_div); | |
let nox_chart = new google.visualization.Gauge(nox_div); | |
voc_chart.draw(voc_data, voc_options); | |
nox_chart.draw(nox_data, nox_options); | |
setInterval(function () { | |
voc_data.setValue(0, 1, voc + Math.round(voc * .05 * Math.random())); | |
voc_chart.draw(voc_data, voc_options); | |
}, 150); | |
setInterval(function () { | |
nox_data.setValue(0, 1, nox + Math.round(nox * .05 * Math.random())); | |
nox_chart.draw(nox_data, nox_options); | |
}, 150); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment