Skip to content

Commit 0bda257

Browse files
authored
fix: impossible to set a name for the bar in barline chart (#382)
1 parent 64c35c0 commit 0bda257

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/Chart/BarLineChart.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ declare global {
2727

2828
export type BarLineChartBaseProps = {
2929
ybar: number[];
30-
name?: [string, string];
30+
name?: string;
31+
nameBar?: string;
3132
horizontal?: boolean;
3233
stacked?: boolean;
3334
} & Omit<ChartProps, "name"> &

src/Chart/chartWrapper.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ const typeSafeObjectEntries = <T extends Record<PropertyKey, unknown>>(
8282
};
8383

8484
export const stringifyObjectValue = <T extends Record<PropertyKey, unknown>>(obj: T) =>
85-
typeSafeObjectFromEntries(typeSafeObjectEntries(obj).map(([k, v]) => [k, JSON.stringify(v)]));
85+
typeSafeObjectFromEntries(
86+
typeSafeObjectEntries(obj).map(([k, v]) => [
87+
k,
88+
typeof v === "string" ? v : JSON.stringify(v)
89+
])
90+
);
8691

8792
export const chartWrapper = <T extends {}>(ChartComponent: React.FC<T>, idPrefix: string) => {
8893
return memo(

stories/charts/BarLineChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
2525
"ybar": {
2626
"description": "Array of value for the x axis to create the bars"
2727
},
28-
"name": { "description": "Array of name", control: "object" },
28+
"name": { "description": "Name for the line", control: "object" },
29+
"nameBar": { "description": "Name for the bars", control: "object" },
2930
"color": { "description": "Array of color", control: "object" },
3031
"hline": { "description": "Array of horizontal lines to add", control: "object" },
3132
"hlinename": { "description": "Name of the horizontal lines", control: "object" },

0 commit comments

Comments
 (0)