File size: 1,258 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
---
title: Bar Segment
description:
Used to display data as segments within a horizontal bar, showing proportions
and part-to-whole relationships between values
links:
storybook: charts-bar-segment--basic
---
<ExampleTabs name="charts/bar-segment-basic" />
## Usage
```tsx
import { BarSegment, Chart, useChart } from "@chakra-ui/charts"
```
```tsx
<BarSegment.Root>
<BarSegment.Content>
<BarSegment.Value />
<BarSegment.Bar />
<BarSegment.Label />
</BarSegment.Content>
</BarSegment.Root>
```
## Examples
### Bar Size
Pass the `barSize` prop to the `BarSegment.Root` component to configure the size
of the bar.
<ExampleTabs name="charts/bar-segment-with-bar-size" />
### Legend
Use the `BarSegment.Legend` component to render the legend. You can pass
`showPercent` and `showValue` to control the visibility of the percentage and
values.
<ExampleTabs name="charts/bar-segment-with-legend" />
### Tooltip
Pass the `tooltip` prop to the `BarSegment.Bar` component to show a tooltip when
hovering over the bar.
<ExampleTabs name="charts/bar-segment-with-tooltip" />
### Reference
To reference a specific value on the chart, use the `BarSegment.Reference`
component.
<ExampleTabs name="charts/bar-segment-with-reference" />
|