fix: Bar charts horizontal margin adjustment error (#26817)

This commit is contained in:
Michael S. Molina
2024-01-29 15:25:16 -05:00
committed by GitHub
parent 8db5d13749
commit 84c48d11d8
4 changed files with 72 additions and 17 deletions

View File

@@ -466,6 +466,7 @@ export function getChartPadding(
orientation: LegendOrientation,
margin?: string | number | null,
padding?: { top?: number; bottom?: number; left?: number; right?: number },
isHorizontal?: boolean,
): {
bottom: number;
left: number;
@@ -486,6 +487,19 @@ export function getChartPadding(
}
const { bottom = 0, left = 0, right = 0, top = 0 } = padding || {};
if (isHorizontal) {
return {
left:
left + (orientation === LegendOrientation.Bottom ? legendMargin : 0),
right:
right + (orientation === LegendOrientation.Right ? legendMargin : 0),
top: top + (orientation === LegendOrientation.Top ? legendMargin : 0),
bottom:
bottom + (orientation === LegendOrientation.Left ? legendMargin : 0),
};
}
return {
left: left + (orientation === LegendOrientation.Left ? legendMargin : 0),
right: right + (orientation === LegendOrientation.Right ? legendMargin : 0),