Skip to content

Commit e60742e

Browse files
committed
feat: Charts allowDecimals
1 parent 45f7bec commit e60742e

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

src/components/chart-elements/AreaChart/AreaChart.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
4949
minValue,
5050
maxValue,
5151
connectNulls = false,
52+
allowDecimals = true,
5253
className,
5354
...other
5455
} = props;
@@ -93,6 +94,7 @@ const AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>((props, ref)
9394
fontFamily: "Inter; Helvetica",
9495
}}
9596
tickFormatter={valueFormatter}
97+
allowDecimals={allowDecimals}
9698
/>
9799
{showTooltip ? (
98100
<Tooltip

src/components/chart-elements/BarChart/BarChart.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
4848
autoMinValue = false,
4949
minValue,
5050
maxValue,
51+
allowDecimals = true,
5152
className,
5253
...other
5354
} = props;
@@ -102,6 +103,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
102103
tickFormatter={valueFormatter}
103104
padding={{ left: 10, right: 10 }}
104105
minTickGap={5}
106+
allowDecimals={allowDecimals}
105107
/>
106108
)}
107109
{layout !== "vertical" ? (
@@ -120,6 +122,7 @@ const BarChart = React.forwardRef<HTMLDivElement, BarChartProps>((props, ref) =>
120122
tickFormatter={
121123
relative ? (value: number) => `${(value * 100).toString()} %` : valueFormatter
122124
}
125+
allowDecimals={allowDecimals}
123126
/>
124127
) : (
125128
<YAxis

src/components/chart-elements/LineChart/LineChart.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
4646
minValue,
4747
maxValue,
4848
connectNulls = false,
49+
allowDecimals = true,
4950
className,
5051
...other
5152
} = props;
@@ -89,6 +90,7 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((props, ref)
8990
fontFamily: "Inter; Helvetica",
9091
}}
9192
tickFormatter={valueFormatter}
93+
allowDecimals={allowDecimals}
9294
/>
9395
{showTooltip ? (
9496
<Tooltip

src/components/chart-elements/common/BaseChartProps.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface BaseChartProps extends React.HTMLAttributes<HTMLDivElement> {
1818
autoMinValue?: boolean;
1919
minValue?: number;
2020
maxValue?: number;
21+
allowDecimals?: boolean;
2122
}
2223

2324
export default BaseChartProps;

src/stories/chart-elements/AreaChart.stories.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,20 @@ const DefaultTemplate: ComponentStory<typeof AreaChart> = ({ ...args }) => (
3737
export const DefaultResponsive = ResponsiveTemplate.bind({});
3838
// More on args: https://storybook.js.org/docs/react/writing-stories/args
3939
DefaultResponsive.args = {
40-
data: data,
40+
data: [
41+
{
42+
month: "Jan 21'",
43+
Sales: 3,
44+
},
45+
{
46+
month: "Feb 21'",
47+
Sales: 1,
48+
},
49+
{
50+
month: "Mar 21'",
51+
Sales: 2,
52+
},
53+
],
4154
categories: ["Sales", "Successful Payments"],
4255
index: "month",
4356
};

0 commit comments

Comments
 (0)