Components
TimeDistribution
Data visualization component combining donut chart and legend
Overview
TimeDistribution is a high-level data visualization component that combines a DonutChart + legend. With generic types, it can visualize any data structure.
- Generic — Freely define data shape with the
<T>type parameter - Compound — Combines donut chart + legend + title into one
- Interactive — Legend items and chart segments are clickable
- Empty State — Automatically displays empty state when there is no data
Basic Usage
Custom Legend
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
items | T[] | - | Yes | Items to show |
getValue | (item: T) => number | - | Yes | Time of each item |
getFillColor | (item: T) => string | - | Yes | Slice color of each item |
getLabel | (item: T, context: TimeDistributionLegendContext) => ReactNode | - | Yes | Legend text. context has index, value and percentage |
title | ReactNode | - | No | Heading above the chart |
getStrokeColor | (item: T) => string | undefined | - | No | Slice stroke color |
getKey | (item: T, index: number) => string | - | No | React key for each item |
onItemClick | (item: T, index: number) => void | - | No | Makes legend items and slices clickable |
isItemClickable | (item: T, index: number) => boolean | - | No | Limits which items are clickable |
emptyMessage | ReactNode | 'No data available' | No | Shown when items is empty |
chartSize | number | '180' | No | Chart size in px |
chartProps | Omit<DonutChartProps, 'segments' | 'size' | 'onSegmentClick'> | - | No | Passed to the donut chart |
legendMaxWidth | number | '240' | No | Legend width limit in px |
legendDotSize | number | '12' | No | Legend color dot size in px |
renderLegendItem | (params: TimeDistributionRenderItemParams<T>) => ReactNode | - | No | Replaces the default legend item |
className | string | - | No | Extra class |
getLabel context
export type TimeDistributionLegendContext = {
index: number
value: number
percentage: number
}Specification
base
| 상태 | 요소 | 속성 | 값 |
|---|---|---|---|
| enabled | title | typography | $text.bodyStrong |
| enabled | title | color | $color.text.default.default |
| enabled | panel | backgroundColor | $color.background.default.default |
| enabled | panel | borderRadius | $size.radius.200 |
| enabled | panel | paddingX | $size.space.400 |
| enabled | panel | paddingY | $size.space.800 |
| enabled | panel | gap | $size.space.600 |
| enabled | legendLabel | typography | $text.caption |
| enabled | legendLabel | color | $color.text.default.secondary |
| enabled | legendDot | borderRadius | $size.radius.full |
Guidelines
- Items with value ≤ 0 are excluded from the chart but shown as 0% in the legend
- If you only need a simple donut chart, use DonutChart directly
- Use
renderLegendItemto fully customize the legend