commit d5f9d6e97f8779d04b20d63ae0139e38f9f5bcbd
parent 25d133eb8cd1076030b01837e9373a6079967e8d
Author: Chris Bracken <chris@bracken.jp>
Date: Sat, 13 Nov 2021 09:21:31 -0800
CLeanup: Replaces hardcoded charts init with loop
Eliminate the hardcoded assumption of three charts, and simply loop over
the charts list.
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/static/tempestas.js b/static/tempestas.js
@@ -22,10 +22,10 @@ fetch(sensorUrl)
sensor.color = colors[i];
sensors.push(sensor);
});
- charts.forEach((chart, i) => sensorReadings[chart.id] = {});
- sensors.forEach((sensor, i) => fetchSensorData(sensor.id, charts[0]));
- sensors.forEach((sensor, i) => fetchSensorData(sensor.id, charts[1]));
- sensors.forEach((sensor, i) => fetchSensorData(sensor.id, charts[2]));
+ charts.forEach((chart, i) => {
+ sensorReadings[chart.id] = {};
+ sensors.forEach((sensor, i) => fetchSensorData(sensor.id, chart));
+ });
});
function fetchSensorData(sensorId, chart) {