Preview Updated 2026-05-10

BarChart

Single-series vertical bar chart.

Basic usage

Data is passed in via props and rendered as plain SVG — no third-party charting library. Colors come from the --viz-1..8 tokens and are color-blind friendly.

023466891MonTueWedThuFriSatSunMonTue
Demo source
src/App.vue vue
<CfBarChart ... />
src/App.tsx tsx
<CfBarChart ... />

Color

colorIndex 0..7 selects --viz-1..8 directly.

023466891MonTueWedThuFriSatSunMon023466891MonTueWedThuFriSatSunMon023466891MonTueWedThuFriSatSunMon023466891MonTueWedThuFriSatSunMon
Demo source
src/App.vue vue
<CfBarChart :data="data" :color-index="0" />
<CfBarChart :data="data" :color-index="3" />
src/App.tsx tsx
<CfBarChart data={data} colorIndex={0} />
<CfBarChart data={data} colorIndex={3} />

Horizontal layout

Use orientation="horizontal" for rankings, comparisons, or longer category labels.

023466891APIWebDBCacheQueueWorker
Demo source
src/App.vue vue
<CfBarChart :data="data" :labels="labels" orientation="horizontal" />
src/App.tsx tsx
<CfBarChart data={data} labels={labels} orientation="horizontal" />

API

PropTypeDefaultDescription
datanumber[]Bar heights
labelsstring[]x-axis labels
colorIndex0..70
orientation'vertical' | 'horizontal''vertical'Bar direction
width / height / showGrid / showLabels

反馈与讨论

BarChart · Discussion

0
0 / 600
一键发送
正在加载评论...