12 hours button

This commit is contained in:
FliegendeWurst 2023-10-14 12:47:22 +02:00
parent baa2f0eea4
commit 1030cba4a0
2 changed files with 8 additions and 3 deletions

View File

@ -19,6 +19,10 @@ function buttonsPlugin(opts) {
});
}
const day12 = document.getElementById("h12");
day12.addEventListener("click", e => {
zoomRange(60 * 60 * 12);
});
const day = document.getElementById("day");
day.addEventListener("click", e => {
zoomRange(60 * 60 * 24);
@ -59,7 +63,7 @@ function processCSV() {
x: {
time: true,
range: (u, dataMin, dataMax) => {
if ((dataMax - dataMin) % (60 * 60 * 24) === 0) {
if ((dataMax - dataMin) % (60 * 60 * 12) === 0) {
return [dataMin, dataMax];
} else {
return [dataMin, Math.ceil(dataMax / (24 * 60 * 60)) * 24 * 60 * 60];

View File

@ -20,8 +20,8 @@
align-items: center;
}
button {
padding: 0.5em;
margin: 0.75em;
padding: 0.4em;
margin: 0.65em;
font-size: x-large;
}
</style>
@ -29,6 +29,7 @@
<body>
<div id="plot"></div>
<div id="buttons" style="display: none">
<button id="h12">12 hours</button>
<button id="day">24 hours</button>
<button id="week">7 days</button>
<button id="all">all data</button>