feat: convert pressure display from hPa to kPa
Co-authored-by: aider (gemini/gemini-3.1-pro-preview) <aider@aider.chat>
This commit is contained in:
+10
-4
@@ -29,6 +29,7 @@ const units = {
|
|||||||
'State': '',
|
'State': '',
|
||||||
'Lux': ' lx',
|
'Lux': ' lx',
|
||||||
'Hpa': ' hpa',
|
'Hpa': ' hpa',
|
||||||
|
'kPa': ' kPa',
|
||||||
'Soil': '',
|
'Soil': '',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -679,7 +680,7 @@ function Lux({name, sensorName, end, duration}) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MultiLineChart({title, measurement, dataKey, sensors, colors, end, duration, yDomain, unitKey}) {
|
function MultiLineChart({title, measurement, dataKey, sensors, colors, end, duration, yDomain, unitKey, transform}) {
|
||||||
const [data, setData] = useState(false);
|
const [data, setData] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
@@ -696,7 +697,11 @@ function MultiLineChart({title, measurement, dataKey, sensors, colors, end, dura
|
|||||||
const formattedData = res.data.map(d => {
|
const formattedData = res.data.map(d => {
|
||||||
const newObj = { time: d.time };
|
const newObj = { time: d.time };
|
||||||
sensors.forEach(sensor => {
|
sensors.forEach(sensor => {
|
||||||
newObj[sensor] = d[`${sensor}_${dataKey}`];
|
let val = d[`${sensor}_${dataKey}`];
|
||||||
|
if (transform && val !== undefined && val !== null) {
|
||||||
|
val = transform(val);
|
||||||
|
}
|
||||||
|
newObj[sensor] = val;
|
||||||
});
|
});
|
||||||
return newObj;
|
return newObj;
|
||||||
});
|
});
|
||||||
@@ -911,8 +916,9 @@ function Graphs({end, duration}) {
|
|||||||
colors={['black', 'red', 'blue']}
|
colors={['black', 'red', 'blue']}
|
||||||
end={end}
|
end={end}
|
||||||
duration={duration}
|
duration={duration}
|
||||||
yDomain={[870, 915]}
|
yDomain={[87, 91.5]}
|
||||||
unitKey='Hpa'
|
unitKey='kPa'
|
||||||
|
transform={v => v / 10}
|
||||||
/>
|
/>
|
||||||
<WH51Soil name='Side Garden Soil Moisture' sensorName='Side Garden' end={end} duration={duration} />
|
<WH51Soil name='Side Garden Soil Moisture' sensorName='Side Garden' end={end} duration={duration} />
|
||||||
<MultiLineChart
|
<MultiLineChart
|
||||||
|
|||||||
Reference in New Issue
Block a user