Skip to content

Commit 4dcdeff

Browse files
committed
Add isBarChartProp to ChartsClipPath
1 parent c22cdac commit 4dcdeff

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/x-charts/src/BarChart/BarChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const BarChart = React.forwardRef(function BarChart(
148148
<ChartsAxisHighlight {...axisHighlightProps} />
149149
</g>
150150
<ChartsAxis {...chartsAxisProps} />
151-
<ChartsClipPath {...clipPathProps} />
151+
<ChartsClipPath {...clipPathProps} isBarChart />
152152
{children}
153153
</ChartsSurface>
154154
{!props.loading && <Tooltip {...props.slotProps?.tooltip} />}

packages/x-charts/src/ChartsClipPath/ChartsClipPath.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type ChartsClipPathProps = {
1414
* A positive value will move the rectangle outside the drawing area.
1515
*/
1616
offset?: { top?: number; right?: number; bottom?: number; left?: number };
17+
isBarChart?: boolean;
1718
};
1819

1920
/**
@@ -22,10 +23,18 @@ export type ChartsClipPathProps = {
2223
* - [ChartsClipPath API](https://mui.com/x/api/charts/charts-clip-path/)
2324
*/
2425
function ChartsClipPath(props: ChartsClipPathProps) {
25-
const { id, offset: offsetProps } = props;
26+
const { id, offset: offsetProps, isBarChart = false } = props;
2627
const { left, top, width, height } = useDrawingArea();
2728

28-
const offset = { top: 30, right: 30, bottom: 30, left: 30, ...offsetProps };
29+
const adjustedOffset = isBarChart ? 30 : 0;
30+
31+
const offset = {
32+
top: adjustedOffset,
33+
right: adjustedOffset,
34+
bottom: adjustedOffset,
35+
left: adjustedOffset,
36+
...offsetProps,
37+
};
2938

3039
return (
3140
<clipPath id={id}>

0 commit comments

Comments
 (0)