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' });
|
callback({ error: 'Error fetching latest sensor data' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = results[0];
|
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({
|
callback({
|
||||||
temperature: data.temperature,
|
timestamps,
|
||||||
humidity: data.humidity,
|
temperatures,
|
||||||
co2: data.co2,
|
humidities,
|
||||||
pressure: data.pressure,
|
co2,
|
||||||
timestamps: data.timestamp.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' '))
|
pressure
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
// 添加新的数据
|
// 添加新的数据
|
||||||
timestamps.push(data.timestamps);
|
timestamps.push(data.timestamps);
|
||||||
temperatures.push(data.temperature);
|
temperatures.push(data.temperatures);
|
||||||
|
|
||||||
updateChart();
|
updateChart();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user