diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-07-05 21:23:22 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-07-05 21:23:22 -0500 |
| commit | c4d87a3c25a9b1376ed3252f09fbec83303057f1 (patch) | |
| tree | 52cd21b37c5fd1ae52c9056fb3b92761e61e5fcd /src | |
| parent | aa86e4c3e67a4b9ae591325b3e4d2a6d9c31f77b (diff) | |
| download | slskd-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.jsx | 13 |
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(() => { |
