aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-07-05 21:23:22 -0500
committerJP Dillingham <jp@dillingham.me>2026-07-05 21:23:22 -0500
commitc4d87a3c25a9b1376ed3252f09fbec83303057f1 (patch)
tree52cd21b37c5fd1ae52c9056fb3b92761e61e5fcd /src
parentaa86e4c3e67a4b9ae591325b3e4d2a6d9c31f77b (diff)
downloadslskd-c4d87a3c25a9b1376ed3252f09fbec83303057f1.tar.gz
include year on date labels if the data set spans years
Diffstat (limited to 'src')
-rw-r--r--src/web/src/components/Shared/Graph.jsx13
1 files changed, 8 insertions, 5 deletions
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(() => {