|
|
@@ -28,8 +28,7 @@ function toLocalInput(date) {
|
|
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
|
}
|
|
|
|
|
|
-function setStatus(ok) {
|
|
|
- const el = $("#status");
|
|
|
+function setStatus(ok) { const el = $("#status");
|
|
|
el.classList.toggle("ok", ok === true);
|
|
|
el.classList.toggle("err", ok === false);
|
|
|
}
|
|
|
@@ -50,6 +49,19 @@ function applyPreset(days) {
|
|
|
load();
|
|
|
}
|
|
|
|
|
|
+// Kärbi kõik seeriad ühisesse ajavahemikku, et jooned algaksid ja lõpeksid koos.
|
|
|
+function clipToCommonRange(series) {
|
|
|
+ const active = series.filter((s) => Array.isArray(s.data) && s.data.length);
|
|
|
+ if (active.length < 2) return series;
|
|
|
+ const start = Math.max(...active.map((s) => s.data[0][0]));
|
|
|
+ const end = Math.min(...active.map((s) => s.data[s.data.length - 1][0]));
|
|
|
+ if (!(start < end)) return series;
|
|
|
+ return series.map((s) => {
|
|
|
+ if (!Array.isArray(s.data)) return s;
|
|
|
+ return { ...s, data: s.data.filter((d) => d && d[0] >= start && d[0] <= end) };
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
function buildOption(data) {
|
|
|
const text = cssVar("--text");
|
|
|
const muted = cssVar("--muted");
|
|
|
@@ -206,7 +218,7 @@ function buildOption(data) {
|
|
|
{ type: "inside", throttle: 50 },
|
|
|
{ type: "slider", height: 22, bottom: 14, borderColor: border, textStyle: { color: muted }, fillColor: cssVar("--accent-soft") },
|
|
|
],
|
|
|
- series,
|
|
|
+ series: clipToCommonRange(series),
|
|
|
};
|
|
|
}
|
|
|
|