Fixed daily and graphs

This commit is contained in:
2026-06-26 01:07:25 -04:00
parent 5947b61b8f
commit 216420ad80
2 changed files with 6 additions and 4 deletions

View File

@@ -15,11 +15,11 @@ watch([() => props.metricKey, mode], async ([key]) => {
if(mode.value === 'hourly') {
past.setHours(past.getHours() - 24, 0, 0, 0);
future.setHours(future.getHours() + 24, 0, 0, 0);
rows.value = await api.hourly(past, future, props.metricKey || undefined);
rows.value = await api.hourly(past, future, `time,${props.metricKey}`);
} else {
past.setDate(past.getDate() - 3);
future.setDate(future.getDate() + 3);
rows.value = await api.daily(past, future);
rows.value = await api.daily(past, future, `time,${props.metricKey}`);
}
}, {immediate: true});
@@ -54,6 +54,7 @@ const chart = computed(() => {
// stitch current point into both paths so lines meet
const nearest = pts.reduce((a, b) => Math.abs(a.t - nowT) < Math.abs(b.t - nowT) ? a : b);
const dot = {x: xOf(nearest.t), y: yOf(nearest.v as number), v: nearest.v};
hist.push({t: nearest.t, v: nearest.v});
const toPath = (arr: typeof pts) =>
arr.map((p, i) => `${i===0?'M':'L'} ${xOf(p.t).toFixed(1)} ${yOf(p.v as number).toFixed(1)}`).join(' ');