Skip to content

Commit 36c2e36

Browse files
committed
feat(StatsRoute): Increase Chart padding with small amounts of data
1 parent db31af7 commit 36c2e36

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/app/routes/stats/time-charts.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const getTicks = (
3737
const timeDotLabel = ({ y }: Coordinate) => timeHelpers.fromMinutes(y)
3838
const hourDotLabel = ({ y }: Coordinate) => `${(y / 60).toFixed(1)}h`
3939

40+
const getPadding = (items: number): [number, number] => [
41+
24,
42+
Math.max(1, 6 - items) * 24,
43+
]
44+
4045
interface TimeChartProps {
4146
timeStats: Record<string, TimeStats>
4247
tickLabel?: (x: number) => string
@@ -60,7 +65,12 @@ export const WorkingHoursChart = ({
6065
const maxY = Math.max(startRange.maxY, endRange.maxY)
6166

6267
return (
63-
<Chart.Root maxX={maxX} minY={minY} maxY={maxY}>
68+
<Chart.Root
69+
maxX={maxX}
70+
minY={minY}
71+
maxY={maxY}
72+
padding={getPadding(startPoints.length)}
73+
>
6474
<Chart.Caption>Working Hours (avg)</Chart.Caption>
6575

6676
<Chart.Line points={startPoints} />
@@ -85,7 +95,12 @@ export const TotalTimeChart = ({
8595
const { maxX, maxY } = getGraphRange(points)
8696

8797
return (
88-
<Chart.Root maxX={maxX} minY={0} maxY={maxY}>
98+
<Chart.Root
99+
maxX={maxX}
100+
minY={0}
101+
maxY={maxY}
102+
padding={getPadding(points.length)}
103+
>
89104
<Chart.Caption>Working Time (avg)</Chart.Caption>
90105
<Chart.Bars points={points} printValue={hourDotLabel} />
91106

0 commit comments

Comments
 (0)