From 5acaddc784152be242c21008a634f92d197ba5c3 Mon Sep 17 00:00:00 2001 From: roshni73 Date: Wed, 5 Jun 2024 12:01:03 +0545 Subject: [PATCH] Fix:use template to write Barchart story,Fix Change in any one value of the bar affects the width of overall barchart --- .../src/stories/BarChart.stories.tsx | 66 +++++++++++++------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/packages/go-ui-storybook/src/stories/BarChart.stories.tsx b/packages/go-ui-storybook/src/stories/BarChart.stories.tsx index b40ed9899..0cda7d565 100644 --- a/packages/go-ui-storybook/src/stories/BarChart.stories.tsx +++ b/packages/go-ui-storybook/src/stories/BarChart.stories.tsx @@ -1,16 +1,35 @@ import { BarChartProps } from '@ifrc-go/ui'; import type { + Args, Meta, StoryObj, } from '@storybook/react'; import BarChart from './BarChart'; +interface Option { + id: number; + label: string; + value: number; +} + +const data: Option[] = [ + { id: 1, label: '2022', value: 10 }, + { id: 2, label: '2023', value: 9 }, + { id: 3, label: '2024', value: 5 }, + { id: 4, label: '2020', value: 2 }, +]; + +const keySelector = (d: Option) => d.id; +const valueSelector = (d: Option) => d.value; +const labelSelector = (d: Option) => d.label; + +const maxValue = Math.max(...data.map(valueSelector)); type BarChartSpecificProps = BarChartProps