使用高级 Chakra UI 组件更快构建 💎

了解更多
跳到内容
文档演练场指南博客
赞助商

条形分段

用于将数据显示为水平条内的分段,展示值之间的比例和部分与整体关系

Storybook
500K
200K
100K
100K
Google
Bing
Direct
Yandex

用法

import { BarSegment, Chart, useChart } from "@chakra-ui/charts"
<BarSegment.Root>
  <BarSegment.Content>
    <BarSegment.Value />
    <BarSegment.Bar />
    <BarSegment.Label />
  </BarSegment.Content>
</BarSegment.Root>

示例

条形大小

barSize 属性传递给 BarSegment.Root 组件以配置条形的大小。

Ruby

35%

JavaScript

23%

React

17%

HTML

13%

CSS

12%

图例

使用 BarSegment.Legend 组件渲染图例。您可以传递 showPercentshowValue 来控制百分比和值的可见性。

500K
200K
100K
100K

Google

56%

Bing

22%

Direct

11%

Yandex

11%

工具提示

tooltip 属性传递给 BarSegment.Bar 组件,以便在鼠标悬停在条形上时显示工具提示。

Google

56%

Bing

22%

Direct

11%

Yandex

11%

参考

要在图表上引用特定值,请使用 BarSegment.Reference 组件。

500K
200K
100K
80K
目标
Google
Bing
Direct
Yandex

上一页

条形列表

下一页

圆环图