Skip to Content
文档

条形片段

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

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

用法

¥Usage

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

示例

¥Examples

条形大小

¥Bar Size

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

¥Pass the barSize prop to the BarSegment.Root component to configure the size of the bar.

Ruby

35%

JavaScript

23%

React

17%

HTML

13%

CSS

12%

图例

¥Legend

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

¥Use the BarSegment.Legend component to render the legend. You can pass showPercent and showValue to control the visibility of the percentage and values.

500K
200K
100K
100K

Google

56%

Bing

22%

Direct

11%

Yandex

11%

工具提示

¥Tooltip

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

¥Pass the tooltip prop to the BarSegment.Bar component to show a tooltip when hovering over the bar.

Google

56%

Bing

22%

Direct

11%

Yandex

11%

参考

¥Reference

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

¥To reference a specific value on the chart, use the BarSegment.Reference component.

500K
200K
100K
80K
Target
Google
Bing
Direct
Yandex

Previous

条形列表

Next

圆环图