diff --git a/src/components/bar-chart/bar-chart.stories.tsx b/src/components/bar-chart/bar-chart.stories.tsx index 6d576c0e..e52857da 100644 --- a/src/components/bar-chart/bar-chart.stories.tsx +++ b/src/components/bar-chart/bar-chart.stories.tsx @@ -567,3 +567,35 @@ export const AreaChartCard5: Story1 = ( args ) => ( ); AreaChartCard5.storyName = 'Revenue Card With Bar Chart Interactive'; + +export const BarChartCard6: Story = { + args: { + data: chartData, + dataKeys: [ 'desktop' ], + layout: 'horizontal', + showXAxis: true, + showYAxis: false, + showTooltip: true, + tooltipIndicator: 'dot', + showCartesianGrid: true, + tickFormatter: monthFormatter, + yAxisDataKey: 'month', + activeBar: { + fill: '#2563EB', + }, + tooltipProps: { + cursor: { + fill: 'transparent', + }, + }, + }, + render: ( args ) => ( + + ), +}; + +BarChartCard6.storyName = 'Customize hover effect'; diff --git a/src/components/bar-chart/bar-chart.tsx b/src/components/bar-chart/bar-chart.tsx index 2f8010cc..bb749b7b 100644 --- a/src/components/bar-chart/bar-chart.tsx +++ b/src/components/bar-chart/bar-chart.tsx @@ -7,6 +7,7 @@ import { Tooltip, Legend, ResponsiveContainer, + type BarProps, } from 'recharts'; import ChartLegendContent from './chart-legend-content'; import ChartTooltipContent from './chart-tooltip-content'; @@ -82,6 +83,34 @@ interface BarChartProps { /** Border radius of chart bar. */ borderRadius?: number; + + /** + * xAxis related props. + * + * @see https://recharts.org/en-US/api/XAxis + */ + xAxisProps?: Record; + + /** + * yAxis related props. + * + * @see https://recharts.org/en-US/api/YAxis + */ + yAxisProps?: Record; + + /** + * Tooltip related props. + * + * @see https://recharts.org/en-US/api/Tooltip + */ + tooltipProps?: Record; + + /** + * Active bar index. + * + * @see https://recharts.org/en-US/api/Bar#activeBar + */ + activeBar?: BarProps['activeBar']; } const BarChart = ( { @@ -106,6 +135,10 @@ const BarChart = ( { chartWidth = 350, chartHeight = 200, borderRadius = 8, + xAxisProps, + yAxisProps, + tooltipProps, + activeBar, }: BarChartProps ) => { const defaultColors = [ { fill: '#7DD3FC' }, { fill: '#2563EB' } ]; @@ -138,6 +171,7 @@ const BarChart = ( { { layout === 'horizontal' && showXAxis && ( - + } { showTooltip && ( ); } ) }