diff --git a/src/components/chart-elements/AreaChart/AreaChart.tsx b/src/components/chart-elements/AreaChart/AreaChart.tsx index 57426b02..b863106d 100644 --- a/src/components/chart-elements/AreaChart/AreaChart.tsx +++ b/src/components/chart-elements/AreaChart/AreaChart.tsx @@ -80,11 +80,18 @@ const AreaChart = React.forwardRef((props, ref) rotateLabelX, tickGap = 5, xAxisLabel, + xAxisPadding, yAxisLabel, ...other } = props; const CustomTooltip = customTooltip; - const paddingValue = (!showXAxis && !showYAxis) || (startEndOnly && !showYAxis) ? 0 : 20; + + const defaultPadding: number = + (!showXAxis && !showYAxis) || (startEndOnly && !showYAxis) ? 0 : 20; + const paddingValue: Required = { + left: xAxisPadding?.left ?? defaultPadding, + right: xAxisPadding?.right ?? defaultPadding, + }; const [legendHeight, setLegendHeight] = useState(60); const [activeDot, setActiveDot] = useState(undefined); const [activeLegend, setActiveLegend] = useState(undefined); @@ -174,7 +181,7 @@ const AreaChart = React.forwardRef((props, ref) /> ) : null} ((props, ref) => barCategoryGap, tickGap = 5, xAxisLabel, + xAxisPadding, yAxisLabel, className, ...other } = props; const CustomTooltip = customTooltip; - const paddingValue = !showXAxis && !showYAxis ? 0 : 20; + const defaultPadding: number = !showXAxis && !showYAxis ? 0 : 20; + const paddingValue: Required = { + left: xAxisPadding?.left ?? defaultPadding, + right: xAxisPadding?.right ?? defaultPadding, + }; const [legendHeight, setLegendHeight] = useState(60); const categoryColors = constructCategoryColors(categories, colors); const [activeBar, setActiveBar] = React.useState(undefined); @@ -187,7 +192,7 @@ const BarChart = React.forwardRef((props, ref) => {layout !== "vertical" ? ( ((props, ref) tickGap = 5, xAxisLabel, yAxisLabel, + xAxisPadding, ...other } = props; const CustomTooltip = customTooltip; - const paddingValue = !showXAxis && !showYAxis ? 0 : 20; + const defaultPadding: number = !showXAxis && !showYAxis ? 0 : 20; + const paddingValue: Required = { + left: xAxisPadding?.left ?? defaultPadding, + right: xAxisPadding?.right ?? defaultPadding, + }; const [legendHeight, setLegendHeight] = useState(60); const [activeDot, setActiveDot] = useState(undefined); const [activeLegend, setActiveLegend] = useState(undefined); @@ -170,7 +175,7 @@ const LineChart = React.forwardRef((props, ref) /> ) : null}