From c4d87a3c25a9b1376ed3252f09fbec83303057f1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 5 Jul 2026 21:23:22 -0500 Subject: include year on date labels if the data set spans years --- src/web/src/components/Shared/Graph.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/Shared/Graph.jsx b/src/web/src/components/Shared/Graph.jsx index d383345f..386f9a46 100644 --- a/src/web/src/components/Shared/Graph.jsx +++ b/src/web/src/components/Shared/Graph.jsx @@ -112,11 +112,14 @@ const Graph = ({ data = [], defaultSeries, height = 200, series = [] }) => { }); } - return (timestamp) => - new Date(timestamp).toLocaleDateString(undefined, { - day: 'numeric', - month: 'short', - }); + const spansYears = + new Date(xRange.min).getFullYear() !== new Date(xRange.max).getFullYear(); + + return (timestamp) => { + const d = new Date(timestamp); + const date = d.toLocaleDateString(undefined, { day: 'numeric', month: 'short' }); + return spansYears ? `${date} '${String(d.getFullYear()).slice(2)}` : date; + }; }, [xRange]); const yFormatter = useMemo(() => { -- cgit v1.2.3