Bar Chart
用于短序列的柱状图,带刻度标签、悬停和聚焦时的提示、方向键导航,以及供屏幕阅读器使用的隐藏数据表。
Angular: 可用 Vue: 可用 React: 可用 React Native: 暂不可用
用法
| Day | Meetings |
|---|---|
| Sep 10 | 0 |
| Sep 11 | 1 |
| Sep 12 | 0 |
| Sep 13 | 2 |
| Sep 14 | 3 |
| Sep 15 | 1 |
| Sep 16 | 0 |
| Sep 17 | 0 |
| Sep 18 | 2 |
| Sep 19 | 4 |
| Sep 20 | 3 |
| Sep 21 | 1 |
| Sep 22 | 0 |
| Sep 23 | 0 |
| Sep 24 | 1 |
| Sep 25 | 2 |
| Sep 26 | 5 |
| Sep 27 | 3 |
| Sep 28 | 2 |
| Sep 29 | 0 |
| Sep 30 | 0 |
| Oct 1 | 1 |
| Oct 2 | 3 |
| Oct 3 | 4 |
| Oct 4 | 2 |
| Oct 5 | 1 |
| Oct 6 | 0 |
| Oct 7 | 0 |
| Oct 8 | 2 |
| Oct 9 | 3 |
<div class="demo-stack" style="padding-top: var(--space-8)">
<sone-bar-chart
[data]="days"
[tick]="tick"
[tooltip]="tooltip"
ariaLabel="Meetings per day, last 30 days"
categoryHeader="Day"
valueHeader="Meetings"
/>
</div>导入
import {
SoneBarChartComponent,
} from "@surface-one/angular/bar-chart";API 参考
SoneBarChartComponent组件
`<sone-bar-chart>` — a column chart for a short series (a day per bar). Bars are HTML boxes, not a stretched SVG: crisp edges and real rounded corners at any width, and hover, focus and tooltip positioning are plain CSS. One Tab stop with a roving focus (Left/Right/Home/End); each bar is an image named by its tooltip, and a visually hidden table carries the data for screen-reader browsing.
| 名称 | 类型 | 默认值 |
|---|---|---|
dataThe bars, left to right (oldest first for a time series). | readonly T[] | [] |
heightThe plot height in CSS pixels (ticks sit below it). | number | 132 |
yMaxThe top of the value axis; defaults to `niceCeiling(values, 4)`. | number | null | undefined | undefined |
tickThe axis label under a bar, or `null` for none; no function, no axis row. | SoneBarChartTick<T> | null | undefined | undefined |
tooltipA bar's tooltip and accessible name; defaults to “label: value”. | SoneBarChartTooltip<T> | null | undefined | undefined |
zeroHow a zero value draws: a flat stub (`baseline`) or nothing (`gap`). | SoneBarChartZero | "baseline" |
toneThe bar colour. | SoneChartTone | "accent" |
ariaLabelNames the chart and captions its data table (“Meetings per day, last 30 days”). | string | "" |
valueFormatFormats values in the default tooltip and the data table. | SoneBarChartFormat | defaultFormat |
categoryHeaderThe data table's category column header. | — | $localize`Category` |
valueHeaderThe data table's value column header. | — | $localize`Value` |