commit 318cdab830a4a421e19683e3991e436499510820
parent c2e0690e0062884840e0a49f41eb571c46b82bc0
Author: Kninteman <[email protected]>
Date: Tue, 13 Jun 2023 11:38:59 +0200
Fix Point Color
Diffstat:
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/js/panda.js b/js/panda.js
@@ -54,14 +54,22 @@ var myChart = new Chart(ctx, {
data: [],
backgroundColor: 'rgba(176, 204, 207, 1)',
borderColor: 'rgba(176, 204, 207, 1)',
- borderWidth: 2
+ borderWidth: 2,
+ pointBackgroundColor: [],
+ pointBorderColor: [],
+ pointBorderWidth: [],
+ pointRadius: 5
},
{
label: 'Chengdu Research Facility 2',
data: [],
backgroundColor: 'rgba(195, 176, 207, 1)',
borderColor: 'rgba(195, 176, 207, 1)',
- borderWidth: 2
+ borderWidth: 2,
+ pointBackgroundColor: [],
+ pointBorderColor: [],
+ pointBorderWidth: [],
+ pointRadius: 5
}
]
},
@@ -115,14 +123,14 @@ function fetchDataAndUpdateChart() {
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].pointBackgroundColor = chengduData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(176, 204, 207, 1)');
+ myChart.data.datasets[0].pointBorderColor = chengduData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(176, 204, 207, 1)');
+ myChart.data.datasets[0].pointBorderWidth = 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].pointBackgroundColor = kangdingData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(195, 176, 207, 1)');
+ myChart.data.datasets[1].pointBorderColor = kangdingData.map(value => value > 80 ? 'rgba(207, 72, 72, 1)' : 'rgba(195, 176, 207, 1)');
+ myChart.data.datasets[1].pointBorderWidth = kangdingData.map(value => value > 80 ? 10 : 2);
myChart.data.datasets[1].data = kangdingData;
myChart.update();
@@ -144,4 +152,4 @@ function splitData(data) {
}
fetchDataAndUpdateChart();
-setInterval(fetchDataAndUpdateChart, 300000);
-\ No newline at end of file
+setInterval(fetchDataAndUpdateChart, 300);
+\ No newline at end of file