mirror of
https://github.com/FliegendeWurst/sensor-dashboard.git
synced 2024-11-09 10:50:42 +00:00
Automatically resize plot
This commit is contained in:
parent
f5baaebc20
commit
489d92cd9c
15
base.js
15
base.js
@ -36,14 +36,20 @@ function buttonsPlugin(opts) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSize() {
|
||||||
|
return {
|
||||||
|
width: document.getElementById("plot").clientWidth,
|
||||||
|
height: 600
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function processCSV() {
|
function processCSV() {
|
||||||
let plotData = [dataX, dataY, dataY2];
|
let plotData = [dataX, dataY, dataY2];
|
||||||
let opts = {
|
let opts = {
|
||||||
title: "Temperature and humidity stats",
|
title: "Temperature and humidity stats",
|
||||||
id: "chart1",
|
id: "chart1",
|
||||||
class: "my-chart",
|
class: "my-chart",
|
||||||
width: document.getElementById("plot").clientWidth,
|
...getSize(),
|
||||||
height: 600,
|
|
||||||
plugins: [
|
plugins: [
|
||||||
buttonsPlugin({})
|
buttonsPlugin({})
|
||||||
],
|
],
|
||||||
@ -154,6 +160,11 @@ function processCSV() {
|
|||||||
document.getElementById("day").click();
|
document.getElementById("day").click();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
|
// automatically resize plot
|
||||||
|
window.addEventListener("resize", e => {
|
||||||
|
uplot.setSize(getSize());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Papa.parse('./x.csv', {
|
Papa.parse('./x.csv', {
|
||||||
delimiter: ",",
|
delimiter: ",",
|
||||||
|
Loading…
Reference in New Issue
Block a user