@zsherman/charts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +373 -0
- package/README.md +13 -2
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/dom/bar-list/bar-list.js +386 -0
- package/dist/dom/bar-list/bar-list.styles.js +171 -0
- package/dist/dom/bar-list/index.js +1 -0
- package/dist/dom/chart/chart.js +716 -0
- package/dist/dom/chart/chart.styles.js +165 -0
- package/dist/dom/chart/index.js +1 -0
- package/dist/dom/chart-grid/chart-grid.js +67 -0
- package/dist/dom/chart-grid/index.js +1 -0
- package/dist/dom/donut/donut.js +565 -0
- package/dist/dom/donut/donut.styles.js +111 -0
- package/dist/dom/donut/index.js +1 -0
- package/dist/dom/heat-graph/calendar.js +118 -0
- package/dist/dom/heat-graph/heat-graph.js +423 -0
- package/dist/dom/heat-graph/heat-graph.styles.js +168 -0
- package/dist/dom/heat-graph/index.js +1 -0
- package/dist/dom/heat-matrix/heat-matrix.js +346 -0
- package/dist/dom/heat-matrix/heat-matrix.styles.js +155 -0
- package/dist/dom/heat-matrix/index.js +1 -0
- package/dist/dom/heat-matrix/model.js +41 -0
- package/dist/dom/index.js +13 -0
- package/dist/dom/internal/colors.js +44 -0
- package/dist/dom/internal/floating-tip.js +83 -0
- package/dist/dom/internal/format.js +43 -0
- package/dist/dom/internal/grid-context.js +5 -0
- package/dist/dom/internal/hidden.styles.js +16 -0
- package/dist/dom/internal/legend.js +112 -0
- package/dist/dom/internal/legend.styles.js +108 -0
- package/dist/dom/internal/markers.js +101 -0
- package/dist/dom/internal/options.js +300 -0
- package/dist/dom/internal/place.js +27 -0
- package/dist/dom/internal/scheme-watch.js +73 -0
- package/dist/dom/internal/share.js +28 -0
- package/dist/dom/internal/types.js +0 -0
- package/dist/dom/row-chart/index.js +1 -0
- package/dist/dom/row-chart/model.js +59 -0
- package/dist/dom/row-chart/row-chart.js +691 -0
- package/dist/dom/row-chart/row-chart.styles.js +242 -0
- package/dist/dom/segmented-bar/index.js +1 -0
- package/dist/dom/segmented-bar/segmented-bar.js +280 -0
- package/dist/dom/segmented-bar/segmented-bar.styles.js +88 -0
- package/dist/dom/sparkline/index.js +1 -0
- package/dist/dom/sparkline/sparkline.js +145 -0
- package/dist/dom/stacked-histogram/histogram.js +137 -0
- package/dist/dom/stacked-histogram/index.js +1 -0
- package/dist/dom/stacked-histogram/stacked-histogram.js +761 -0
- package/dist/dom/stacked-histogram/stacked-histogram.styles.js +211 -0
- package/dist/dom/state-timeline/index.js +1 -0
- package/dist/dom/state-timeline/model.js +166 -0
- package/dist/dom/state-timeline/state-timeline.js +729 -0
- package/dist/dom/state-timeline/state-timeline.styles.js +171 -0
- package/dist/dom/status-history/index.js +1 -0
- package/dist/dom/status-history/status-history.js +542 -0
- package/dist/dom/status-history/status-history.styles.js +171 -0
- package/dist/solid/bar-list/bar-list.jsx +139 -0
- package/dist/solid/bar-list/bar-list.styles.jsx +171 -0
- package/dist/solid/bar-list/index.jsx +1 -0
- package/dist/solid/chart/chart.jsx +454 -0
- package/dist/solid/chart/chart.styles.jsx +165 -0
- package/dist/solid/chart/index.jsx +1 -0
- package/dist/solid/chart-grid/chart-grid.jsx +46 -0
- package/dist/solid/chart-grid/index.jsx +1 -0
- package/dist/solid/donut/donut.jsx +291 -0
- package/dist/solid/donut/donut.styles.jsx +111 -0
- package/dist/solid/donut/index.jsx +1 -0
- package/dist/solid/heat-graph/calendar.jsx +118 -0
- package/dist/solid/heat-graph/heat-graph.jsx +228 -0
- package/dist/solid/heat-graph/heat-graph.styles.jsx +168 -0
- package/dist/solid/heat-graph/index.jsx +1 -0
- package/dist/solid/heat-matrix/heat-matrix.jsx +165 -0
- package/dist/solid/heat-matrix/heat-matrix.styles.jsx +155 -0
- package/dist/solid/heat-matrix/index.jsx +1 -0
- package/dist/solid/heat-matrix/model.jsx +41 -0
- package/dist/solid/index.jsx +13 -0
- package/dist/solid/internal/colors.jsx +44 -0
- package/dist/solid/internal/floating-tip.jsx +68 -0
- package/dist/solid/internal/format.jsx +43 -0
- package/dist/solid/internal/grid-context.jsx +5 -0
- package/dist/solid/internal/hidden.styles.jsx +16 -0
- package/dist/solid/internal/legend.jsx +35 -0
- package/dist/solid/internal/legend.styles.jsx +108 -0
- package/dist/solid/internal/markers.jsx +101 -0
- package/dist/solid/internal/options.jsx +300 -0
- package/dist/solid/internal/place.jsx +27 -0
- package/dist/solid/internal/scheme-watch.jsx +73 -0
- package/dist/solid/internal/share.jsx +28 -0
- package/dist/solid/internal/types.jsx +0 -0
- package/dist/solid/row-chart/index.jsx +1 -0
- package/dist/solid/row-chart/model.jsx +59 -0
- package/dist/solid/row-chart/row-chart.jsx +312 -0
- package/dist/solid/row-chart/row-chart.styles.jsx +242 -0
- package/dist/solid/segmented-bar/index.jsx +1 -0
- package/dist/solid/segmented-bar/segmented-bar.jsx +125 -0
- package/dist/solid/segmented-bar/segmented-bar.styles.jsx +88 -0
- package/dist/solid/sparkline/index.jsx +1 -0
- package/dist/solid/sparkline/sparkline.jsx +88 -0
- package/dist/solid/stacked-histogram/histogram.jsx +137 -0
- package/dist/solid/stacked-histogram/index.jsx +1 -0
- package/dist/solid/stacked-histogram/stacked-histogram.jsx +381 -0
- package/dist/solid/stacked-histogram/stacked-histogram.styles.jsx +211 -0
- package/dist/solid/state-timeline/index.jsx +1 -0
- package/dist/solid/state-timeline/model.jsx +166 -0
- package/dist/solid/state-timeline/state-timeline.jsx +387 -0
- package/dist/solid/state-timeline/state-timeline.styles.jsx +171 -0
- package/dist/solid/status-history/index.jsx +1 -0
- package/dist/solid/status-history/status-history.jsx +279 -0
- package/dist/solid/status-history/status-history.styles.jsx +171 -0
- package/dist/styles.css +1 -0
- package/dist/types/bar-list/bar-list.d.ts +91 -0
- package/dist/types/bar-list/bar-list.styles.d.ts +148 -0
- package/dist/types/bar-list/index.d.ts +3 -0
- package/dist/types/chart/chart.d.ts +98 -0
- package/dist/types/chart/chart.styles.d.ts +145 -0
- package/dist/types/chart/index.d.ts +3 -0
- package/dist/types/chart-grid/chart-grid.d.ts +35 -0
- package/dist/types/chart-grid/index.d.ts +2 -0
- package/dist/types/donut/donut.d.ts +124 -0
- package/dist/types/donut/donut.styles.d.ts +96 -0
- package/dist/types/donut/index.d.ts +3 -0
- package/dist/types/heat-graph/calendar.d.ts +61 -0
- package/dist/types/heat-graph/heat-graph.d.ts +82 -0
- package/dist/types/heat-graph/heat-graph.styles.d.ts +141 -0
- package/dist/types/heat-graph/index.d.ts +4 -0
- package/dist/types/heat-matrix/heat-matrix.d.ts +65 -0
- package/dist/types/heat-matrix/heat-matrix.styles.d.ts +135 -0
- package/dist/types/heat-matrix/index.d.ts +3 -0
- package/dist/types/heat-matrix/model.d.ts +15 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/internal/colors.d.ts +22 -0
- package/dist/types/internal/floating-tip.d.ts +15 -0
- package/dist/types/internal/format.d.ts +7 -0
- package/dist/types/internal/grid-context.d.ts +9 -0
- package/dist/types/internal/hidden.styles.d.ts +15 -0
- package/dist/types/internal/legend.d.ts +18 -0
- package/dist/types/internal/legend.styles.d.ts +96 -0
- package/dist/types/internal/markers.d.ts +16 -0
- package/dist/types/internal/options.d.ts +59 -0
- package/dist/types/internal/place.d.ts +20 -0
- package/dist/types/internal/scheme-watch.d.ts +12 -0
- package/dist/types/internal/share.d.ts +19 -0
- package/dist/types/internal/types.d.ts +163 -0
- package/dist/types/row-chart/index.d.ts +4 -0
- package/dist/types/row-chart/model.d.ts +50 -0
- package/dist/types/row-chart/row-chart.d.ts +148 -0
- package/dist/types/row-chart/row-chart.styles.d.ts +216 -0
- package/dist/types/segmented-bar/index.d.ts +3 -0
- package/dist/types/segmented-bar/segmented-bar.d.ts +65 -0
- package/dist/types/segmented-bar/segmented-bar.styles.d.ts +75 -0
- package/dist/types/sparkline/index.d.ts +3 -0
- package/dist/types/sparkline/sparkline.d.ts +38 -0
- package/dist/types/stacked-histogram/histogram.d.ts +48 -0
- package/dist/types/stacked-histogram/index.d.ts +4 -0
- package/dist/types/stacked-histogram/stacked-histogram.d.ts +73 -0
- package/dist/types/stacked-histogram/stacked-histogram.styles.d.ts +187 -0
- package/dist/types/state-timeline/index.d.ts +3 -0
- package/dist/types/state-timeline/model.d.ts +63 -0
- package/dist/types/state-timeline/state-timeline.d.ts +108 -0
- package/dist/types/state-timeline/state-timeline.styles.d.ts +151 -0
- package/dist/types/status-history/index.d.ts +3 -0
- package/dist/types/status-history/status-history.d.ts +72 -0
- package/dist/types/status-history/status-history.styles.d.ts +150 -0
- package/docs/api.json +1346 -0
- package/docs/bar-list.md +190 -0
- package/docs/chart-grid.md +77 -0
- package/docs/chart.md +355 -0
- package/docs/donut.md +182 -0
- package/docs/heat-graph.md +121 -0
- package/docs/heat-matrix.md +108 -0
- package/docs/llms.txt +68 -0
- package/docs/row-chart.md +193 -0
- package/docs/search-index.json +291 -0
- package/docs/segmented-bar.md +128 -0
- package/docs/sparkline.md +82 -0
- package/docs/stacked-histogram.md +123 -0
- package/docs/state-timeline.md +141 -0
- package/docs/status-history.md +121 -0
- package/package.json +104 -4
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Row chart
|
|
2
|
+
|
|
3
|
+
<!-- search: row chart, horizontal bar chart, horizontal bars, grouped bars, stacked bars, comparison, baseline vs candidate, before and after, A/B, benchmark, breakdown per row, user vs kernel, delta, change -->
|
|
4
|
+
|
|
5
|
+
Horizontal bars, one row per category. Grouped, each row has a bar per series under one another, to compare them row by row: a baseline and a candidate, with the change written after it. Stacked, each row is one bar split into its series: user and kernel time, parts of each row's whole. Rows carry a label with a note under it, can sit in groups and can be muted, and a tooltip shows the row on hover or with the arrow keys. It's plain DOM, so it renders on the server.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { RowChart } from "@zsherman/charts/row-chart";
|
|
9
|
+
|
|
10
|
+
<RowChart
|
|
11
|
+
label="Participants per vCPU, baseline vs candidate, higher is better"
|
|
12
|
+
series={[
|
|
13
|
+
{ label: "Baseline", note: "3e0ea366fb", tone: "neutral" },
|
|
14
|
+
{ label: "Candidate", note: "perf-ab-r3-r5" },
|
|
15
|
+
]}
|
|
16
|
+
rows={[
|
|
17
|
+
{ label: "Gcore eu-central", note: "g1-cpu-4-4 · 16p", values: [13.3, 20.6], group: "cloud" },
|
|
18
|
+
{ label: "Vultr us-east", note: "voc-c-4c-8gb · 16p", values: [17.3, 22.3], group: "cloud" },
|
|
19
|
+
{ label: "storm Loopback", note: "lo 0.03ms · 32p", values: [68.9, 101.0], group: "metal" },
|
|
20
|
+
]}
|
|
21
|
+
format={(v) => v.toFixed(1)}
|
|
22
|
+
delta
|
|
23
|
+
/>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage guidelines
|
|
27
|
+
|
|
28
|
+
- Use it for a handful of named rows, each with a value per series: benchmarks per host, before and after per region, a cost split per team. Rows with long names and notes read better as rows than as a category axis.
|
|
29
|
+
- `layout="grouped"` (the default) compares series within each row. Put the reference first (a baseline, "before", last month) in `tone: "neutral"`, and turn on `delta` to write the last series' change from it.
|
|
30
|
+
- `layout="stacked"` splits each row into parts of its whole. The bar's length is the row's total; the tooltip gives each part's share.
|
|
31
|
+
- For one measure ranked largest first (top pages, top customers), use a [Bar list](./bar-list.md); for one whole, a [Segmented bar](./segmented-bar.md); for values over time or many categories, a [Chart](./chart.md).
|
|
32
|
+
- Name it with `label`: what is compared, by what, and which way is better ("Participants per vCPU, higher is better").
|
|
33
|
+
- Keep it to a few series (two or three grouped, up to five or six stacked) and a few dozen rows.
|
|
34
|
+
- Values below 0 or missing count as 0 and draw no bar; a missing value is written "–". A value above 0 always shows a sliver.
|
|
35
|
+
|
|
36
|
+
## Anatomy
|
|
37
|
+
|
|
38
|
+
`series` is a list of `RowChartSeries`, and `rows` of `RowChartRow`:
|
|
39
|
+
|
|
40
|
+
| Field | Type | |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `series[].label` | `string` | The series' name in the legend, the tooltip and each row's name. |
|
|
43
|
+
| `series[].note` | `string` | A short note after the name in the legend, in the mono face: a version, a commit. |
|
|
44
|
+
| `series[].color` | `ChartColor` | A chart token (`"chart-3"`) or any CSS color. |
|
|
45
|
+
| `series[].tone` | `ChartTone` | A status tone instead: `"neutral"` (gray) for a baseline. Ignored when `color` is set. |
|
|
46
|
+
| `rows[].label` | `string` | What the row is. Cut short with an ellipsis when long (full text in its `title` and name). |
|
|
47
|
+
| `rows[].note` | `string` | A line under the label: a configuration, a region, a size. |
|
|
48
|
+
| `rows[].values` | `(number \| null)[]` | One value per series, in the series' order. |
|
|
49
|
+
| `rows[].group` | `string` | Rows with the same group sit together; a line separates a group from the next. |
|
|
50
|
+
| `rows[].muted` | `boolean` | Draws the row a step back: bars mixed into the surface, a lighter label. A base build, a "before" row. |
|
|
51
|
+
| `rows[].colors` | `(ChartColor \| undefined)[]` | This row's colors by series, in place of the series' own. |
|
|
52
|
+
| `rows[].key`, `rows[].data` | `string`, `T` | Your own id and data, handed back to `valueText` and the tooltip's `render`. |
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<RowChart
|
|
56
|
+
label="…" // required: the chart's accessible name
|
|
57
|
+
series={[{ label, note, color, tone }]}
|
|
58
|
+
rows={[{ label, note, values, group, muted, colors, key, data }]}
|
|
59
|
+
layout="grouped" // "stacked"
|
|
60
|
+
max={…} // the value a full bar stands for (shared between charts)
|
|
61
|
+
format={(v) => …} // how values are written
|
|
62
|
+
delta // grouped: the last series' change from the first
|
|
63
|
+
valueText={({ row, series, value, text, delta }) => …} // the text after a bar, your way
|
|
64
|
+
legend // the series legend (on for two or more)
|
|
65
|
+
tooltip={true | false | { render }}
|
|
66
|
+
labels={{ total, keyboardHint, legend, empty }}
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Without `color` or `tone`, series take the chart colors in order, counting only the series without either (a neutral baseline doesn't use up `chart-1`).
|
|
71
|
+
|
|
72
|
+
What renders: a root `div` (`data-slot="row-chart"`) with the legend (`row-chart-legend`, a list of `row-chart-legend-item`, notes in `row-chart-legend-note`), the rows (`row-chart-plot`, a `group` named by `label`, focusable with the tooltip, holding a list `row-chart-rows`), each row an `li` (`row-chart-row`, with `data-muted`, `data-group-start` and `data-active`) with its label (`row-chart-label`), note (`row-chart-note`), bars (`row-chart-bars`: each `row-chart-bar`, or a stacked bar's `row-chart-segment`s) and the text after them (`row-chart-value`). The tooltip is `row-chart-tooltip`, a manual popover in the top layer; `row-chart-readout` is the polite live region; `row-chart-empty` replaces the rows when there are none.
|
|
73
|
+
|
|
74
|
+
## Grouped: compare series row by row
|
|
75
|
+
|
|
76
|
+
Each row has a bar per series, one under the other, on one scale for the whole chart. `delta` writes the last series' change from the first after its value, "20.6 (+54.9%)", in the locale's percent; a row whose first value is missing or 0 has no change to write. The last series' text is set in the body color; the others are muted.
|
|
77
|
+
|
|
78
|
+
`rows[].colors` draws a row in its own colors, for a kind of row that shouldn't read as one more of the others (bare metal among cloud hosts):
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
{ label: "storm Loopback", note: "lo 0.03ms · 32p", values: [68.9, 101.0], group: "metal", colors: [undefined, "chart-7"] }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Stacked: parts of each row
|
|
85
|
+
|
|
86
|
+
`layout="stacked"` draws one bar per row, its series side by side with 2px between them. The bar's length is the row's total on one scale for the chart; the text after it is the total. The tooltip lists the total, then each part with its value and share.
|
|
87
|
+
|
|
88
|
+
Mute the rows people compare against (`muted: true`), and pair each with the row it's compared to in a `group`:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
const twoDecimals = new Intl.NumberFormat("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
92
|
+
const percent = new Intl.NumberFormat("en-US", { style: "percent", maximumFractionDigits: 0 });
|
|
93
|
+
|
|
94
|
+
<RowChart
|
|
95
|
+
label="Relay vCPU split, user space vs kernel space, base vs new build"
|
|
96
|
+
layout="stacked"
|
|
97
|
+
series={[
|
|
98
|
+
{ label: "User vCPU", note: "Rust · QUIC · crypto" },
|
|
99
|
+
{ label: "Kernel vCPU", note: "UDP · CNI · sched", color: "chart-4" },
|
|
100
|
+
]}
|
|
101
|
+
rows={[
|
|
102
|
+
{ label: "Gcore Base", note: "Skylake 2.2G · Cilium", values: [0.818, 0.385], group: "gcore", muted: true },
|
|
103
|
+
{ label: "Gcore New", note: "Skylake 2.2G · Cilium", values: [0.472, 0.303], group: "gcore" },
|
|
104
|
+
]}
|
|
105
|
+
format={(v) => twoDecimals.format(v)}
|
|
106
|
+
valueText={(v) => `${v.text} (${percent.format(v.value > 0 ? (v.row.values[1] ?? 0) / v.value : 0)} kernel)`}
|
|
107
|
+
/>;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## The text after the bars
|
|
111
|
+
|
|
112
|
+
`format` writes values (the locale's numbers by default, compact from 10,000: 12.9K). `valueText` replaces the text after each bar (grouped) or each stacked bar, with a `RowChartValue`:
|
|
113
|
+
|
|
114
|
+
| Field | Type | |
|
|
115
|
+
| --- | --- | --- |
|
|
116
|
+
| `row` | `RowChartRow<T>` | The row. |
|
|
117
|
+
| `series` | `number \| null` | The series' index; `null` for a stacked row's total. |
|
|
118
|
+
| `value` | `number` | The value, or the row's total when stacked (missing counts as 0). |
|
|
119
|
+
| `text` | `string` | What the chart would write: the value, with the change when `delta`. |
|
|
120
|
+
| `delta` | `number \| undefined` | With `delta`, on the last series: the change from the first value (0.549 for +54.9%). |
|
|
121
|
+
|
|
122
|
+
The text is also read in each row's name, so write it in words a screen reader can say. The chart keeps room after the longest bar for the longest text, so long texts shorten every bar a little.
|
|
123
|
+
|
|
124
|
+
## Tooltip
|
|
125
|
+
|
|
126
|
+
Hovering a row, or reaching it with the arrow keys, shows its tooltip: the label and note, then each series' value (with the change, grouped; with the total and each share, stacked). It renders in the top layer, so no card or dialog clips it, flipping and sliding to stay on screen. `tooltip={false}` turns it off (and the rows stop taking focus).
|
|
127
|
+
|
|
128
|
+
`tooltip={{ render }}` puts your own content in the box. `render` gets an accessor for the active row's `RowChartPoint`: `row`, `index`, `total`, `totalText` and `series` (each `label`, `value`, `text`, `share` when stacked, and `color`). Read it in your JSX:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { RowChart, type RowChartPoint } from "@zsherman/charts/row-chart";
|
|
132
|
+
import { For } from "solid-js";
|
|
133
|
+
|
|
134
|
+
function Breakdown(props: { point: RowChartPoint }) {
|
|
135
|
+
return (
|
|
136
|
+
<div style={{ display: "grid", gap: "2px" }}>
|
|
137
|
+
<div>{props.point.row.label} ({props.point.row.note})</div>
|
|
138
|
+
<div>Total: {props.point.totalText} vCPU</div>
|
|
139
|
+
<For each={props.point.series}>{(s) => <div>{s.label}: {s.text} vCPU ({s.share})</div>}</For>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
<RowChart label="…" layout="stacked" series={series} rows={rows} tooltip={{ render: (point) => <Breakdown point={point()} /> }} />;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Side by side
|
|
148
|
+
|
|
149
|
+
Two row charts next to each other (capacity, and where the time goes) compare only on their own scales. To compare bar lengths between charts measuring the same thing, give both the same `max`.
|
|
150
|
+
|
|
151
|
+
## Accessibility
|
|
152
|
+
|
|
153
|
+
- The rows are a group named by `label`, holding a list. Each row is named in words: "Gcore eu-central, g1-cpu-4-4 · 16p: Baseline 13.3, Candidate 20.6 (+54.9%)", or stacked "Gcore New, Skylake 2.2G: Total 0.77; User vCPU 0.47 (61%), Kernel vCPU 0.30 (39%)". The visible labels, bars and numbers are hidden from assistive technology so nothing is read twice.
|
|
154
|
+
- With the tooltip, the group is focusable: Up and Down move through the rows (Home and End to the ends, Escape to clear), the tooltip follows, and a polite live region reads the row's name.
|
|
155
|
+
- The legend is a list of the series, named from `label` ("…: series").
|
|
156
|
+
- Long labels and notes are cut short with an ellipsis; the full text stays in the row's name and in a `title`.
|
|
157
|
+
- The bar's length isn't the only cue: every value is written after its bar, and a muted row is also named like the others.
|
|
158
|
+
- In right-to-left text (`dir="rtl"`) labels sit on the right and bars grow leftward.
|
|
159
|
+
|
|
160
|
+
## Words
|
|
161
|
+
|
|
162
|
+
`total`, `keyboardHint`, `legend` and `empty` take `labels`, or app-wide the kit's `LocaleProvider messages={{ rowChart: { … } }}`. Numbers and changes follow `LocaleProvider`'s locale.
|
|
163
|
+
|
|
164
|
+
## Gotchas
|
|
165
|
+
|
|
166
|
+
- `values` follow the series' order; a row with fewer values than series has the rest missing ("–").
|
|
167
|
+
- Negative values count as 0: the chart draws magnitudes from zero, not differences around it. For a change that goes both ways, write it with `delta` or `valueText`.
|
|
168
|
+
- A muted row's bars are mixed into `--sui-surface`; on a page background that differs much from the surface, they read lighter or darker than you might expect.
|
|
169
|
+
|
|
170
|
+
## API reference
|
|
171
|
+
|
|
172
|
+
<!-- generated:props:row-chart (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
|
|
173
|
+
|
|
174
|
+
Generated from the types of `@zsherman/charts/row-chart`. Each part also takes its element's native and ARIA attributes.
|
|
175
|
+
|
|
176
|
+
#### `RowChart`
|
|
177
|
+
|
|
178
|
+
| Prop | Type | Default | Description |
|
|
179
|
+
| --- | --- | --- | --- |
|
|
180
|
+
| `class` | `ClassValue` | | Extra classes on the root. |
|
|
181
|
+
| `delta` | `boolean` | | Grouped: write the last series' change from the first after its value ("20.6 (+54.9%)"), for a baseline and a candidate. |
|
|
182
|
+
| `format` | `((value: number) => string)` | | How values are written. Defaults to the locale's numbers, compact from 10,000 (12.9K). |
|
|
183
|
+
| `label` (required) | `string` | | The chart's name for assistive technology: what is compared, by what ("Participants per vCPU, baseline vs candidate"). |
|
|
184
|
+
| `labels` | `Partial<RowChartLabels>` | | The words, in your wording or language (app-wide: `LocaleProvider messages.rowChart`). |
|
|
185
|
+
| `layout` | `"grouped" \| "stacked"` | `"grouped"` | `grouped`: one bar per series, under one another, to compare them row by row (before and after, A and B). `stacked`: one bar per row split into its series, for parts of a whole (user and kernel time). |
|
|
186
|
+
| `legend` | `boolean` | | The series legend above the rows. Defaults to on for two or more series. |
|
|
187
|
+
| `max` | `number` | | The value a full-length bar stands for. Defaults to the largest bar (grouped) or row total (stacked). Pass the same `max` to charts that sit side by side so their bars compare. |
|
|
188
|
+
| `rows` (required) | `readonly RowChartRow<T>[]` | | The rows, top to bottom, in the order given. |
|
|
189
|
+
| `series` (required) | `readonly RowChartSeries[]` | | The series, in the order of each row's `values`. |
|
|
190
|
+
| `tooltip` | `boolean \| RowChartTooltip<T>` | `true` | The tooltip on a row: each series' value (and share, stacked) and the total. Also driven by the keyboard (arrow keys on the focused chart). |
|
|
191
|
+
| `valueText` | `((value: RowChartValue<T>) => string)` | | The text after each bar (grouped) or each stacked bar, in place of the chart's: add a share, a unit, a note. It's also read in each row's name. |
|
|
192
|
+
|
|
193
|
+
<!-- /generated:props:row-chart -->
|