Skip to content

Commit 9c25d15

Browse files
fix: update time format to include seconds and enhance chart configurations
1 parent 122cc39 commit 9c25d15

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

internal/store/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (s *Store) GetHistory(limit int) ([]Measurement, error) {
130130
return nil, err
131131
}
132132
t, _ := time.Parse(time.RFC3339, ts)
133-
m.Time = t.Format("15:04")
133+
m.Time = t.Format("15:04:05")
134134
results = append(results, m)
135135
}
136136

web/index.html

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,18 +476,25 @@ <h3><span class="chart-dot" style="background:var(--purple)"></span> DNS Resolut
476476
const isMd = window.innerWidth < 1024;
477477
const h = isSmall ? 180 : isMd ? 200 : 220;
478478

479+
const tooltipTheme = document.body.classList.contains("dark-mode") ? "dark" : "light";
480+
const labelStyle = { colors: "var(--muted)", fontSize: isSmall ? "9px" : "10px" };
481+
const tickCount = Math.min(times.length, isSmall ? 4 : 6);
482+
479483
const base = {
480-
chart: { background: "transparent", fontFamily: "'Inter',sans-serif", toolbar: { show: false }, height: h, animations: { speed: 600 } },
481-
stroke: { curve: "smooth", width: 2.5 },
484+
chart: { type: "area", background: "transparent", fontFamily: "'Inter',sans-serif", toolbar: { show: false }, height: h, animations: { speed: 400 }, zoom: { enabled: false } },
485+
stroke: { curve: "smooth", width: 2 },
486+
markers: { size: times.length <= 5 ? 4 : 0, hover: { size: 5 } },
482487
grid: { borderColor: "var(--border)", xaxis: { lines: { show: false } }, yaxis: { lines: { show: true } }, padding: { top: -8, right: 8, bottom: 0, left: 8 } },
483488
xaxis: {
484489
categories: times,
485-
labels: { style: { colors: "var(--muted)", fontSize: isSmall ? "9px" : "10px" }, rotate: 0, hideOverlappingLabels: true, maxHeight: 30 },
490+
tickAmount: tickCount,
491+
labels: { style: labelStyle, rotate: 0, hideOverlappingLabels: true, maxHeight: 30 },
486492
axisBorder: { show: false }, axisTicks: { show: false },
487493
},
488-
yaxis: { labels: { style: { colors: "var(--muted)", fontSize: isSmall ? "9px" : "10px" } } },
494+
yaxis: { labels: { style: labelStyle }, forceNiceScale: true },
489495
legend: { position: "top", fontSize: "10px", labels: { colors: "var(--subtle)" }, markers: { width: 6, height: 6, radius: 2 }, itemMargin: { horizontal: 8 } },
490-
tooltip: { theme: document.body.classList.contains("dark-mode") ? "dark" : "light", style: { fontSize: "11px" } },
496+
tooltip: { theme: tooltipTheme, style: { fontSize: "11px" }, x: { show: true } },
497+
dataLabels: { enabled: false },
491498
};
492499

493500
const fillArea = (opacity = 0.12) => ({ type: "gradient", gradient: { shadeIntensity: 0, opacityFrom: opacity, opacityTo: 0.01, stops: [0, 95] } });
@@ -498,6 +505,7 @@ <h3><span class="chart-dot" style="background:var(--purple)"></span> DNS Resolut
498505
series: [{ name: "Latency (ms)", data: history.map(h => h.latency) }],
499506
colors: ["#3b82f6"],
500507
fill: fillArea(),
508+
yaxis: { ...base.yaxis, min: 0 },
501509
});
502510
chartInstances.latency.render();
503511

@@ -523,8 +531,8 @@ <h3><span class="chart-dot" style="background:var(--purple)"></span> DNS Resolut
523531
colors: ["#ef4444", "#f59e0b"],
524532
fill: fillArea(0.1),
525533
yaxis: [
526-
{ title: { text: "Loss %", style: { fontSize: "10px", color: "var(--muted)" } }, labels: { style: { colors: "var(--muted)", fontSize: "10px" } }, min: 0 },
527-
{ opposite: true, title: { text: "Jitter ms", style: { fontSize: "10px", color: "var(--muted)" } }, labels: { style: { colors: "var(--muted)", fontSize: "10px" } }, min: 0 },
534+
{ forceNiceScale: true, min: 0, title: { text: "Loss %", style: { fontSize: "10px", color: "var(--muted)" } }, labels: { style: { colors: "var(--muted)", fontSize: "10px" } } },
535+
{ opposite: true, forceNiceScale: true, min: 0, title: { text: "Jitter ms", style: { fontSize: "10px", color: "var(--muted)" } }, labels: { style: { colors: "var(--muted)", fontSize: "10px" } } },
528536
],
529537
});
530538
chartInstances.loss.render();
@@ -535,6 +543,7 @@ <h3><span class="chart-dot" style="background:var(--purple)"></span> DNS Resolut
535543
series: [{ name: "DNS (ms)", data: history.map(h => h.dns) }],
536544
colors: ["#8b5cf6"],
537545
fill: fillArea(),
546+
yaxis: { ...base.yaxis, min: 0 },
538547
});
539548
chartInstances.dns.render();
540549
}

0 commit comments

Comments
 (0)