Skip to content

Commit 6dbf972

Browse files
committed
chore: add custom classNames to label & count in segmentedBarChart
1 parent 5da33f0 commit 6dbf972

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Common/SegmentedBarChart/SegmentedBarChart.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { SegmentedBarChartProps, Entity } from './types'
33
import { FALLBACK_ENTITY } from './constants'
44
import './styles.scss'
55

6-
const SegmentedBarChart: React.FC<SegmentedBarChartProps> = ({ entities = [FALLBACK_ENTITY], rootClassName }) => {
6+
const SegmentedBarChart: React.FC<SegmentedBarChartProps> = ({
7+
entities = [FALLBACK_ENTITY],
8+
rootClassName,
9+
countClassName,
10+
labelClassName,
11+
}) => {
712
const total = entities.reduce((sum, entity) => entity.value + sum, 0)
813

914
const calcSegmentWidth = (entity: Entity) => {
@@ -19,8 +24,8 @@ const SegmentedBarChart: React.FC<SegmentedBarChartProps> = ({ entities = [FALLB
1924
{entities?.map((entity) => (
2025
<div className="flexbox dc__gap-4 dc__align-items-center">
2126
<div className="dot" style={{ backgroundColor: entity.color, width: '10px', height: '10px' }} />
22-
<span>{entity.value}</span>
23-
<span>{entity.label}</span>
27+
<span className={countClassName}>{entity.value}</span>
28+
<span className={labelClassName}>{entity.label}</span>
2429
</div>
2530
))}
2631
</div>

src/Common/SegmentedBarChart/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ export type Entity = {
77
export interface SegmentedBarChartProps {
88
entities: NonNullable<Entity[]>
99
rootClassName?: string
10+
countClassName?: string
11+
labelClassName?: string
1012
}

0 commit comments

Comments
 (0)