From ecb0ddef370750f45b74bba8c7995b5c02bf305b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Thu, 25 Apr 2024 16:35:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArrayTemperatureData.html | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/system/ArrayTemperatureData/ArrayTemperatureData.html b/ruoyi-admin/src/main/resources/templates/system/ArrayTemperatureData/ArrayTemperatureData.html index 28d158b..092d672 100644 --- a/ruoyi-admin/src/main/resources/templates/system/ArrayTemperatureData/ArrayTemperatureData.html +++ b/ruoyi-admin/src/main/resources/templates/system/ArrayTemperatureData/ArrayTemperatureData.html @@ -28,12 +28,12 @@ let getColorByTemperature = {} - function getGradientColor(level) { + function getGradientColor(level,sum) { // 确保级别在1到50之间 - level = Math.max(1, Math.min(50, level)); + level = Math.max(1, Math.min(sum, level)); // 将级别映射到0到1之间的色相值 - const hue = (0.6 - (0.6 / 50) * level) % 1; // 0.6是红色的色相值 + const hue = (0.6 - (0.6 / sum) * level) % 1; // 0.6是红色的色相值 const saturation = 1; // 饱和度最大 const value = 1; // 亮度最大 @@ -69,15 +69,23 @@ return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`; } - for (var i = 0; i <= 10; i++) { - getColorByTemperature[20+i] = getGradientColor(i) - } const getData = () =>{ $.post(prefix+'/newDataStreak',(e)=>{ - console.log(e) $('#temInfo').html(`最高温度:${e.rows[0].maxTemperature}℃ 最低温度:${e.rows[0].minTemperature}℃ 平均温度:${e.rows[0].avgTemperature}℃`) $('#timeInfo').html(`采集时间:${e.rows[0].collectTime} `) let colors = [] + let tems = [] + for(i in e.rows[0]){ + if(i.includes('site')){ + tems.push(e.rows[0][i]) + } + } + let sum = Math.max(...tems) - Math.min(...tems) + getColorByTemperature={} + + for (var i = 0; i <= sum; i++) { + getColorByTemperature[20+i] = getGradientColor(i,sum) + } for(i in e.rows[0]){ if(i.includes('site')){ colors.push(getColorByTemperature[e.rows[0][i]]) @@ -109,7 +117,7 @@ }) } getData() - setInterval(getData,1000*60) + setInterval(getData,1000*2) })