@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.
Files changed (180) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +373 -0
  3. package/README.md +13 -2
  4. package/THIRD_PARTY_NOTICES.md +33 -0
  5. package/dist/dom/bar-list/bar-list.js +386 -0
  6. package/dist/dom/bar-list/bar-list.styles.js +171 -0
  7. package/dist/dom/bar-list/index.js +1 -0
  8. package/dist/dom/chart/chart.js +716 -0
  9. package/dist/dom/chart/chart.styles.js +165 -0
  10. package/dist/dom/chart/index.js +1 -0
  11. package/dist/dom/chart-grid/chart-grid.js +67 -0
  12. package/dist/dom/chart-grid/index.js +1 -0
  13. package/dist/dom/donut/donut.js +565 -0
  14. package/dist/dom/donut/donut.styles.js +111 -0
  15. package/dist/dom/donut/index.js +1 -0
  16. package/dist/dom/heat-graph/calendar.js +118 -0
  17. package/dist/dom/heat-graph/heat-graph.js +423 -0
  18. package/dist/dom/heat-graph/heat-graph.styles.js +168 -0
  19. package/dist/dom/heat-graph/index.js +1 -0
  20. package/dist/dom/heat-matrix/heat-matrix.js +346 -0
  21. package/dist/dom/heat-matrix/heat-matrix.styles.js +155 -0
  22. package/dist/dom/heat-matrix/index.js +1 -0
  23. package/dist/dom/heat-matrix/model.js +41 -0
  24. package/dist/dom/index.js +13 -0
  25. package/dist/dom/internal/colors.js +44 -0
  26. package/dist/dom/internal/floating-tip.js +83 -0
  27. package/dist/dom/internal/format.js +43 -0
  28. package/dist/dom/internal/grid-context.js +5 -0
  29. package/dist/dom/internal/hidden.styles.js +16 -0
  30. package/dist/dom/internal/legend.js +112 -0
  31. package/dist/dom/internal/legend.styles.js +108 -0
  32. package/dist/dom/internal/markers.js +101 -0
  33. package/dist/dom/internal/options.js +300 -0
  34. package/dist/dom/internal/place.js +27 -0
  35. package/dist/dom/internal/scheme-watch.js +73 -0
  36. package/dist/dom/internal/share.js +28 -0
  37. package/dist/dom/internal/types.js +0 -0
  38. package/dist/dom/row-chart/index.js +1 -0
  39. package/dist/dom/row-chart/model.js +59 -0
  40. package/dist/dom/row-chart/row-chart.js +691 -0
  41. package/dist/dom/row-chart/row-chart.styles.js +242 -0
  42. package/dist/dom/segmented-bar/index.js +1 -0
  43. package/dist/dom/segmented-bar/segmented-bar.js +280 -0
  44. package/dist/dom/segmented-bar/segmented-bar.styles.js +88 -0
  45. package/dist/dom/sparkline/index.js +1 -0
  46. package/dist/dom/sparkline/sparkline.js +145 -0
  47. package/dist/dom/stacked-histogram/histogram.js +137 -0
  48. package/dist/dom/stacked-histogram/index.js +1 -0
  49. package/dist/dom/stacked-histogram/stacked-histogram.js +761 -0
  50. package/dist/dom/stacked-histogram/stacked-histogram.styles.js +211 -0
  51. package/dist/dom/state-timeline/index.js +1 -0
  52. package/dist/dom/state-timeline/model.js +166 -0
  53. package/dist/dom/state-timeline/state-timeline.js +729 -0
  54. package/dist/dom/state-timeline/state-timeline.styles.js +171 -0
  55. package/dist/dom/status-history/index.js +1 -0
  56. package/dist/dom/status-history/status-history.js +542 -0
  57. package/dist/dom/status-history/status-history.styles.js +171 -0
  58. package/dist/solid/bar-list/bar-list.jsx +139 -0
  59. package/dist/solid/bar-list/bar-list.styles.jsx +171 -0
  60. package/dist/solid/bar-list/index.jsx +1 -0
  61. package/dist/solid/chart/chart.jsx +454 -0
  62. package/dist/solid/chart/chart.styles.jsx +165 -0
  63. package/dist/solid/chart/index.jsx +1 -0
  64. package/dist/solid/chart-grid/chart-grid.jsx +46 -0
  65. package/dist/solid/chart-grid/index.jsx +1 -0
  66. package/dist/solid/donut/donut.jsx +291 -0
  67. package/dist/solid/donut/donut.styles.jsx +111 -0
  68. package/dist/solid/donut/index.jsx +1 -0
  69. package/dist/solid/heat-graph/calendar.jsx +118 -0
  70. package/dist/solid/heat-graph/heat-graph.jsx +228 -0
  71. package/dist/solid/heat-graph/heat-graph.styles.jsx +168 -0
  72. package/dist/solid/heat-graph/index.jsx +1 -0
  73. package/dist/solid/heat-matrix/heat-matrix.jsx +165 -0
  74. package/dist/solid/heat-matrix/heat-matrix.styles.jsx +155 -0
  75. package/dist/solid/heat-matrix/index.jsx +1 -0
  76. package/dist/solid/heat-matrix/model.jsx +41 -0
  77. package/dist/solid/index.jsx +13 -0
  78. package/dist/solid/internal/colors.jsx +44 -0
  79. package/dist/solid/internal/floating-tip.jsx +68 -0
  80. package/dist/solid/internal/format.jsx +43 -0
  81. package/dist/solid/internal/grid-context.jsx +5 -0
  82. package/dist/solid/internal/hidden.styles.jsx +16 -0
  83. package/dist/solid/internal/legend.jsx +35 -0
  84. package/dist/solid/internal/legend.styles.jsx +108 -0
  85. package/dist/solid/internal/markers.jsx +101 -0
  86. package/dist/solid/internal/options.jsx +300 -0
  87. package/dist/solid/internal/place.jsx +27 -0
  88. package/dist/solid/internal/scheme-watch.jsx +73 -0
  89. package/dist/solid/internal/share.jsx +28 -0
  90. package/dist/solid/internal/types.jsx +0 -0
  91. package/dist/solid/row-chart/index.jsx +1 -0
  92. package/dist/solid/row-chart/model.jsx +59 -0
  93. package/dist/solid/row-chart/row-chart.jsx +312 -0
  94. package/dist/solid/row-chart/row-chart.styles.jsx +242 -0
  95. package/dist/solid/segmented-bar/index.jsx +1 -0
  96. package/dist/solid/segmented-bar/segmented-bar.jsx +125 -0
  97. package/dist/solid/segmented-bar/segmented-bar.styles.jsx +88 -0
  98. package/dist/solid/sparkline/index.jsx +1 -0
  99. package/dist/solid/sparkline/sparkline.jsx +88 -0
  100. package/dist/solid/stacked-histogram/histogram.jsx +137 -0
  101. package/dist/solid/stacked-histogram/index.jsx +1 -0
  102. package/dist/solid/stacked-histogram/stacked-histogram.jsx +381 -0
  103. package/dist/solid/stacked-histogram/stacked-histogram.styles.jsx +211 -0
  104. package/dist/solid/state-timeline/index.jsx +1 -0
  105. package/dist/solid/state-timeline/model.jsx +166 -0
  106. package/dist/solid/state-timeline/state-timeline.jsx +387 -0
  107. package/dist/solid/state-timeline/state-timeline.styles.jsx +171 -0
  108. package/dist/solid/status-history/index.jsx +1 -0
  109. package/dist/solid/status-history/status-history.jsx +279 -0
  110. package/dist/solid/status-history/status-history.styles.jsx +171 -0
  111. package/dist/styles.css +1 -0
  112. package/dist/types/bar-list/bar-list.d.ts +91 -0
  113. package/dist/types/bar-list/bar-list.styles.d.ts +148 -0
  114. package/dist/types/bar-list/index.d.ts +3 -0
  115. package/dist/types/chart/chart.d.ts +98 -0
  116. package/dist/types/chart/chart.styles.d.ts +145 -0
  117. package/dist/types/chart/index.d.ts +3 -0
  118. package/dist/types/chart-grid/chart-grid.d.ts +35 -0
  119. package/dist/types/chart-grid/index.d.ts +2 -0
  120. package/dist/types/donut/donut.d.ts +124 -0
  121. package/dist/types/donut/donut.styles.d.ts +96 -0
  122. package/dist/types/donut/index.d.ts +3 -0
  123. package/dist/types/heat-graph/calendar.d.ts +61 -0
  124. package/dist/types/heat-graph/heat-graph.d.ts +82 -0
  125. package/dist/types/heat-graph/heat-graph.styles.d.ts +141 -0
  126. package/dist/types/heat-graph/index.d.ts +4 -0
  127. package/dist/types/heat-matrix/heat-matrix.d.ts +65 -0
  128. package/dist/types/heat-matrix/heat-matrix.styles.d.ts +135 -0
  129. package/dist/types/heat-matrix/index.d.ts +3 -0
  130. package/dist/types/heat-matrix/model.d.ts +15 -0
  131. package/dist/types/index.d.ts +12 -0
  132. package/dist/types/internal/colors.d.ts +22 -0
  133. package/dist/types/internal/floating-tip.d.ts +15 -0
  134. package/dist/types/internal/format.d.ts +7 -0
  135. package/dist/types/internal/grid-context.d.ts +9 -0
  136. package/dist/types/internal/hidden.styles.d.ts +15 -0
  137. package/dist/types/internal/legend.d.ts +18 -0
  138. package/dist/types/internal/legend.styles.d.ts +96 -0
  139. package/dist/types/internal/markers.d.ts +16 -0
  140. package/dist/types/internal/options.d.ts +59 -0
  141. package/dist/types/internal/place.d.ts +20 -0
  142. package/dist/types/internal/scheme-watch.d.ts +12 -0
  143. package/dist/types/internal/share.d.ts +19 -0
  144. package/dist/types/internal/types.d.ts +163 -0
  145. package/dist/types/row-chart/index.d.ts +4 -0
  146. package/dist/types/row-chart/model.d.ts +50 -0
  147. package/dist/types/row-chart/row-chart.d.ts +148 -0
  148. package/dist/types/row-chart/row-chart.styles.d.ts +216 -0
  149. package/dist/types/segmented-bar/index.d.ts +3 -0
  150. package/dist/types/segmented-bar/segmented-bar.d.ts +65 -0
  151. package/dist/types/segmented-bar/segmented-bar.styles.d.ts +75 -0
  152. package/dist/types/sparkline/index.d.ts +3 -0
  153. package/dist/types/sparkline/sparkline.d.ts +38 -0
  154. package/dist/types/stacked-histogram/histogram.d.ts +48 -0
  155. package/dist/types/stacked-histogram/index.d.ts +4 -0
  156. package/dist/types/stacked-histogram/stacked-histogram.d.ts +73 -0
  157. package/dist/types/stacked-histogram/stacked-histogram.styles.d.ts +187 -0
  158. package/dist/types/state-timeline/index.d.ts +3 -0
  159. package/dist/types/state-timeline/model.d.ts +63 -0
  160. package/dist/types/state-timeline/state-timeline.d.ts +108 -0
  161. package/dist/types/state-timeline/state-timeline.styles.d.ts +151 -0
  162. package/dist/types/status-history/index.d.ts +3 -0
  163. package/dist/types/status-history/status-history.d.ts +72 -0
  164. package/dist/types/status-history/status-history.styles.d.ts +150 -0
  165. package/docs/api.json +1346 -0
  166. package/docs/bar-list.md +190 -0
  167. package/docs/chart-grid.md +77 -0
  168. package/docs/chart.md +355 -0
  169. package/docs/donut.md +182 -0
  170. package/docs/heat-graph.md +121 -0
  171. package/docs/heat-matrix.md +108 -0
  172. package/docs/llms.txt +68 -0
  173. package/docs/row-chart.md +193 -0
  174. package/docs/search-index.json +291 -0
  175. package/docs/segmented-bar.md +128 -0
  176. package/docs/sparkline.md +82 -0
  177. package/docs/stacked-histogram.md +123 -0
  178. package/docs/state-timeline.md +141 -0
  179. package/docs/status-history.md +121 -0
  180. package/package.json +104 -4
@@ -0,0 +1,190 @@
1
+ # Bar list
2
+
3
+ <!-- search: bar list, top pages, top customers, ranking, leaderboard, horizontal bars, referrers, top countries, breakdown -->
4
+
5
+ Ranked horizontal bars: top pages, top referrers, top customers. Each bar is scaled to the largest value, its label sits on the bar, and the value is at the end of the row, with an optional share of the total. Rows can be links or filter buttons. It's plain DOM, so it renders on the server.
6
+
7
+ ```tsx
8
+ import { BarList } from "@zsherman/charts/bar-list";
9
+
10
+ <BarList
11
+ label="Top pages by visitors, last 7 days"
12
+ data={[
13
+ { label: "/", value: 18_420 },
14
+ { label: "/pricing", value: 7_310 },
15
+ { label: "/docs/getting-started", value: 5_904 },
16
+ ]}
17
+ labelHeader="Page"
18
+ valueHeader="Visitors"
19
+ share
20
+ />;
21
+ ```
22
+
23
+ ## Usage guidelines
24
+
25
+ - Use it to rank categories by one measure, when the question is "which ones, and by how much": pages, sources, countries, customers. For change over time use a [Chart](./chart.md); for parts of one whole, a [Segmented bar](./segmented-bar.md) or a [Donut](./donut.md); for several series per row (before and after, a split per row), a [Row chart](./row-chart.md).
26
+ - Name it with `label`: what is ranked, by what, over which period ("Top pages by visitors, last 7 days"). It's the list's accessible name.
27
+ - Rows are ranked largest first. Keep your own order with `sort="none"` (a fixed list of plans), or `sort="ascending"` for "slowest first" style lists where smaller is the story.
28
+ - Show a handful of rows (`limit={5}`) and put the rest behind Show more. Use `share` when the proportion matters more than the count.
29
+ - Values below 0 or missing count as 0. A value above 0 always shows a sliver of bar, so it never reads as zero.
30
+
31
+ ## Anatomy
32
+
33
+ Each row is a `BarListItem`:
34
+
35
+ | Field | Type | |
36
+ | --- | --- | --- |
37
+ | `label` | `string` | What is ranked. Cut short on its bar when long; the full text is in the row's name and `title`. |
38
+ | `value` | `number \| null` | Its amount. Missing or negative counts as 0. |
39
+ | `href` | `string` | Makes the row a link. |
40
+ | `icon` | `JSX.Element` | An icon before the label (`<Icon icon={Globe} />`), decorative. |
41
+ | `key` | `string` | Identifies the row for `selected` when labels repeat. Defaults to `label`. |
42
+ | `data` | `T` | Your own data, handed back to `onSelect`. |
43
+
44
+ ```tsx
45
+ <BarList
46
+ label="…" // required: the list's accessible name
47
+ data={[{ label, value, href, icon, key, data }]}
48
+ sort="descending" // "ascending" | "none"
49
+ limit={5} // the rest behind Show more
50
+ onShowMore={() => …} // Show more opens your own view; without it, the list expands in place
51
+ share // a column of each row's share of the total
52
+ max={…} total={…} // the whole list's, when data is part of it
53
+ labelHeader="Page" valueHeader="Visitors" // column headers
54
+ shareHeader="Share" // over the share column, with `share`
55
+ format={(v) => …} // how values are written
56
+ color="chart-1" // the bars' wash
57
+ onSelect={(item, index) => …} // rows become buttons
58
+ selected="Direct" // the pressed row (its key, or label); null for none
59
+ labels={{ showMore, showLess, empty }}
60
+ />
61
+ ```
62
+
63
+ What renders: a root `div` (`data-slot="bar-list"`) holding the headers (`bar-list-header`, hidden from assistive technology), a `ul` (`bar-list-list`, named by `label`) of `li` rows (`bar-list-item`). Each row holds a link (`href`), a button (`onSelect`) or a plain `div`, with the bar (`bar-list-bar`, its fill `bar-list-fill` and label `bar-list-label`), the value (`bar-list-value`) and the share (`bar-list-share`). Show more is a kit `Button` (`bar-list-more`). With no rows the named list stays (empty) and a paragraph after it (`bar-list-empty`) says why.
64
+
65
+ ## Show more
66
+
67
+ `limit` shows the first rows. Without `onShowMore`, Show more expands the list in place (`aria-expanded`, `aria-controls` the list), and while it's collapsed the last rows fade out. With `onShowMore`, the button calls you instead: open every row in a dialog, with search if the list is long.
68
+
69
+ ```tsx
70
+ import { BarList } from "@zsherman/charts/bar-list";
71
+ import { Dialog, DialogBody, DialogContent, DialogHeader, DialogTitle } from "@zsherman/kit/dialog";
72
+ import { createSignal } from "solid-js";
73
+
74
+ const [open, setOpen] = createSignal(false);
75
+
76
+ <>
77
+ <BarList label="Top pages by visitors, last 7 days" data={pages} limit={4} onShowMore={() => setOpen(true)} />
78
+ <Dialog open={open()} onOpenChange={(next) => setOpen(next)}>
79
+ <DialogContent size="sm">
80
+ <DialogHeader>
81
+ <DialogTitle>All pages</DialogTitle>
82
+ </DialogHeader>
83
+ <DialogBody>
84
+ <BarList label="All pages by visitors, last 7 days" data={pages} share />
85
+ </DialogBody>
86
+ </DialogContent>
87
+ </Dialog>
88
+ </>;
89
+ ```
90
+
91
+ ### Part of a larger list
92
+
93
+ A list that shows part of a larger one (the results of a search in that dialog, a page of rows) would rescale to what's left: the only match would fill its bar and read as 100%. Pass the whole list's largest value as `max` and its total as `total`, and each row keeps its length and share as the others are filtered out.
94
+
95
+ ```tsx
96
+ const all = () => pages; // every row
97
+ const found = () => pages.filter((p) => p.label.includes(query()));
98
+
99
+ <BarList
100
+ label="Pages matching the search"
101
+ data={found()}
102
+ max={Math.max(...all().map((p) => p.value ?? 0))}
103
+ total={all().reduce((sum, p) => sum + (p.value ?? 0), 0)}
104
+ share
105
+ />;
106
+ ```
107
+
108
+ ## Links and filters
109
+
110
+ A row with `href` is a link: open that page, customer or campaign. With `onSelect`, rows without `href` are buttons, for filtering the rest of the page by one category; every row is a toggle button (`aria-pressed`). Pass `selected` (the row's `key`, or its label) so the chosen row is pressed and its bar darker; `null` or nothing means none is chosen. Without either, rows are plain list items.
111
+
112
+ ```tsx
113
+ import { BarList } from "@zsherman/charts/bar-list";
114
+ import { Icon } from "@zsherman/kit/icon";
115
+ import { Link, Search } from "@zsherman/kit/icons";
116
+ import { createSignal } from "solid-js";
117
+
118
+ const [source, setSource] = createSignal<string>();
119
+
120
+ <BarList
121
+ label="Visits by referrer, last 7 days"
122
+ data={[
123
+ { label: "Search engines", value: 9_840, icon: <Icon icon={Search} /> },
124
+ { label: "Direct", value: 6_120, icon: <Icon icon={Link} /> },
125
+ ]}
126
+ selected={source()}
127
+ onSelect={(item) => setSource((current) => (current === item.label ? undefined : item.label))}
128
+ />;
129
+ ```
130
+
131
+ `icon` is an element: create it where the list renders (in the component), not in a module-level constant, so each list gets its own.
132
+
133
+ ## Formats
134
+
135
+ Values follow the kit's locale (`LocaleProvider`), full below 10,000 and compact above (12.9K), the same as Chart's axes. Pass `format` for units or currency. Shares have one decimal under 10% ("4.2%"), none above ("42%"), and "<0.1%" for a sliver.
136
+
137
+ ```tsx
138
+ const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", notation: "compact" });
139
+
140
+ <BarList label="Top customers by annual revenue" data={customers} format={(v) => usd.format(v)} />;
141
+ ```
142
+
143
+ ## Accessibility
144
+
145
+ - The rows are a list named by `label`. Each row is named "Label, value, share" ("/pricing, 7.3K, 16%"), whether it's a link, a button or a plain item; the visible bar and numbers are hidden from assistive technology so nothing is read twice.
146
+ - Long labels are cut short on their bar with an ellipsis; the full text stays in the row's name and in a `title` on the label.
147
+ - Links and buttons are ordinary tab stops; buttons are toggles, pressed when their row is `selected`.
148
+ - An empty list keeps its name: it's read as an empty list, then the `empty` text.
149
+ - In right-to-left text (`dir="rtl"`) the bars grow from the right and the values sit at the left end.
150
+ - The bar's length isn't the only cue: the value is always written at the end of the row.
151
+
152
+ ## Words
153
+
154
+ `showMore`, `showLess` and `empty` take `labels`, or app-wide the kit's `LocaleProvider messages={{ barList: { … } }}`.
155
+
156
+ ## Gotchas
157
+
158
+ - The bars are a light wash of `color`, so the label on them stays legible: don't pass a dark color expecting a solid bar.
159
+ - Shares are of every row, not only those shown, so the visible shares can add up to less than 100%.
160
+ - `key` identifies a row for `selected` when two rows share a label.
161
+
162
+ ## API reference
163
+
164
+ <!-- generated:props:bar-list (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
165
+
166
+ Generated from the types of `@zsherman/charts/bar-list`. Each part also takes its element's native and ARIA attributes.
167
+
168
+ #### `BarList`
169
+
170
+ | Prop | Type | Default | Description |
171
+ | --- | --- | --- | --- |
172
+ | `class` | `ClassValue` | | Extra classes on the root. |
173
+ | `color` | `ChartColor` | `"chart-1"` | The bars' color: a chart token (`chart-1` … `chart-8`) or any CSS color, drawn as a light wash so the label on it stays legible. |
174
+ | `data` (required) | `readonly BarListItem<T>[]` | | The rows. They're ranked by value unless `sort` says otherwise. |
175
+ | `format` | `((value: number) => string)` | | How values are written. Defaults to the locale's numbers, compact from 10,000 (12.9K), as Chart's axes. |
176
+ | `label` (required) | `string` | | The list's name for assistive technology: what is ranked, by what, over which period ("Top pages by visitors, last 7 days"). |
177
+ | `labelHeader` | `Element` | | A header over the labels ("Page"). |
178
+ | `labels` | `Partial<BarListLabels>` | | The words, in your wording or language (app-wide: `LocaleProvider messages.barList`). |
179
+ | `limit` | `number` | | Show the first `limit` rows, and a Show more button for the rest. |
180
+ | `max` | `number` | | The value a full bar stands for. Defaults to the largest in `data`. Pass the whole list's largest when `data` is part of it (search results, a page of it), so a bar keeps its length as others are left out. |
181
+ | `onSelect` | `((item: BarListItem<T>, index: number) => void)` | | Makes each row a toggle button (for rows with no `href`): filter the page by the chosen row. |
182
+ | `onShowMore` | `(() => void)` | | Called by Show more (with `limit`): open your own view of every row, a dialog with search. Without it, Show more expands the list in place, and the last rows fade out while it's collapsed. |
183
+ | `selected` | `string \| null` | | The `key` (or label) of the row that is on, for a filter: its button is pressed and its bar darker. `null` or nothing: none is on. |
184
+ | `share` | `boolean` | | A column with each row's share of the total (of every row, not only those shown). |
185
+ | `shareHeader` | `Element` | | A header over the shares, with `share` ("Share"). |
186
+ | `sort` | `"ascending" \| "descending" \| "none"` | `"descending"` | The order: largest first, smallest first, or as given. |
187
+ | `total` | `number` | | The total the shares are of. Defaults to the sum of `data`. Pass the whole list's total when `data` is part of it, so a row's share doesn't grow as others are left out. |
188
+ | `valueHeader` | `Element` | | A header over the values ("Visitors"). |
189
+
190
+ <!-- /generated:props:bar-list -->
@@ -0,0 +1,77 @@
1
+ # Chart grid
2
+
3
+ <!-- search: chart grid, dashboard charts, small multiples, synced cursor, metrics panel -->
4
+
5
+ Several charts on one time axis, laid out in columns that follow the width, with one cursor: point at a moment in one chart and read it in all of them. For a diagnostics or metrics panel read together, or for a set of series too large for one chart (small multiples).
6
+
7
+ ```tsx
8
+ import { Chart } from "@zsherman/charts/chart";
9
+ import { ChartGrid } from "@zsherman/charts/chart-grid";
10
+
11
+ <ChartGrid label="API service, last hour" chartHeight={180}>
12
+ <Chart title="Throughput (req/s)" label="Throughput, last hour: about 400 a second" data={throughput} series={[{ label: "Reads" }, { label: "Writes" }]} />
13
+ <Chart title="Latency (ms)" label="Latency, last hour: p95 under 200 ms" data={latency} series={[{ label: "p50" }, { label: "p95" }]} />
14
+ </ChartGrid>;
15
+ ```
16
+
17
+ ## Usage guidelines
18
+
19
+ - Use a grid for measures that share an x axis and are read together, each in its own unit: throughput, latency, errors, CPU. One chart each, one y axis each.
20
+ - Give every chart a `title` with its unit ("Latency (ms)") and a `label` with its finding; give the grid a `label` that names the panel and the period.
21
+ - Keep the panels few (two to six). A grid isn't a dashboard of dozens.
22
+ - Keep the charts alike: the same height (`chartHeight`), the same x formatter, one unit system.
23
+ - Turn `sync` off only when the charts don't share an x axis; then a grid of separate charts is the right tool anyway.
24
+ - Add a heading above the grid; chart titles are plain text, not headings.
25
+
26
+ ## Anatomy
27
+
28
+ ```tsx
29
+ <ChartGrid label="…" minColumnWidth={320} columns={2} sync chartHeight={180}>
30
+ <Chart … />
31
+ <Chart … />
32
+ </ChartGrid>
33
+ ```
34
+
35
+ A `div` (`data-slot="chart-grid"`, `role="group"` named by `label`) laid out as a CSS grid: as many columns as fit at `minColumnWidth` (320px), or exactly `columns`. Charts inside share a cursor sync key and take `chartHeight` unless they set `height`.
36
+
37
+ ## Live grids
38
+
39
+ Each chart's `data` updates on its own, without rebuilding, and the shared cursor stays put:
40
+
41
+ ```tsx
42
+ const [data, setData] = createSignal(metrics.map((m) => initial(m)));
43
+ // every 250ms: setData((all) => all.map((d, i) => append(d, i)));
44
+
45
+ <ChartGrid label="Cluster, live" chartHeight={160} minColumnWidth={280}>
46
+ <For each={metrics}>
47
+ {(m, i) => (
48
+ <Chart title={m.title} label={`${m.title}, live`} data={data()[i()]!} series={m.series} legend="live" zoom={false} />
49
+ )}
50
+ </For>
51
+ </ChartGrid>;
52
+ ```
53
+
54
+ ## Gotchas
55
+
56
+ - Charts sync by x value, so they need the same x units (all Unix seconds).
57
+ - Zooming one chart doesn't zoom the others.
58
+
59
+ ## API reference
60
+
61
+ <!-- generated:props:chart-grid (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
62
+
63
+ Generated from the types of `@zsherman/charts/chart-grid`. Each part also takes its element's native and ARIA attributes.
64
+
65
+ #### `ChartGrid`
66
+
67
+ | Prop | Type | Default | Description |
68
+ | --- | --- | --- | --- |
69
+ | `chartHeight` | `number` | | Plot height for charts that don't set `height`. |
70
+ | `children` (required) | `Element` | | The charts: `Chart` elements, each with a `title`. |
71
+ | `class` | `ClassValue` | | Extra classes on the root. |
72
+ | `columns` | `number` | | A fixed number of columns instead (they still shrink to fit). |
73
+ | `label` (required) | `string` | | Names the panel and its period for assistive technology ("Network, last hour"). |
74
+ | `minColumnWidth` | `number` | `320` | The narrowest a column gets, in pixels: the grid fits as many columns as the width allows. |
75
+ | `sync` | `boolean` | `true` | One cursor for every chart in the grid: point at a moment in one, read it in all. Turn it off when the charts don't share an x axis. |
76
+
77
+ <!-- /generated:props:chart-grid -->
package/docs/chart.md ADDED
@@ -0,0 +1,355 @@
1
+ # Chart
2
+
3
+ <!-- search: chart, graph, plot, line chart, area chart, bar chart, column chart, time series, uplot, visualization -->
4
+
5
+ A canvas chart for values over time or across categories: lines, areas and bars, grouped or stacked, with a tooltip at the cursor, a legend that toggles series, drag to zoom and data that streams in without rebuilding the chart. Built on uPlot, themed with the kit's tokens; the plot is a named image whose values the arrow keys read out.
6
+
7
+ ```tsx
8
+ import { Chart, type ChartData } from "@zsherman/charts/chart";
9
+
10
+ // x in Unix seconds, then one array per series.
11
+ const data: ChartData = [
12
+ [1793750400, 1793754000, 1793757600, 1793761200],
13
+ [1210, 1340, 1295, null],
14
+ [880, 940, 910, 970],
15
+ ];
16
+
17
+ <Chart
18
+ title="Requests per hour"
19
+ label="Requests per hour, in and out: steady at about 1,300 in"
20
+ data={data}
21
+ series={[{ label: "Inbound" }, { label: "Outbound" }]}
22
+ />;
23
+ ```
24
+
25
+ ## Usage guidelines
26
+
27
+ - Use a line for a trend of one or more series where the shape over time matters; an area for one series whose volume matters; bars for values people compare one by one.
28
+ - Name every chart with `label`: the metric, the period and the main finding ("Signups per week, last quarter: up 30%"). Add `title` for a visible name unless the page already gives one.
29
+ - Keep it to five series or fewer. A larger set reads better as several charts in a [ChartGrid](./chart-grid.md).
30
+ - One y axis per chart. Two measures with different units or scales are two charts on the same x axis (a `ChartGrid` syncs their cursors).
31
+ - The legend appears for two or more series and toggles each one; a single series needs none, its title names it.
32
+ - Give the chart a definite width from its container (it fills it) and a `height` (240 by default). The legend and title sit outside that height.
33
+ - When there's no data, show an `EmptyState` (or a sentence) instead of empty axes.
34
+
35
+ ## Anatomy
36
+
37
+ ```tsx
38
+ <Chart
39
+ title="…" // optional visible title
40
+ label="…" // the plot's accessible name (required)
41
+ data={[x, ...ys]}
42
+ series={[{ label: "…", type: "line" | "area" | "bar", color, dash, points }]}
43
+ x={{ time, categories, format, range, steps, label }}
44
+ y={{ format, range, steps, label, grid }}
45
+ legend={true | false | "live"}
46
+ tooltip={true | false | { formatX, render }}
47
+ onCursor={(point) => …} // the point under the cursor, null when it leaves
48
+ focus={true} // the pointer near a line, or a legend entry, fades the others
49
+ markers={[{ axis: "y", value: 4, label: "Target" }]}
50
+ zoom onZoom onSelect controller labels
51
+ />
52
+ ```
53
+
54
+ What renders: a root `div` (`data-slot="chart"`) with the title (`chart-title`), the plot (`chart-plot`, `role="img"` with `aria-label`, focusable when it has data) holding uPlot's canvas and the tooltip (`chart-tooltip`, a manual popover in the top layer, with a heading `chart-tooltip-heading` and a row per series, `chart-tooltip-row`, `data-focused` on the focused series' row), a polite live region (`chart-readout`) for the keyboard readout, and the legend (`chart-legend`: a list of toggle buttons, `chart-legend-item`, each with a swatch, `chart-swatch`).
55
+
56
+ ## Series
57
+
58
+ Each entry of `series` describes the y array at the same position (`series[0]` is `data[1]`).
59
+
60
+ | Field | What it does |
61
+ | --- | --- |
62
+ | `label` | The name in the legend, tooltip and readout. Required. |
63
+ | `type` | `"line"` (default), `"area"` (a 12% wash under the line) or `"bar"`. |
64
+ | `color` | `"chart-1"` … `"chart-8"`, or any CSS color (`"var(--sui-text-subtle)"`). Defaults to the next chart color in order. |
65
+ | `width` | Line width in pixels (2). |
66
+ | `dash` | A dash pattern (`[6, 4]`) for a target or a forecast: a cue beside color. |
67
+ | `points` | A dot at each point. For a few points, not dense series. |
68
+ | `show` | `false` to start hidden (the legend shows it off). |
69
+ | `format` | Formats this series' values in the tooltip, legend and readout. |
70
+
71
+ ## Bars and categories
72
+
73
+ Bars sit on their x value, at most 24px wide with a rounded data end. Several bar series are grouped side by side; `stacked` stacks them (and areas) instead, and the tooltip and legend still show each series' own value.
74
+
75
+ A category axis takes `x.categories`: the data's x array is `0, 1, 2, …` and each value is named.
76
+
77
+ ```tsx
78
+ <Chart
79
+ title="Revenue by plan"
80
+ label="Monthly revenue by plan, June to November: Enterprise grows fastest"
81
+ data={[
82
+ [0, 1, 2, 3, 4, 5],
83
+ [18.2, 19.4, 21.1, 20.6, 22.8, 24.3],
84
+ [31.5, 33.9, 35.2, 38.4, 41.0, 43.7],
85
+ [42.0, 41.2, 47.8, 52.3, 55.1, 61.9],
86
+ ]}
87
+ series={[
88
+ { label: "Starter", type: "bar" },
89
+ { label: "Team", type: "bar" },
90
+ { label: "Enterprise", type: "bar" },
91
+ ]}
92
+ x={{ categories: ["Jun", "Jul", "Aug", "Sep", "Oct", "Nov"] }}
93
+ y={{ format: (v) => `$${v}k` }}
94
+ zoom={false}
95
+ />
96
+ ```
97
+
98
+ Parts of a daily total, stacked (bars and stacks start at zero; segments are separated by a 2px gap in the surface color, and hiding a series from the legend restacks the rest):
99
+
100
+ ```tsx
101
+ <Chart
102
+ label="Deploys per day by environment, last two weeks"
103
+ data={deploys}
104
+ stacked
105
+ series={[
106
+ { label: "Production", type: "bar" },
107
+ { label: "Staging", type: "bar" },
108
+ { label: "Preview", type: "bar" },
109
+ ]}
110
+ zoom={false}
111
+ />
112
+ ```
113
+
114
+ ## Axes and formats
115
+
116
+ `x` and `y` take `format` (tick labels; also the tooltip unless a series has its own), `range` (a fixed `[min, max]`), `steps` (allowed tick steps: `[1]` for whole numbers), `label` (an axis title), `grid` and `show`. On a time axis (the default without `categories`), ticks are uPlot's dates; the tooltip heading uses `Intl.DateTimeFormat` in the kit's locale, with as much detail as the data's span needs. Numbers default to the locale's format, compact from 10,000 (`12.9K`).
117
+
118
+ ```tsx
119
+ const week = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", timeZone: "UTC" });
120
+
121
+ <Chart
122
+ label="Weekly signup conversion: rising to just under the 4% target"
123
+ data={conversion}
124
+ series={[{ label: "Conversion", points: true }]}
125
+ x={{ format: (t) => week.format(new Date(t * 1000)) }}
126
+ y={{ range: [0, 6], format: (v) => `${v.toFixed(1)}%`, label: "Conversion" }}
127
+ markers={[{ axis: "y", value: 4, label: "Target 4%" }]}
128
+ tooltip={{ formatX: (t) => `Week of ${week.format(new Date(t * 1000))}` }}
129
+ />;
130
+ ```
131
+
132
+ Pass a time zone to your formatters when the data's day boundaries matter; the defaults use the reader's.
133
+
134
+ ## Reference lines and bands
135
+
136
+ `markers` draws a target, a threshold or a window across the plot: on `y` a horizontal line (a target, an SLO) or band (a normal range), on `x` a vertical line (a deploy, a release) or band (an incident). A line is dashed; a band is a wash. Each takes a `label`, drawn beside it in a text color and read out after the chart's label ("SLO 300 ms: 300 ms; Incident: 3:04 PM – 3:18 PM"), and a `tone`: `neutral` (the default) for a reference, a status tone when it means a state. The y axis keeps every y marker in view.
137
+
138
+ ```tsx
139
+ <Chart
140
+ label="API latency per minute: p95 broke the 300 ms SLO during the 3:04 PM incident"
141
+ data={latency}
142
+ series={[{ label: "p50" }, { label: "p95" }]}
143
+ y={{ format: (v) => `${v} ms` }}
144
+ markers={[
145
+ { axis: "y", value: 300, label: "SLO 300 ms", tone: "warning" },
146
+ { axis: "x", value: deployedAt, label: "Deploy" },
147
+ { axis: "x", value: [incidentStart, incidentEnd], label: "Incident", tone: "danger" },
148
+ ]}
149
+ />
150
+ ```
151
+
152
+ | Field | What it does |
153
+ | --- | --- |
154
+ | `axis` | `"y"` (at a value) or `"x"` (at a time or category). |
155
+ | `value` | One value for a line, `[from, to]` for a band, in the axis' units. |
156
+ | `label` | Drawn beside it and read out with the chart. |
157
+ | `tone` | `"neutral"` (default), `"accent"`, `"success"`, `"warning"`, `"danger"`. Say the meaning in `label` too. |
158
+ | `dash` | The line's dash pattern in pixels (`[6, 4]`). |
159
+
160
+ Use a marker, not a second series, for a constant: it isn't data, so it stays out of the legend and the tooltip.
161
+
162
+ ## Live data
163
+
164
+ New `data` flows into the existing chart (uPlot's `setData`): it never rebuilds, so a signal updated 20 times a second is fine. Build each update as new arrays (the window slides by dropping the oldest point). Pause the stream when the chart is off screen or the tab is hidden.
165
+
166
+ ```tsx
167
+ const [data, setData] = createSignal<ChartData>(initial());
168
+
169
+ createEffect(
170
+ () => running(),
171
+ (on) => {
172
+ if (!on) return;
173
+ const timer = setInterval(() => setData((d) => append(d, Date.now() / 1000)), 50);
174
+ return () => clearInterval(timer);
175
+ },
176
+ );
177
+
178
+ <Chart
179
+ label="Five live system signals, in percent of capacity"
180
+ data={data()}
181
+ series={signals.map((label) => ({ label, width: 1.5 }))}
182
+ y={{ range: [0, 100], format: (v) => `${Math.round(v)}%` }}
183
+ legend="live"
184
+ zoom={false}
185
+ />;
186
+ ```
187
+
188
+ `legend="live"` shows each series' value at the cursor (the latest value otherwise). For data that changes outside Solid (a socket buffer), the controller's `setData` does the same as the prop:
189
+
190
+ ```tsx
191
+ <Chart label="…" data={initial} series={series} controller={(c) => socket.on("tick", (d) => c.setData(d))} />
192
+ ```
193
+
194
+ Any other prop (series, axes, stacking, tooltip) rebuilds the chart in place when it changes: no `key` needed.
195
+
196
+ ## Zoom and selection
197
+
198
+ Dragging across the plot zooms the x axis (`zoom`, on by default); a double-click zooms back out. `onZoom` reports the range after a zoom and `null` when it resets; the controller's `resetZoom` resets it from a button. Streaming data keeps the zoom.
199
+
200
+ ```tsx
201
+ const [range, setRange] = createSignal<ChartRange | null>(null);
202
+ let chart: ChartController | undefined;
203
+
204
+ <Show when={range()}>
205
+ <Button size="sm" onClick={() => chart?.resetZoom()}>Reset zoom</Button>
206
+ </Show>
207
+ <Chart label="API latency per minute" data={latency} series={[{ label: "p50" }, { label: "p95" }]} onZoom={setRange} controller={(c) => (chart = c)} />;
208
+ ```
209
+
210
+ For a brush that selects a range without zooming (to filter a table, say), set `zoom={false}` and `onSelect`: it receives the dragged `{ min, max }` and the brush clears.
211
+
212
+ ## Tooltip and cursor
213
+
214
+ <!-- search: custom tooltip, tooltip content, tooltip render, cursor callback, hover callback, crosshair, highlight series, focus series, dim other series, tooltip clipped, tooltip overflow -->
215
+
216
+ The tooltip follows the pointer and the keyboard's cursor. It renders in the top layer (a manual popover, still inside the chart in the DOM, so its theme and tokens reach it): a card with `overflow: hidden`, a scrolling dialog body or a stacking context never cuts it off. It sits beside the cursor, flips to the other side where it would leave the viewport, and slides along the cursor at the top and bottom edges.
217
+
218
+ `tooltip={{ render }}` puts your own content in the box, in place of the heading and the rows: a total, shares, a note. `render` is called once while the tooltip is open with an accessor for the `ChartPoint` under the cursor; read it in your JSX and the content follows the cursor. The box, its placement and the keyboard stay the chart's.
219
+
220
+ ```tsx
221
+ import { Chart, type ChartPoint } from "@zsherman/charts/chart";
222
+ import { For } from "solid-js";
223
+
224
+ function Breakdown(props: { point: ChartPoint }) {
225
+ const shown = () => props.point.series.filter((s) => s.shown);
226
+ const total = () => shown().reduce((sum, s) => sum + (s.value ?? 0), 0);
227
+ return (
228
+ <div style={{ display: "grid", gap: "4px" }}>
229
+ <strong>{props.point.xText}: {total()} deploys</strong>
230
+ <For each={shown()}>
231
+ {(s) => (
232
+ <div style={{ display: "flex", gap: "8px" }}>
233
+ <span style={{ width: "8px", height: "8px", background: s.color }} aria-hidden="true" />
234
+ <span style={{ "flex-grow": 1 }}>{s.label}</span>
235
+ <span>{s.text}</span>
236
+ </div>
237
+ )}
238
+ </For>
239
+ </div>
240
+ );
241
+ }
242
+
243
+ <Chart
244
+ label="Deploys per day by environment"
245
+ data={deploys}
246
+ stacked
247
+ series={[{ label: "Production", type: "bar" }, { label: "Staging", type: "bar" }]}
248
+ tooltip={{ render: (point) => <Breakdown point={point()} /> }}
249
+ />;
250
+ ```
251
+
252
+ A `ChartPoint` is what's under the cursor:
253
+
254
+ | Field | Type | |
255
+ | --- | --- | --- |
256
+ | `index` | `number` | The index into the data arrays. |
257
+ | `x` | `number` | The x value (Unix seconds on a time axis, the index on a category axis). |
258
+ | `xText` | `string` | The x value as the tooltip heading writes it. |
259
+ | `series` | `ChartPointSeries[]` | Every series in order, hidden ones included: `label`, `value` (its own value, not a stack's running total; `null` where it has no reading), `text` (the value formatted), `color` (CSS, for your own swatch) and `shown`. |
260
+ | `focused` | `number \| null` | The focused series (an index into `series`): the pointer is on it, or its legend entry is hovered or focused. |
261
+
262
+ `onCursor` reports the same point to your code whenever the cursor moves to another point or the focused series changes, and `null` when it leaves: a readout above the chart, your own legend, the matching row of a table. It fires for the pointer, the keyboard and a [ChartGrid](./chart-grid.md)'s shared cursor, and not at all until the cursor has been somewhere.
263
+
264
+ ```tsx
265
+ const [point, setPoint] = createSignal<ChartPoint | null>(null);
266
+
267
+ <p>{point() ? `${point()!.xText}: ${point()!.series.map((s) => `${s.label} ${s.text}`).join(", ")}` : "Point at the chart"}</p>
268
+ <Chart label="Response time, 2 to 4 PM" data={latency} series={[{ label: "p50" }, { label: "p95" }]} onCursor={setPoint} />;
269
+ ```
270
+
271
+ With two or more lines or areas side by side, the pointer near one focuses it: the others fade, and the tooltip sets its row apart. Hovering or focusing a legend entry focuses its series too, for any type (bars and stacks are focused from the legend only, since the pointer's distance to a bar's top says little about which bar it's on). `focus={false}` turns both off. A ChartGrid's charts focus each on their own.
272
+
273
+ ## Controller
274
+
275
+ `controller` receives a `ChartController` once the chart mounts, for work that doesn't fit props: data from outside Solid, ranges set from your own controls, uPlot's own API.
276
+
277
+ | Method | What it does |
278
+ | --- | --- |
279
+ | `setData(data)` | Replace the data without rebuilding the chart (the same as new `data`). |
280
+ | `setXRange({ min, max })` | Zoom the x axis to a range (reported through `onZoom`). |
281
+ | `setYRange({ min, max })` | Fix the y axis to a range until the data changes. |
282
+ | `resetZoom()` | Fit the x axis to the data again (reported as `onZoom(null)`). |
283
+ | `uplot()` | The uPlot instance, or `null` before mount and on the server. |
284
+
285
+ A `ChartRange` is `{ min: number; max: number }` in x units (Unix seconds on a time axis). For your own drawing, pass uPlot `plugins` or `hooks`; they're added after the chart's own.
286
+
287
+ ## Colors
288
+
289
+ Series take the chart tokens in order: `--sui-chart-1` (blue), `-2` (orange), `-3` (aqua), `-4` (yellow), `-5` (magenta), `-6` (green), `-7` (violet), `-8` (red), each a light and a dark value, chosen so neighbours stay apart for color-blind readers. A series keeps its color when others are hidden, so color follows the series, not its position on screen.
290
+
291
+ - Pick a series color by token name (`color: "chart-3"`) to keep it themed; any CSS color works.
292
+ - Override a token for your brand like any kit token: `:root { --sui-chart-1: oklch(0.55 0.14 160); }` (both schemes: `light-dark(…, …)`).
293
+ - Past eight series, fold the rest into "Other" or split the chart; never generate a ninth hue.
294
+ - Text never wears a series color: labels and values use the kit's text colors, with the series' swatch beside them.
295
+ - Status colors (`--sui-success`, `--sui-danger`) mean states, not series.
296
+
297
+ In light mode, chart-3, -4 and -5 sit under 3:1 against the surface: a chart using them keeps its legend and offers its values as a table.
298
+
299
+ ## Words
300
+
301
+ The chart's own strings (the keyboard hint after the plot's name, the legend list's name) take `labels={{ keyboardHint, legend }}`, or app-wide the kit's `LocaleProvider messages={{ chart: { … } }}`. Numbers and dates follow `LocaleProvider`'s locale.
302
+
303
+ ## Accessibility
304
+
305
+ - The plot is an image named by `label` (and `description`, if set). Write the finding into it, not just the metric. Labeled markers are read after it.
306
+ - With a tooltip, the plot is focusable: Left and Right move the cursor one point (Home and End to the ends, Escape to clear), the tooltip follows, and a polite live region reads the x value and each visible series' value. A custom `render` changes only what's seen: the live region still reads the values.
307
+ - The legend is a list of toggle buttons (`aria-pressed`), outside the image, each named by its series.
308
+ - A canvas exposes nothing else. When people need the values, put them in a table or text next to the chart (the "with a data table" example uses the kit's `Table`).
309
+ - Separate series by more than hue where it matters: `dash`, `points`, or the legend's names.
310
+
311
+ ## Gotchas
312
+
313
+ - x in milliseconds draws a chart in the year 58,000: divide by 1000.
314
+ - One `series` entry per y array, in the same order: the entry at index `i` describes `data[i + 1]`.
315
+ - The chart fills its container's width; a container with no width (`display: none`, an unmeasured flex item) draws nothing until it gets one.
316
+ - Canvas text uses the chart's font family and size; a web font that loads later redraws it.
317
+ - `tooltip.render` gets an accessor: read `point()` inside your JSX (`<Breakdown point={point()} />`), not once at the top of `render`, or the content stays on the first point.
318
+
319
+ ## API reference
320
+
321
+ <!-- generated:props:chart (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
322
+
323
+ Generated from the types of `@zsherman/charts/chart`. Each part also takes its element's native and ARIA attributes.
324
+
325
+ #### `Chart`
326
+
327
+ | Prop | Type | Default | Description |
328
+ | --- | --- | --- | --- |
329
+ | `class` | `ClassValue` | | Extra classes on the root. Unlayered app CSS wins over the chart's. |
330
+ | `controller` | `((controller: ChartController) => void)` | | Receives the chart's controller once it mounts: push data, set ranges, reach uPlot. |
331
+ | `cursor` | `boolean` | `true` | Show the cursor line and points on hover. |
332
+ | `data` (required) | `AlignedData` | | `[x, ...ys]`: x values first, then one array per series. Updates without rebuilding the chart. |
333
+ | `description` | `string` | | A longer description read after the label (a trend, the peak). |
334
+ | `focus` | `boolean` | `true` | Fade the other series while one is focused: the pointer near a line or an area, or a legend entry hovered or focused (any series type). The tooltip sets the focused series' row apart. |
335
+ | `height` | `number` | `240` | The plot's height in pixels, axes included (the legend and title sit outside it). The width follows the container. |
336
+ | `hooks` | `Arrays` | | uPlot hooks of your own. |
337
+ | `label` (required) | `string` | | What the chart shows, for assistive technology: the metric, the period and the main finding ("Requests per minute, last hour: steady at about 1,200"). The canvas has no other name. |
338
+ | `labels` | `Partial<ChartLabels>` | | The chart's built-in strings, in your words or language (app-wide: `LocaleProvider messages.chart`). |
339
+ | `legend` | `"live" \| boolean` | | The series legend under the plot; each entry toggles its series. `"live"` also shows each value at the cursor (the latest value otherwise). Defaults to on for two or more series. |
340
+ | `markers` | `ChartMarker[]` | | Reference lines and bands: a target or a threshold on y, a deploy or an incident on x. The y axis keeps them in view, and their labels are read out after the chart's label. |
341
+ | `onCursor` | `((point: ChartPoint \| null) => void)` | | Called when the cursor moves to another point, or the focused series changes, with what's under it; `null` when it leaves the plot. For your own legend, a readout beside the chart, or the matching row of a table. Fires for the keyboard's cursor and a ChartGrid's shared one too. |
342
+ | `onSelect` | `((range: ChartRange) => void)` | | Called with the dragged x range instead of zooming (brush selection; set `zoom={false}`). |
343
+ | `onZoom` | `((range: ChartRange \| null) => void)` | | Called after a zoom with the new x range, and with `null` when the chart zooms back out. |
344
+ | `padding` | `[number, number, number, number]` | | Space around the plot in pixels: `[top, right, bottom, left]`. |
345
+ | `plugins` | `Plugin[]` | | uPlot plugins of your own (annotations, custom drawing). |
346
+ | `series` (required) | `ChartSeries[]` | | One entry per y array, in the same order. |
347
+ | `stacked` | `boolean` | | Stack the series: each sits on the ones before it. The tooltip and legend show each series' own value. |
348
+ | `syncKey` | `string` | | Charts with the same key share a cursor. Charts in a ChartGrid share one by default. |
349
+ | `title` | `Element` | | A visible title above the plot. Leave it out when the page already names the chart. |
350
+ | `tooltip` | `boolean \| ChartTooltip` | `true` | The tooltip at the cursor, also driven by the keyboard (arrow keys on the focused plot). |
351
+ | `x` | `ChartXAxis` | | The x axis: time (the default), numbers or categories. |
352
+ | `y` | `ChartAxis` | | The y axis. |
353
+ | `zoom` | `boolean` | `true` | Drag across the plot to zoom the x axis; double-click to zoom out. |
354
+
355
+ <!-- /generated:props:chart -->