fix: display every other day sequentially for month ticks

Co-authored-by: aider (gemini/gemini-3.1-pro-preview) <aider@aider.chat>
This commit is contained in:
Tanner
2026-08-26 16:03:22 +00:00
co-authored by aider
parent 3c1a0b41a2
commit 75734bb9b2
+6 -2
View File
@@ -79,13 +79,15 @@ function useSensor(measurement, name, end, duration) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
ticks = []; ticks = [];
let lastLabel = null; let lastLabel = null;
let dayCount = 0;
data.forEach(d => { data.forEach(d => {
const lbl = memoConvertTZ(isDST, d.time, duration.format); const lbl = memoConvertTZ(isDST, d.time, duration.format);
if (lbl !== lastLabel) { if (lbl !== lastLabel) {
if (duration.len !== 'Month' || parseInt(lbl, 10) % 2 !== 0) { if (duration.len !== 'Month' || dayCount % 2 === 0) {
ticks.push(d.time); ticks.push(d.time);
} }
lastLabel = lbl; lastLabel = lbl;
dayCount++;
} }
}); });
} }
@@ -730,13 +732,15 @@ function MultiLineChart({title, measurement, dataKey, sensors, colors, end, dura
if (Array.isArray(data)) { if (Array.isArray(data)) {
ticks = []; ticks = [];
let lastLabel = null; let lastLabel = null;
let dayCount = 0;
data.forEach(d => { data.forEach(d => {
const lbl = memoConvertTZ(isDST, d.time, duration.format); const lbl = memoConvertTZ(isDST, d.time, duration.format);
if (lbl !== lastLabel) { if (lbl !== lastLabel) {
if (duration.len !== 'Month' || parseInt(lbl, 10) % 2 !== 0) { if (duration.len !== 'Month' || dayCount % 2 === 0) {
ticks.push(d.time); ticks.push(d.time);
} }
lastLabel = lbl; lastLabel = lbl;
dayCount++;
} }
}); });
} }