mirror of
https://github.com/FliegendeWurst/sensor-dashboard.git
synced 2024-11-22 00:45:03 +00:00
Smart resize of plot in mobile UI
This commit is contained in:
parent
489d92cd9c
commit
baa2f0eea4
18
base.js
18
base.js
@ -5,6 +5,8 @@ let dataY2 = [];
|
||||
let dataY3 = [];
|
||||
let xMin = Number.MAX_SAFE_INTEGER;
|
||||
let xMax = 0;
|
||||
let height = 600;
|
||||
let isMobile = false;
|
||||
|
||||
function buttonsPlugin(opts) {
|
||||
return {
|
||||
@ -39,7 +41,7 @@ function buttonsPlugin(opts) {
|
||||
function getSize() {
|
||||
return {
|
||||
width: document.getElementById("plot").clientWidth,
|
||||
height: 600
|
||||
height: height
|
||||
};
|
||||
}
|
||||
|
||||
@ -154,15 +156,25 @@ function processCSV() {
|
||||
|
||||
// mobile view: activate 24h initially
|
||||
setTimeout(() => {
|
||||
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
|
||||
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
|
||||
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
||||
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
||||
if (vh > vw) {
|
||||
document.getElementById("day").click();
|
||||
height = vh / 2;
|
||||
uplot.setSize(getSize());
|
||||
isMobile = true;
|
||||
}
|
||||
}, 500);
|
||||
|
||||
// automatically resize plot
|
||||
window.addEventListener("resize", e => {
|
||||
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
||||
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
|
||||
if (isMobile && vw > vh) {
|
||||
height = vh;
|
||||
} else if (isMobile && vh > vw) {
|
||||
height = vh / 2;
|
||||
}
|
||||
uplot.setSize(getSize());
|
||||
});
|
||||
}
|
||||
|
@ -19,11 +19,12 @@ fn main() {
|
||||
}
|
||||
// exclude outliers (> X °C diff and not between consecutive values)
|
||||
// remember, measurements are done once every 10 minutes
|
||||
// it is unlikely the temp. will sway by 2.4 ° C in that timeframe
|
||||
// it is unlikely the temp. will sway by 1.9 °C in that timeframe
|
||||
windows_mut_each(&mut values, 3, |vars| {
|
||||
if vars[1].0 - vars[0].0 >= 5000000 {
|
||||
if vars[1].0 - vars[0].0 >= 5000000 { // keep measurements after long gaps
|
||||
return;
|
||||
}
|
||||
// spike up
|
||||
if vars[1].1.abs_diff(vars[0].1) >= 19 && vars[1].1 > vars[0].1 && vars[1].1 > vars[2].1 {
|
||||
vars[1].3 = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user