commit 907e6e33257f6f4e403ffb3a920f0f80468aaf0e
parent 1290249e3213c55e80adb2c85d2d99c22dfbf4ed
Author: Kninteman <[email protected]>
Date: Tue, 13 Jun 2023 00:57:40 +0200
Graph Alert
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/js/panda.js b/js/panda.js
@@ -107,8 +107,19 @@ function fetchDataAndUpdateChart() {
array.push(point['humidity']);
});
let splitDataResult = splitData(data);
- myChart.data.datasets[0].data = splitDataResult.chengduData.splice(-5);
- myChart.data.datasets[1].data = splitDataResult.kangdingData.splice(-5);
+ let chengduData = splitDataResult.chengduData.splice(-5);
+ let kangdingData = splitDataResult.kangdingData.splice(-5);
+
+ myChart.data.datasets[0].backgroundColor = chengduData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(176, 204, 207, 1)');
+ myChart.data.datasets[0].borderColor = chengduData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(176, 204, 207, 1)');
+ myChart.data.datasets[0].borderWidth = chengduData.map(value => value > 80 ? 10 : 2);
+ myChart.data.datasets[0].data = chengduData;
+
+ myChart.data.datasets[1].backgroundColor = kangdingData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(195, 176, 207, 1)');
+ myChart.data.datasets[1].borderColor = kangdingData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(195, 176, 207, 1)');
+ myChart.data.datasets[1].borderWidth = kangdingData.map(value => value > 80 ? 10 : 2);
+ myChart.data.datasets[1].data = kangdingData;
+
myChart.update();
})
}