modified: server.js
modified: static/js/sensor-1.js
This commit is contained in:
parent
3ae436f20f
commit
d305f0e03c
16
server.js
16
server.js
@ -60,14 +60,18 @@ function getLatestSensorData(callback) {
|
||||
callback({ error: 'Error fetching latest sensor data' });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = results[0];
|
||||
const timestamps = data.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' '));
|
||||
const temperatures = data.map(row => row.temperature);
|
||||
const humidities = data.map(row => row.humidity);
|
||||
const co2 = data.map(row => row.co2);
|
||||
const pressure = data.map(row => row.pressure);
|
||||
callback({
|
||||
temperature: data.temperature,
|
||||
humidity: data.humidity,
|
||||
co2: data.co2,
|
||||
pressure: data.pressure,
|
||||
timestamps: data.timestamp.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' '))
|
||||
timestamps,
|
||||
temperatures,
|
||||
humidities,
|
||||
co2,
|
||||
pressure
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
// 添加新的数据
|
||||
timestamps.push(data.timestamps);
|
||||
temperatures.push(data.temperature);
|
||||
temperatures.push(data.temperatures);
|
||||
|
||||
updateChart();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user