Skip to content

Commit 0e79c51

Browse files
add story for stacked histogram
1 parent 62ac69c commit 0e79c51

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/lib/components/barchartv2/Barchart.component.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ describe('Barchart', () => {
319319
<Barchart
320320
type={{ type: 'category' }}
321321
bars={testStackedBars}
322-
stacked={true}
322+
stacked
323323
/>
324324
</ChartLegendWrapper>
325325
</Wrapper>,

stories/BarChart/barchart.stories.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,3 +950,59 @@ export const Histogram: Story = {
950950
);
951951
},
952952
};
953+
954+
export const StackedHistogram: Story = {
955+
render: () => {
956+
const histogramData = [
957+
{
958+
label: 'Test 1',
959+
data: [
960+
['0-10', 1],
961+
['10-20', 5],
962+
['20-30', 15],
963+
['30-40', 40],
964+
['40-50', 45],
965+
['50-60', 50],
966+
['60-70', 40],
967+
['70-80', 15],
968+
['80-90', 5],
969+
['90-100', 1],
970+
],
971+
},
972+
{
973+
label: 'Test 2',
974+
data: [
975+
['0-10', 1],
976+
['10-20', 2],
977+
['20-30', 4],
978+
['30-40', 4],
979+
['40-50', 5],
980+
['50-60', 6],
981+
['60-70', 6],
982+
['70-80', 3],
983+
['80-90', 2],
984+
['90-100', 1],
985+
],
986+
},
987+
] as const;
988+
const theme = useTheme() as CoreUITheme;
989+
return (
990+
<div style={{ width: '50%', padding: spacing.r16 }}>
991+
<ChartLegendWrapper
992+
colorSet={{
993+
'Test 1': theme.statusHealthy,
994+
'Test 2': theme.statusWarning,
995+
}}
996+
>
997+
<Barchart
998+
type={{ type: 'category', gap: 0 }}
999+
bars={histogramData}
1000+
title="Stacked Histogram"
1001+
stacked
1002+
/>
1003+
<ChartLegend shape="rectangle" />
1004+
</ChartLegendWrapper>
1005+
</div>
1006+
);
1007+
},
1008+
};

0 commit comments

Comments
 (0)