Skip to content

Commit 862069e

Browse files
committed
fix label cut off / prettier
1 parent 036056f commit 862069e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/components/Charts/LineChart/LineChartContent.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ function LineChartContent({data, title, titleIcon, isLoading, yAxisUnit, yAxisUn
106106

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

111-
return {...BASE_DOMAIN_PADDING, left: horizontalPadding, right: horizontalPadding};
112+
// if extraPadding is true then we have to add the extra padding to the right so the label is not clipped
113+
return {...BASE_DOMAIN_PADDING, left: horizontalPadding, right: horizontalPadding + (extraPadding ? MIN_SAFE_PADDING : 0)};
112114
}, [chartWidth, data, font]);
113115

114116
// For centered labels, tick spacing is evenly distributed across the plot area (same as BarChart)

0 commit comments

Comments
 (0)