Skip to content

Commit

Permalink
feat: bar category gap (#1002)
Browse files Browse the repository at this point in the history
* add bar category gap prop

* remove default
  • Loading branch information
severinlandolt authored Mar 27, 2024
1 parent 2789f7d commit 76bf497
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/chart-elements/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface BarChartProps extends BaseChartProps {
layout?: "vertical" | "horizontal";
stack?: boolean;
relative?: boolean;
barCategoryGap?: string | number;
}

const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) => {
Expand Down Expand Up @@ -91,6 +92,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
enableLegendSlider = false,
customTooltip,
rotateLabelX,
barCategoryGap,
tickGap = 5,
className,
...other
Expand Down Expand Up @@ -145,6 +147,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
<ResponsiveContainer className="h-full w-full">
{data?.length ? (
<ReChartsBarChart
barCategoryGap={barCategoryGap}
data={data}
stackOffset={stack ? "sign" : relative ? "expand" : "none"}
layout={layout === "vertical" ? "vertical" : "horizontal"}
Expand Down
7 changes: 7 additions & 0 deletions src/stories/chart-elements/BarChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,10 @@ export const tickGap: Story = {
tickGap: 200,
},
};

export const barCategoryGap: Story = {
args: {
data: data,
barCategoryGap: "20%",
},
};

0 comments on commit 76bf497

Please sign in to comment.