Skip to content

Commit 740f0ef

Browse files
committed
fix(charts): undesired space between axis label and bottom positioned legend
1 parent 4dc74af commit 740f0ef

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/react-charts/src/components/Chart/Chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ export const Chart: React.FunctionComponent<ChartProps> = ({
571571

572572
// Adjust for axis label
573573
React.Children.toArray(children).map((child: any) => {
574-
if (child.type.role === 'axis' && child.props.label && !child.props.dependentAxis) {
574+
if (child.type.role === 'axis' && child.props.label && child.props.fixAxisLabelHeight) {
575575
xAxisLabelHeight = getLabelTextSize({ text: child.props.label, theme }).height + 10;
576576
legendTitleHeight = 0;
577577
}

packages/react-charts/src/components/ChartAxis/ChartAxis.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ export interface ChartAxisProps extends VictoryAxisProps {
157157
* @propType object[]
158158
*/
159159
externalEventMutations?: EventCallbackInterface<string | string[], StringOrNumberOrList>[];
160+
/**
161+
* When true, this prop adjusts the height between the axis label and bottom positioned legend
162+
*/
163+
fixAxisLabelHeight?: boolean;
160164
/**
161165
* When true, this prop reduces the number of tick labels to fit the length of the axis.
162166
* Labels are removed at approximately even intervals from the original array of labels.

0 commit comments

Comments
 (0)