modified: server.js

modified:   static/js/sensor-2.js
	modified:   static/js/sensor-3.js
	modified:   static/js/sensor-4.js
This commit is contained in:
IrisVega 2024-07-20 19:58:06 +08:00
parent 12b6bbe4b9
commit 0050451b66
4 changed files with 4 additions and 4 deletions

View File

@ -65,7 +65,7 @@ function getLatestSensorData(callback) {
const timestamps = results.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' ')); const timestamps = results.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' '));
callback({ callback({
temperatures: data.temperature, temperatures: data.temperature,
humiditys: data.humidity, humidities: data.humidity,
co2: data.co2, co2: data.co2,
pressure: data.pressure, pressure: data.pressure,
timestamps timestamps

View File

@ -121,7 +121,7 @@ document.addEventListener('DOMContentLoaded', function () {
series: [{ name: '湿度', type: 'line', data: humidities }] series: [{ name: '湿度', type: 'line', data: humidities }]
}; };
myChart.setOption(option); myChart.setOption(option);
document.getElementById('temperature').textContent = `当前湿度: ${humidities[humidities.length - 1]}`; document.getElementById('humidity').textContent = `当前湿度: ${humidities[humidities.length - 1]}`;
} }
// 初始化时获取所有数据 // 初始化时获取所有数据

View File

@ -122,7 +122,7 @@ document.addEventListener('DOMContentLoaded', function () {
series: [{ name: 'CO2', type: 'line', data: co2 }] series: [{ name: 'CO2', type: 'line', data: co2 }]
}; };
myChart.setOption(option); myChart.setOption(option);
document.getElementById('temperature').textContent = `当前CO2: ${co2[co2.length - 1]}`; document.getElementById('co2').textContent = `当前CO2: ${co2[co2.length - 1]}`;
} }
// 初始化时获取所有数据 // 初始化时获取所有数据

View File

@ -123,7 +123,7 @@ document.addEventListener('DOMContentLoaded', function () {
series: [{ name: '压力', type: 'line', data: pressure }] series: [{ name: '压力', type: 'line', data: pressure }]
}; };
myChart.setOption(option); myChart.setOption(option);
document.getElementById('temperature').textContent = `当前压力: ${pressure[pressure.length - 1]}`; document.getElementById('pressure').textContent = `当前压力: ${pressure[pressure.length - 1]}`;
} }
// 初始化时获取所有数据 // 初始化时获取所有数据