生成图片

master
夜笙歌 6 months ago
parent d28986e459
commit 67f7a1e219

@ -119,13 +119,13 @@
} }
const getData = () => { const getData = () => {
$.post(prefix + '/newDataStreak', {monitorId}, (e) => { $.post(prefix + '/newDataStreak', {monitorId}, (e) => {
$('#temInfo').html(`<span style="color:#ff0000">最高温度:${e.rows[0].maxTemperature}℃</span> <span style="color:#0b05f7">最低温度:${e.rows[0].minTemperature}℃</span> <span style="color:#0066e4">平均温度:${e.rows[0].avgTemperature}℃</span>`) $('#temInfo').html(`<span style="color:#ff0000">最高温度:${e.rows?.[0]?.maxTemperature || ''}℃</span> <span style="color:#0b05f7">最低温度:${e.rows?.[0]?.minTemperature || ''}℃</span> <span style="color:#0066e4">平均温度:${e.rows?.[0]?.avgTemperature || ''}℃</span>`)
$('#timeInfo').html(`<span style="color:#0b05f7">采集时间:${e.rows[0].collectTime}</span> `) $('#timeInfo').html(`<span style="color:#0b05f7">采集时间:${e.rows?.[0]?.collectTime || ''}</span> `)
let colors = [] let colors = []
let tems = [] let tems = []
for (i in e.rows[0]) { for (i in e.rows[0]) {
if (i.includes('site')) { if (i.includes('site')) {
tems.push(e.rows[0][i]) tems.push(e?.rows?.[0]?.[i])
} }
} }
let sum = Math.max(...tems) - Math.min(...tems) let sum = Math.max(...tems) - Math.min(...tems)
@ -136,7 +136,7 @@
} }
for (let i = 1; i <= 768; i++) { for (let i = 1; i <= 768; i++) {
colors.push(getColorByTemperature[e.rows[0]['site' + i]]) colors.push(getColorByTemperature[e?.rows?.[0]?.['site' + i]])
} }
const canvas = document.getElementById('canvas'); const canvas = document.getElementById('canvas');

Loading…
Cancel
Save