From dcf8069f6814ad8845e3245fd6dc4048c7710656 Mon Sep 17 00:00:00 2001 From: Kelvin Ly Date: Sun, 30 Jul 2023 23:52:43 -0400 Subject: [PATCH] Add support for second voltage column --- static/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/static/index.js b/static/index.js index 08912a1..d63090d 100644 --- a/static/index.js +++ b/static/index.js @@ -36,9 +36,11 @@ function initCharts() { columns: [ ['time', 1, 2, 3, 4], ['voltage', 24, 24.5, 24.3, 24.6], + ['voltage2', 24, 24.5, 24.3, 24.6], ], axes: { voltage: 'y', + voltage2: 'y', } }, axis: { @@ -62,6 +64,7 @@ var time = [] var temp = [] var humd = [] var volts = [] +var volts2 = [] function status(msg) { document.getElementById('status').textContent = msg @@ -112,6 +115,7 @@ async function updateCharts() { temp.push(v.temp) humd.push(v.hum) volts.push(v.hv) + volts2.push(v.hv2) } }) // truncate all the lists as necessary @@ -131,11 +135,13 @@ async function updateCharts() { temp = temp.slice(slice_idx) humd = humd.slice(slice_idx) volts = volts.slice(slice_idx) + volts2 = volts2.slice(slice_idx) time = time.slice(slice_idx) const temp_d = temp.filter((_, idx) => (idx % decimation_rate) == 0) const humd_d = humd.filter((_, idx) => (idx % decimation_rate) == 0) const volts_d = volts.filter((_, idx) => (idx % decimation_rate) == 0) + const volts2_d = volts2.filter((_, idx) => (idx % decimation_rate) == 0) const time_d = time.filter((_, idx) => (idx % decimation_rate) == 0) chart.load({ @@ -149,6 +155,7 @@ async function updateCharts() { columns: [ ["time"].concat(time_d), ["voltage"].concat(volts_d), + ["voltage2"].concat(volts2_d), ] }) status("charts updated") @@ -263,6 +270,7 @@ window.onload = () => { temp = [] humd = [] volts = [] + volts2 = [] } } })