Skip to content

Commit 036056f

Browse files
committed
fix points clipping
1 parent 858b386 commit 036056f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/components/Charts/LineChart/LineChartContent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const DOT_RADIUS = 6;
2525
/** Extra hover area beyond the dot radius for easier touch targeting */
2626
const DOT_HOVER_EXTRA_RADIUS = 2;
2727

28+
/** Minimum safe padding to avoid clipping labels/points */
29+
const MIN_SAFE_PADDING = DOT_RADIUS + DOT_HOVER_EXTRA_RADIUS;
30+
2831
/** Base domain padding applied to all sides */
2932
const BASE_DOMAIN_PADDING = {top: 16, bottom: 16, left: 0, right: 0};
3033

@@ -103,7 +106,7 @@ function LineChartContent({data, title, titleIcon, isLoading, yAxisUnit, yAxisUn
103106

104107
// Only reduce if both sides have excess space (labels short enough for 0°)
105108
// If canReduce <= 0, labels are too long and hook will use rotation/truncation
106-
const horizontalPadding = canReduce > 0 ? geometricPadding - canReduce : geometricPadding;
109+
const horizontalPadding = Math.max(canReduce > 0 ? geometricPadding - canReduce : geometricPadding, MIN_SAFE_PADDING);
107110

108111
return {...BASE_DOMAIN_PADDING, left: horizontalPadding, right: horizontalPadding};
109112
}, [chartWidth, data, font]);

0 commit comments

Comments
 (0)