diff --git a/src/components/chart-elements/AreaChart/AreaChart.tsx b/src/components/chart-elements/AreaChart/AreaChart.tsx index 57426b02..20e9644c 100644 --- a/src/components/chart-elements/AreaChart/AreaChart.tsx +++ b/src/components/chart-elements/AreaChart/AreaChart.tsx @@ -80,11 +80,13 @@ 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 paddingValue = + xAxisPadding ?? ((!showXAxis && !showYAxis) || (startEndOnly && !showYAxis) ? 0 : 20); const [legendHeight, setLegendHeight] = useState(60); const [activeDot, setActiveDot] = useState(undefined); const [activeLegend, setActiveLegend] = useState(undefined); diff --git a/src/components/chart-elements/BarChart/BarChart.tsx b/src/components/chart-elements/BarChart/BarChart.tsx index c87df34b..b7234d25 100644 --- a/src/components/chart-elements/BarChart/BarChart.tsx +++ b/src/components/chart-elements/BarChart/BarChart.tsx @@ -96,12 +96,13 @@ const BarChart = React.forwardRef((props, ref) => barCategoryGap, tickGap = 5, xAxisLabel, + xAxisPadding, yAxisLabel, className, ...other } = props; const CustomTooltip = customTooltip; - const paddingValue = !showXAxis && !showYAxis ? 0 : 20; + const paddingValue = xAxisPadding ?? (!showXAxis && !showYAxis ? 0 : 20); const [legendHeight, setLegendHeight] = useState(60); const categoryColors = constructCategoryColors(categories, colors); const [activeBar, setActiveBar] = React.useState(undefined); diff --git a/src/components/chart-elements/LineChart/LineChart.tsx b/src/components/chart-elements/LineChart/LineChart.tsx index ded14f8d..b0a21b35 100644 --- a/src/components/chart-elements/LineChart/LineChart.tsx +++ b/src/components/chart-elements/LineChart/LineChart.tsx @@ -76,10 +76,11 @@ const LineChart = React.forwardRef((props, ref) tickGap = 5, xAxisLabel, yAxisLabel, + xAxisPadding, ...other } = props; const CustomTooltip = customTooltip; - const paddingValue = !showXAxis && !showYAxis ? 0 : 20; + const paddingValue = xAxisPadding ?? (!showXAxis && !showYAxis ? 0 : 20); const [legendHeight, setLegendHeight] = useState(60); const [activeDot, setActiveDot] = useState(undefined); const [activeLegend, setActiveLegend] = useState(undefined); diff --git a/src/components/chart-elements/common/BaseChartProps.tsx b/src/components/chart-elements/common/BaseChartProps.tsx index a08969f5..a03e7888 100644 --- a/src/components/chart-elements/common/BaseChartProps.tsx +++ b/src/components/chart-elements/common/BaseChartProps.tsx @@ -42,6 +42,7 @@ interface BaseChartProps extends BaseAnimationTimingProps, React.HTMLAttributes< }; tickGap?: number; xAxisLabel?: string; + xAxisPadding?: number; yAxisLabel?: string; } diff --git a/src/stories/chart-elements/AreaChart.stories.tsx b/src/stories/chart-elements/AreaChart.stories.tsx index db57ce06..a13df87d 100644 --- a/src/stories/chart-elements/AreaChart.stories.tsx +++ b/src/stories/chart-elements/AreaChart.stories.tsx @@ -364,3 +364,9 @@ export const AxisLabels: Story = { yAxisLabel: "Amount (USD)", }, }; + +export const xAxisNoPadding: Story = { + args: { + xAxisPadding: 0, + }, +}; diff --git a/src/stories/chart-elements/BarChart.stories.tsx b/src/stories/chart-elements/BarChart.stories.tsx index 664925dc..0b4b11ae 100644 --- a/src/stories/chart-elements/BarChart.stories.tsx +++ b/src/stories/chart-elements/BarChart.stories.tsx @@ -387,3 +387,9 @@ export const AxisLabels: Story = { yAxisLabel: "Amount (USD)", }, }; + +export const xAxisNoPadding: Story = { + args: { + xAxisPadding: 0, + }, +}; diff --git a/src/stories/chart-elements/LineChart.stories.tsx b/src/stories/chart-elements/LineChart.stories.tsx index 11cea258..fb69b3c1 100644 --- a/src/stories/chart-elements/LineChart.stories.tsx +++ b/src/stories/chart-elements/LineChart.stories.tsx @@ -324,3 +324,9 @@ export const AxisLabels: Story = { yAxisLabel: "Amount (USD)", }, }; + +export const xAxisNoPadding: Story = { + args: { + xAxisPadding: 0, + }, +};