@zsherman/charts 0.0.0-stage → 0.1.1

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 +24 -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 +109 -4
package/docs/donut.md ADDED
@@ -0,0 +1,182 @@
1
+ # Donut
2
+
3
+ <!-- search: donut, pie chart, doughnut, ring chart, part to whole, breakdown, share, distribution, legend, other slice -->
4
+
5
+ Part-to-whole as a ring of slices: revenue by region, traffic by channel, tickets by reason. The total sits in the centre, and the legend list beside the ring carries every value and share: hovering or focusing a row highlights its slice (and the reverse), and with `onSelect` the rows filter the rest of the page. It's plain SVG, so it renders on the server.
6
+
7
+ ```tsx
8
+ import { Donut } from "@zsherman/charts/donut";
9
+
10
+ <Donut
11
+ label="Revenue by region, Q3 2026"
12
+ data={[
13
+ { label: "North America", value: 482_300 },
14
+ { label: "EMEA", value: 391_750 },
15
+ { label: "Asia Pacific", value: 214_900 },
16
+ { label: "Latin America", value: 88_400 },
17
+ ]}
18
+ />;
19
+ ```
20
+
21
+ ## Usage guidelines
22
+
23
+ - Use it for one whole split into a few categories, when the share is the point. Three to six slices read best. To rank many categories, use a [Bar list](./bar-list.md); to compare wholes over time, a stacked [Chart](./chart.md); for a whole on one line, a [Segmented bar](./segmented-bar.md).
24
+ - Name it with `label`: what the whole is. The ring's accessible name is the label, the total, then every slice's share, written from the data ("Revenue by region, Q3 2026, Total $1.2M: North America 40%, EMEA 32%, …").
25
+ - Keep the legend (it's on by default): it's where values are written and how slices are read. Don't add a tooltip.
26
+ - Slices are drawn in the order of `data`, from the top, clockwise. Sort the data largest first unless the categories have an order of their own.
27
+
28
+ ## Anatomy
29
+
30
+ Each category is a `DonutDatum`:
31
+
32
+ | Field | Type | |
33
+ | --- | --- | --- |
34
+ | `label` | `string` | The category ("EMEA"). |
35
+ | `value` | `number \| null` | Its amount. Missing, zero or negative draws no slice; the legend row stays, at 0. |
36
+ | `key` | `string` | Identifies the category for `selected` when labels repeat. Defaults to `label`. |
37
+ | `color` | `ChartColor` | A chart token (`"chart-3"`) or any CSS color. Defaults to the next chart token among the drawn slices; set it to keep a category's color when the data changes. |
38
+ | `data` | `T` | Your own data, handed back to `onSelect` (in the slice's `items`). |
39
+
40
+ ```tsx
41
+ <Donut
42
+ label="…" // required: what the whole is
43
+ data={[{ label, value, color, data }]} // drawn from the top, clockwise
44
+ size={160} // width and height in pixels; under 80, no centre
45
+ thickness={20} // the ring's width; an eighth of size by default
46
+ gap={2} // between slices
47
+ center={<>…</>} // replaces the total (false keeps the default)
48
+ legend // true by default; false keeps the values for assistive technology only
49
+ maxSlices={8} // the smallest fold into "Other" past it
50
+ format={(v) => …} // how values are written
51
+ onSelect={(slice) => …} // legend rows become buttons
52
+ selected="EMEA" // the pressed category (its key, or label); null for none
53
+ loading // a skeleton ring
54
+ labels={{ total, other, empty, loading }}
55
+ >
56
+ {/* optional: your own legend placement */}
57
+ </Donut>
58
+ ```
59
+
60
+ What renders: a root `div` (`data-slot="donut"`, `aria-busy` while loading) with the figure (`donut-figure`, `role="img"` named from the data) holding the `svg` of slices (`donut-slice`, `data-index`, `data-active` while highlighted; `donut-track` when empty or loading) and the centre (`donut-center`, hidden from assistive technology), then the legend (`donut-legend`, a `ul` of `donut-legend-item` rows, each a button with `onSelect`).
61
+
62
+ ## Legend and highlight
63
+
64
+ Hovering a legend row, or focusing it when rows are buttons, highlights its slice: the others dim and the centre shows that slice's value, then its share and label ("16% · Paid social"). The value is sized to fit the hole. Hovering a slice highlights its row; the pointer wins over the focus, and the focus over the selection. With `onSelect`, each row is a toggle button named "Label, value, share" (clicking a slice selects too). Pass `selected` (the category's `key`, or its label) so the chosen row is pressed and its slice stays highlighted; `null` or nothing means none is chosen. A selected category that is folded into "Other" marks "Other".
65
+
66
+ ```tsx
67
+ import { Donut } from "@zsherman/charts/donut";
68
+ import { createSignal } from "solid-js";
69
+
70
+ const [channel, setChannel] = createSignal<string>();
71
+
72
+ <Donut
73
+ label="Signups by channel, last 30 days"
74
+ data={signups}
75
+ selected={channel()}
76
+ onSelect={(slice) => setChannel((current) => (current === slice.label ? undefined : slice.label))}
77
+ />;
78
+ ```
79
+
80
+ `onSelect` receives a `DonutSlice`: its `key`, `label`, `value`, `share` (0 to 1), `color`, `index`, whether it's `other`, and `items`, the data behind it (one category, or every category folded into "Other").
81
+
82
+ Without `onSelect` the rows are plain list items: hover still highlights, and the values are all written in the list, so nothing is lost for keyboard users.
83
+
84
+ ## Many categories
85
+
86
+ Past `maxSlices` (8 by default, the number of chart colors), the largest categories keep their slices and the rest fold into one "Other" slice in a gray, last. Its legend row lists what it holds, with each share ("India 3.2%, Netherlands 1.8%, …"), so every category stays in the page.
87
+
88
+ ## Your own legend placement
89
+
90
+ Children replace the built-in legend. Place a `DonutLegend` among them (it must be inside the `Donut`): with a heading, or without shares (`share={false}`). `center` replaces the centre's content.
91
+
92
+ ```tsx
93
+ import { Donut, DonutLegend } from "@zsherman/charts/donut";
94
+
95
+ <Donut label="Seats by role, Team plan" data={seats} center={<strong>44 of 50</strong>}>
96
+ <div style={{ flex: "1 1 12rem" }}>
97
+ <span>Seats in use</span>
98
+ <DonutLegend share={false} />
99
+ </div>
100
+ </Donut>;
101
+ ```
102
+
103
+ ## Compact
104
+
105
+ Under 80px the donut has no centre: a mark beside text, in a table cell or a list row. `legend={false}` hides the list from sight but keeps it in the page for assistive technology, so the values are still there; name the donut for what it shows and write the key figure in the text beside it. With `legend={false}` the slices aren't clickable, since a keyboard couldn't reach them; a `DonutLegend` placed in children still offers the choice.
106
+
107
+ ```tsx
108
+ <Donut
109
+ label="checkout-web tests"
110
+ size={24}
111
+ legend={false}
112
+ data={[
113
+ { label: "Passed", value: 182, color: "var(--sui-success)" },
114
+ { label: "Failed", value: 4, color: "var(--sui-danger)" },
115
+ ]}
116
+ />
117
+ ```
118
+
119
+ ## Colors
120
+
121
+ Drawn slices take the chart colors in order (`--sui-chart-1`, `--sui-chart-2`, …), the same as Chart's series, so no two slices share a color; "Other" is a gray. Folding or new data can move a category to another color: pass `color` for categories that must keep theirs when the data changes. `maxSlices` defaults to 8, which with "Other" stays within the eight chart colors. `color` on a datum takes a chart token (`"chart-3"`) or any CSS color, such as a status token for a breakdown by state (`"var(--sui-danger)"`). Slices keep their colors in forced-colors mode (they're data); the legend names them.
122
+
123
+ ## States
124
+
125
+ - **Empty**: no data, or nothing above 0. An empty ring in the track color with "No data" in the centre (`labels.empty`), and the name ends in it. Categories at 0 keep their legend rows.
126
+ - **Loading**: `loading` draws a skeleton ring and skeleton legend rows that keep the layout, sets `aria-busy` on the root, and names the ring "…: Loading". The pulse stops under reduced motion.
127
+ - **One dominant value**: every slice above 0 keeps at least 2px of arc (the room comes out of the larger slices), and the legend says how small ("<0.1%").
128
+
129
+ ## Formats
130
+
131
+ Values follow the kit's locale (`LocaleProvider`): full below a total of 10,000 and compact above (93.6K), the same in the centre and the legend. Pass `format` for currency or units. Shares have one decimal under 10%, none above, and "<0.1%" for a sliver.
132
+
133
+ ## Accessibility
134
+
135
+ - The ring is an image (`role="img"`) named from the data: the label, the total and each slice's share. The centre is visual only.
136
+ - The legend list is always in the page (visible, or for assistive technology only with `legend={false}`), so every value can be read.
137
+ - With `onSelect`, the legend rows are buttons, each a tab stop named "Label, value, share", pressed when selected. Focusing one shows it in the centre.
138
+
139
+ ## Words
140
+
141
+ `total`, `other`, `empty` and `loading` take `labels`, or app-wide the kit's `LocaleProvider messages={{ donut: { … } }}`.
142
+
143
+ ## Gotchas
144
+
145
+ - Negative and missing values count as 0; a donut can't show a negative part. Use a bar [Chart](./chart.md).
146
+ - Shares are rounded on their own, so they can add up to 99% or 101%.
147
+ - `selected` matches a category by its `key` (or label); "Other" is matched by its own key, the `labels.other` word, or by any category folded into it.
148
+
149
+ ## API reference
150
+
151
+ <!-- generated:props:donut (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
152
+
153
+ Generated from the types of `@zsherman/charts/donut`. Each part also takes its element's native and ARIA attributes.
154
+
155
+ #### `Donut`
156
+
157
+ | Prop | Type | Default | Description |
158
+ | --- | --- | --- | --- |
159
+ | `center` | `Element` | | Replaces the centre's content (by default the total, or the hovered or focused slice). `false` keeps the default. |
160
+ | `children` | `Element` | | Where the legend goes, in place of the built-in one: a `DonutLegend` and anything around it. |
161
+ | `class` | `ClassValue` | | Extra classes on the root. |
162
+ | `data` (required) | `readonly DonutDatum<T>[]` | | The categories, in the order they're drawn from the top, clockwise. |
163
+ | `format` | `((value: number) => string)` | | How values are written. Defaults to the locale's numbers, compact from 10,000. |
164
+ | `gap` | `number` | | The space between slices in pixels. Defaults to 2 (1 under 64). |
165
+ | `label` (required) | `string` | | What the whole is ("Revenue by region"). The image's name is this, the total, then each slice's share. |
166
+ | `labels` | `Partial<DonutLabels>` | | The words, in your wording or language (app-wide: `LocaleProvider messages.donut`). |
167
+ | `legend` | `boolean` | `true` | The legend list beside the donut, the way to read and choose slices. `false` keeps the values in the page for assistive technology only, and the slices aren't clickable. Children replace it: place a `DonutLegend` among them (it offers the choice even with `legend={false}`). |
168
+ | `loading` | `boolean` | | A skeleton ring while the data loads; the root is `aria-busy`. |
169
+ | `maxSlices` | `number` | `8` | The most slices drawn: past it, the smallest categories fold into one "Other" slice, whose legend row lists them. |
170
+ | `onSelect` | `((slice: DonutSlice<T>) => void)` | | Makes each legend row a toggle button (and each slice clickable): filter the page by the chosen category. With `legend={false}` the slices aren't clickable; a `DonutLegend` in children still offers the choice. |
171
+ | `selected` | `string \| null` | | The `key` (or label) of the category that is on, for a filter: its row is pressed and its slice stays highlighted. A category folded into "Other" marks "Other". `null` or nothing: none is on. |
172
+ | `size` | `number` | `160` | The donut's width and height in pixels. Under 80 it's a compact mark with nothing in the centre. |
173
+ | `thickness` | `number` | | The ring's width in pixels. Defaults to an eighth of `size` (a fifth under 64). |
174
+
175
+ #### `DonutLegend`
176
+
177
+ | Prop | Type | Default | Description |
178
+ | --- | --- | --- | --- |
179
+ | `class` | `ClassValue` | | Extra classes on the list. |
180
+ | `share` | `boolean` | `true` | Each row's share of the total, after its value. |
181
+
182
+ <!-- /generated:props:donut -->
@@ -0,0 +1,121 @@
1
+ # Heat graph
2
+
3
+ <!-- search: heatmap, calendar heatmap, contribution graph, activity graph, github graph, punch card -->
4
+
5
+ A calendar of daily counts, one cell per day in week columns, shaded by level: which days and weekdays are busy across weeks or months. It's plain DOM (no canvas), so it renders on the server. It's a grid with one tab stop: the arrow keys move by day and week, each day is named with its count and date, and the tooltip follows both the pointer and the focus.
6
+
7
+ ```tsx
8
+ import { HeatGraph } from "@zsherman/charts/heat-graph";
9
+
10
+ <HeatGraph
11
+ label="Commits in 2026: 1,204, busiest in the spring"
12
+ data={[
13
+ { date: "2026-01-05", count: 4 },
14
+ { date: "2026-01-06", count: 7 },
15
+ ]}
16
+ start="2026-01-01"
17
+ end="2026-12-31"
18
+ labels={{ count: (n, formatted) => `${formatted} ${n === 1 ? "commit" : "commits"}` }}
19
+ />;
20
+ ```
21
+
22
+ ## Usage guidelines
23
+
24
+ - Use it for daily counts over weeks or months, when the question is which days and weekdays are busy: contributions, deploys, support tickets, sessions.
25
+ - Name it with `label`: the measure, the period and the takeaway ("Commits in 2026: 1,204, busiest in the spring"). Put the key numbers in text beside it too; shade isn't a number.
26
+ - Give the count its unit with `labels.count` ("12 commits"): every day's name and tooltip use it.
27
+ - Set `start` and `end` for a fixed period (a year, the last 12 weeks), so the grid doesn't depend on which days have data and an empty period still draws.
28
+ - For values between pairs of things (not days), use a [Heat matrix](./heat-matrix.md); for exact values or a trend over time, a [Chart](./chart.md); for one number's shape in a stat tile, a [Sparkline](./sparkline.md).
29
+
30
+ ## Anatomy
31
+
32
+ ```tsx
33
+ <HeatGraph
34
+ label="…" // required: the grid's accessible name
35
+ data={[{ date, count }]} // "YYYY-MM-DD" or a Date; same-day entries add up
36
+ start end // the period
37
+ weekStart="monday" // or "sunday"; defaults to the locale's
38
+ thresholds={[1, 5, 10, 20]} // lower bounds of levels 1–4; quarters of the busiest day by default
39
+ color="chart-1" // the ramp's color
40
+ shape="rounded" // "square", "rounded" or "circle"
41
+ sizeEncoding="fixed" // "value": the mark's area follows the count too
42
+ cellSize={14} cellGap={3} // fixed cells; without cellSize they share the width
43
+ monthLabels dayLabels legend // each on by default
44
+ onSelectDay={(day) => …} // click, Enter or Space on a day
45
+ labels={{ less, more, count }}
46
+ />
47
+ ```
48
+
49
+ What renders: a root `div` (`data-slot="heat-graph"`) with the month names (`heat-graph-months`, hidden from assistive technology), the grid (`heat-graph-grid`, `role="grid"` named by `label`) of seven `row`s, one per weekday, each holding a `gridcell` per day (`data-date`, `data-level` 0–4) with its mark (`heat-graph-mark`), then the legend (`heat-graph-legend`) and the tooltip (`heat-graph-tooltip`). Weekday names (Mon, Wed, Fri) sit at the start of their rows.
50
+
51
+ ## Levels and colors
52
+
53
+ A day's level is 0 with no activity, then 1 to 4 by `thresholds`: the count at or above each bound. The default bounds are quarters of the busiest day in the period (`[1, 4, 7, 10]` when the busiest day has 12; one level per count up to 4). Fix `thresholds` when graphs side by side must share a scale, or when the levels mean something ("10 or more is a busy day").
54
+
55
+ The ramp is one hue, light to dark: level 0 is the muted surface, levels 1–3 wash `color` over it (30%, 55%, 78%), level 4 is the color itself. `color` takes a chart token (`"chart-3"`) or any CSS color; the ramp follows the light and dark schemes. Levels keep their colors in forced-colors mode (they're data); the focus ring follows the system.
56
+
57
+ ## Size encoding
58
+
59
+ `sizeEncoding="value"` sizes each mark by its count as well as its shade: the mark's area is proportional to the count, from a small dot at zero to the full cell on the busiest day. With `shape="circle"` the days read as bubbles. The whole cell stays the hover and click target.
60
+
61
+ ## Layout
62
+
63
+ Without `cellSize`, the cells share the root's width (a year of 53 weeks needs about 700px for readable cells). With it, each cell is that many pixels and the graph takes its own width (`max-content`): put it in a scrolling container (`overflow-x: auto`) where the space is narrower, with about 4px of padding so the focused day's ring isn't cut off at the edges. `cellGap` sets the space between cells (3px). The first column starts on the week's first day, so a period that starts midweek leaves the days before it empty.
64
+
65
+ ## Keyboard
66
+
67
+ | Key | Action |
68
+ | --- | --- |
69
+ | Tab | Into the grid, on the latest day (or the last one focused). |
70
+ | ↑ / ↓ | The day before or after. |
71
+ | ← / → | The same weekday a week earlier or later (mirrored in right-to-left text). |
72
+ | Home / End | The first or last day of the period. |
73
+ | Enter, Space | `onSelectDay` with the focused day. |
74
+ | Escape | Hide the tooltip. |
75
+
76
+ ## Accessibility
77
+
78
+ - The grid is named by `label`; each day is a `gridcell` named with its count and full date ("12 commits, Wednesday, March 4, 2026"), so the shade is never the only way to read a day.
79
+ - Month and weekday names and the legend are hidden from assistive technology: every day's name says its date and count already.
80
+ - The tooltip repeats the day's name for pointer and keyboard users; it isn't announced.
81
+ - Keep the takeaway in `label` and the key numbers in text nearby: a year is 365 days to step through.
82
+
83
+ ## Words
84
+
85
+ The legend's ends and a day's count in words take `labels={{ less, more, count }}`, or app-wide the kit's `LocaleProvider messages={{ heatGraph: { … } }}`. `count(n, formatted)` receives the count and the count formatted in the locale. Month, weekday and date names, and the default week start, follow `LocaleProvider`'s locale.
86
+
87
+ ## Gotchas
88
+
89
+ - Dates are calendar days: `"2026-03-04"` is March 4 everywhere, and a `Date` is read as its local day. Pass days, not timestamps in UTC that may fall on the day before in the user's time zone.
90
+ - Counts must be numbers: a day missing from `data` counts as 0.
91
+ - With fluid cells in a narrow container, the cells get small: set `cellSize` and scroll instead.
92
+
93
+ ## API reference
94
+
95
+ <!-- generated:props:heat-graph (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
96
+
97
+ Generated from the types of `@zsherman/charts/heat-graph`. Each part also takes its element's native and ARIA attributes.
98
+
99
+ #### `HeatGraph`
100
+
101
+ | Prop | Type | Default | Description |
102
+ | --- | --- | --- | --- |
103
+ | `cellGap` | `number` | `3` | Space between cells in pixels. |
104
+ | `cellSize` | `number` | | A fixed cell size in pixels. Without it, cells share the width (a year needs about 700px). |
105
+ | `class` | `ClassValue` | | Extra classes on the root. |
106
+ | `color` | `ChartColor` | `"chart-1"` | The ramp's color, from a wash over the muted surface (level 1) to the full color (level 4). |
107
+ | `data` (required) | `readonly HeatGraphDatum[]` | | One entry per day (entries on the same day add up). Days without one count as 0. |
108
+ | `dayLabels` | `boolean` | `true` | Weekday names beside the rows (every other one). |
109
+ | `end` | `string \| Date` | | The last day shown. Defaults to the latest day in `data`. Set both to draw an empty period. |
110
+ | `label` (required) | `string` | | What the graph shows, for assistive technology: the measure, the period and the takeaway. |
111
+ | `labels` | `Partial<HeatGraphLabels>` | | The graph's words, in your wording or language (app-wide: `LocaleProvider messages.heatGraph`). |
112
+ | `legend` | `boolean` | `true` | The Less → More legend. |
113
+ | `monthLabels` | `boolean` | `true` | Month names over the weeks. |
114
+ | `onSelectDay` | `((day: HeatGraphDay) => void)` | | Called when a day is clicked or chosen with Enter or Space: open that day's activity. |
115
+ | `shape` | `"circle" \| "rounded" \| "square"` | `"rounded"` | The mark: `rounded` squares read as a calendar; `circle` pairs with `sizeEncoding="value"`. |
116
+ | `sizeEncoding` | `"fixed" \| "value"` | `"fixed"` | `"value"` sizes each mark by its count too (its area), so magnitude reads without the legend. A zero day keeps a small mark; the whole cell stays the hover and click target. |
117
+ | `start` | `string \| Date` | | The first day shown (`"2026-01-01"` or a `Date`). Defaults to the earliest day in `data`. |
118
+ | `thresholds` | `[number, number, number, number]` | | The lower bounds of levels 1–4, such as `[1, 5, 10, 20]`. Defaults to quarters of the busiest day. Fix them when graphs side by side must share a scale. |
119
+ | `weekStart` | `"monday" \| "sunday"` | | The weekday each column starts on. Defaults to the locale's (Monday in most, Sunday in the US). |
120
+
121
+ <!-- /generated:props:heat-graph -->
@@ -0,0 +1,108 @@
1
+ # Heat matrix
2
+
3
+ <!-- search: heat matrix, heatmap, heat map table, matrix, confusion matrix, correlation, from to, route latency, region to region, pairwise, cross table, pivot, cohort -->
4
+
5
+ A table of values between two sets of things (routes from one region to another, services by hour), each cell shaded on a five-step heat scale from cool to hot, with its value written on it. A real table: the headers name every cell for assistive technology. It's plain DOM, so it renders on the server.
6
+
7
+ ```tsx
8
+ import { HeatMatrix } from "@zsherman/charts/heat-matrix";
9
+
10
+ const regions = ["eu-central", "me-central", "us-east"];
11
+
12
+ <HeatMatrix
13
+ label="Route RTT, peak increase over the range minimum, from region to region"
14
+ corner="from \ to"
15
+ rows={regions}
16
+ columns={regions}
17
+ values={[
18
+ [0.1, 14.5, 4.6],
19
+ [14.6, 0.1, 9.8],
20
+ [4.6, 11.9, 0.1],
21
+ ]}
22
+ format={(v) => `${v.toFixed(1)} ms`}
23
+ muteDiagonal
24
+ />;
25
+ ```
26
+
27
+ ## Usage guidelines
28
+
29
+ - Use it when each value belongs to a pair (from × to, service × hour, cohort × week) and the question is which pairs stand out. The shade finds them; the written value says how much.
30
+ - Name it with `label`: what the cells measure, between what, over which period. Write the unit into `format` ("14.5 ms"), so every cell and the legend carry it.
31
+ - Higher is hotter: the scale is for values where more is worse (latency, loss, errors, load). For a value where more is better, show its shortfall instead (the error rate, not the success rate).
32
+ - Fix `thresholds` when the shades mean something ("over 20 ms is bad") or when matrices side by side must share a scale. Without them, the five steps split the data's range evenly, so the hottest cell is always red, even on a calm day.
33
+ - A pair of a thing with itself (a route to its own region) usually says nothing: `muteDiagonal` draws it muted and leaves it out of the scale.
34
+ - Keep it to a few dozen columns. Past what fits, it scrolls sideways (and takes focus, so the keyboard can scroll it); for values over many time steps, a [State timeline](./state-timeline.md) or a [Chart](./chart.md) reads better.
35
+
36
+ ## Anatomy
37
+
38
+ ```tsx
39
+ <HeatMatrix
40
+ label="…" // required: the table's accessible name
41
+ rows={["…"]} columns={["…"]} // the headers
42
+ values={[[…], […]]} // values[row][column]; null for none
43
+ corner="from \ to" // text over the row headers
44
+ format={(v) => …} // cell and legend text
45
+ thresholds={[5, 10, 15, 20]} // lower bounds of steps 2–5
46
+ muteDiagonal // a row meeting its own column: muted, out of the scale
47
+ legend // the steps and their ranges (on by default)
48
+ cellHeight={32}
49
+ labels={{ missing, empty, legend }}
50
+ />
51
+ ```
52
+
53
+ What renders: a root `div` (`data-slot="heat-matrix"`) with the scroller (`heat-matrix-scroller`: a focusable `region` named by `label` only while it scrolls) holding a `table` (`heat-matrix-table`, named by `label`): the corner cell (`heat-matrix-corner`), the column headers (`heat-matrix-column`, `th scope="col"`), and per row a row header (`heat-matrix-row`, `th scope="row"`) and the cells (`heat-matrix-cell`, with `data-step` 0–5 and `data-active` while hovered). Under it, the legend (`heat-matrix-legend`, a list of the steps), or `heat-matrix-empty` when there are no rows or columns.
54
+
55
+ ## The heat scale
56
+
57
+ Five steps, from pale yellow through amber and orange to red: `--sui-chart-heat-1` … `--sui-chart-heat-5`, each with a light and a dark value (a little dimmer in dark mode). Values on steps 1–4 are written in `--sui-chart-heat-text`, on step 5 in `--sui-chart-heat-text-inverse`; every pair is held to 4.5:1 in both schemes. Override the steps like any token, keeping their text readable:
58
+
59
+ ```css
60
+ :root {
61
+ --sui-chart-heat-5: oklch(0.5 0.16 15);
62
+ }
63
+ ```
64
+
65
+ A cell's step comes from `thresholds`, the lower bounds of steps 2 to 5: a value below the first is step 1, at or above the last is step 5. The default bounds split the range of the values (not counting muted or missing cells) into five even steps; when every value is the same, all are step 1 and the legend is left out. Missing values (`null`, `undefined`, `NaN`) and muted cells are step 0: the muted surface, a dash, and "No data" for assistive technology.
66
+
67
+ ## Accessibility
68
+
69
+ - It's a `table` named by `label`, with real column and row headers, so a screen reader announces "vultr-af-south, vultr-us-west-sea, 32.6 ms" as it moves through the cells. Shade is never the only cue: every value is written.
70
+ - Long column names wrap; long row names are cut short with an ellipsis, the full text in a `title`.
71
+ - When the columns don't fit, the scroller becomes a focusable region named by `label`, so the arrow keys scroll it.
72
+ - Hovering a cell rings it and sets its row and column headers apart.
73
+ - The shades keep their colors in forced-colors mode (they're data), with their text.
74
+
75
+ ## Words
76
+
77
+ `missing`, `empty` and `legend` take `labels`, or app-wide the kit's `LocaleProvider messages={{ heatMatrix: { … } }}`. Numbers follow `LocaleProvider`'s locale.
78
+
79
+ ## Gotchas
80
+
81
+ - `values[row][column]`, in the order of `rows` and `columns`. A short row leaves the rest of its cells missing.
82
+ - `muteDiagonal` compares the row's and the column's names: it mutes the cells where they're equal, wherever they are.
83
+ - The default steps follow the data, so the same value can change shade from one day to the next. Fix `thresholds` for a scale that means the same thing every time.
84
+
85
+ ## API reference
86
+
87
+ <!-- generated:props:heat-matrix (node tooling/props-doc.ts; edit the JSDoc in the source, not this table) -->
88
+
89
+ Generated from the types of `@zsherman/charts/heat-matrix`. Each part also takes its element's native and ARIA attributes.
90
+
91
+ #### `HeatMatrix`
92
+
93
+ | Prop | Type | Default | Description |
94
+ | --- | --- | --- | --- |
95
+ | `cellHeight` | `number` | `32` | A cell's height in pixels. |
96
+ | `class` | `ClassValue` | | Extra classes on the root. |
97
+ | `columns` (required) | `readonly string[]` | | The column headers, start to end ("to"). |
98
+ | `corner` | `Element` | | Text in the top corner, over the row headers: what the rows and columns are ("from \\ to"). |
99
+ | `format` | `((value: number) => string)` | | How values are written in the cells and the legend. Defaults to the locale's numbers. |
100
+ | `label` (required) | `string` | | The table's name: what the cells measure, between what, over which period ("Route RTT, peak increase"). |
101
+ | `labels` | `Partial<HeatMatrixLabels>` | | The words, in your wording or language (app-wide: `LocaleProvider messages.heatMatrix`). |
102
+ | `legend` | `boolean` | `true` | The scale's steps and their ranges under the matrix. |
103
+ | `muteDiagonal` | `boolean` | | Leave the cells where a row meets the column of the same name (a route to itself) out of the scale: they're drawn muted, and their values don't set the default steps. |
104
+ | `rows` (required) | `readonly string[]` | | The row headers, top to bottom ("from"). |
105
+ | `thresholds` | `[number, number, number, number]` | | The lower bounds of steps 2–5 of the heat scale, such as `[5, 10, 15, 20]`. Defaults to five even steps between the smallest and the largest value. Fix them when the shades mean something (over 20 ms is bad) or when matrices side by side must share a scale. |
106
+ | `values` (required) | `readonly (readonly (number \| null \| undefined)[])[]` | | The values, one array per row with one value per column (`values[row][column]`); `null` for none. |
107
+
108
+ <!-- /generated:props:heat-matrix -->
package/docs/llms.txt ADDED
@@ -0,0 +1,68 @@
1
+ # @zsherman/charts
2
+
3
+ > Charts for @zsherman/kit: line, area and bar charts (grouped or stacked), sparklines, grids of charts with one shared cursor, calendar heat graphs, stacked histograms with range zoom, status histories, row charts (horizontal bars per category, grouped or stacked), heat matrices, state timelines, and part-to-whole charts (bar lists, segmented bars, donuts). Charts are drawn by uPlot (fast enough for live data and tens of thousands of points); sparklines, heat graphs, histograms, status histories, row charts, heat matrices, state timelines, bar lists, segmented bars and donuts are plain SVG and DOM, rendered on the server. All are themed with the kit's `--sui-*` tokens and read out by keyboard. Your app does not need a StyleX compiler.
4
+
5
+ Read this file first, then the pages for what you use. These docs ship in the package, so they match the installed version.
6
+
7
+ ## Setup
8
+
9
+ ```sh
10
+ npm install @zsherman/charts @zsherman/kit solid-js@^2 @solidjs/web@^2
11
+ ```
12
+
13
+ Load both stylesheets once, in the app entry, the kit's first:
14
+
15
+ ```ts
16
+ import "@zsherman/kit/styles.css";
17
+ import "@zsherman/charts/styles.css";
18
+ ```
19
+
20
+ `@zsherman/charts/styles.css` carries the chart parts, uPlot's rules and the series colors (`--sui-chart-1` … `--sui-chart-8`), in the kit's cascade layers, so your own CSS wins without `!important`. Charts follow the kit's light and dark schemes (`data-color-scheme`, `<Theme scheme>`) and its `LocaleProvider` for number and date formats.
21
+
22
+ Common tasks:
23
+
24
+ - Values over time, several series: [chart.md#usage-guidelines](./chart.md#usage-guidelines)
25
+ - Bars per category, grouped or stacked: [chart.md#bars-and-categories](./chart.md#bars-and-categories)
26
+ - Live data at 20 updates a second: [chart.md#live-data](./chart.md#live-data)
27
+ - Your own tooltip content, or the cursor's point in your own code: [chart.md#tooltip-and-cursor](./chart.md#tooltip-and-cursor)
28
+ - Zoom into a range and reset it: [chart.md#zoom-and-selection](./chart.md#zoom-and-selection)
29
+ - Dates, units and fixed ranges on the axes: [chart.md#axes-and-formats](./chart.md#axes-and-formats)
30
+ - A chart that screen readers and keyboards can read: [chart.md#accessibility](./chart.md#accessibility)
31
+ - A trend line in a stat tile: [sparkline.md](./sparkline.md)
32
+ - A panel of charts with one cursor: [chart-grid.md](./chart-grid.md)
33
+ - Daily activity on a calendar (a contribution graph): [heat-graph.md](./heat-graph.md)
34
+ - Events per minute above a log list, and zooming to a range: [stacked-histogram.md](./stacked-histogram.md)
35
+ - A service's recent health, one bar per check (an uptime strip): [status-history.md](./status-history.md)
36
+ - Baseline vs candidate per host, before and after, with the change: [row-chart.md](./row-chart.md)
37
+ - Each row split into parts (user and kernel time), stacked horizontal bars: [row-chart.md#stacked-parts-of-each-row](./row-chart.md#stacked-parts-of-each-row)
38
+ - Values between pairs (region to region latency, service by hour), shaded cool to hot: [heat-matrix.md](./heat-matrix.md)
39
+ - Many routes or services over hours, each a lane of states (healthy, degraded, down): [state-timeline.md](./state-timeline.md)
40
+ - Top pages, top customers, a ranking with values and shares: [bar-list.md](./bar-list.md)
41
+ - One bar split by category or status, or storage used of a quota: [segmented-bar.md](./segmented-bar.md)
42
+ - Part-to-whole as a ring, with the legend as the way to read it: [donut.md](./donut.md)
43
+ - Colors and theming: [chart.md#colors](./chart.md#colors)
44
+
45
+ ## Entries
46
+
47
+ - `@zsherman/charts/chart` — `Chart` — [chart.md](./chart.md)
48
+ - `@zsherman/charts/sparkline` — `Sparkline` — [sparkline.md](./sparkline.md)
49
+ - `@zsherman/charts/chart-grid` — `ChartGrid` — [chart-grid.md](./chart-grid.md)
50
+ - `@zsherman/charts/heat-graph` — `HeatGraph` — [heat-graph.md](./heat-graph.md)
51
+ - `@zsherman/charts/stacked-histogram` — `StackedHistogram` — [stacked-histogram.md](./stacked-histogram.md)
52
+ - `@zsherman/charts/status-history` — `StatusHistory` — [status-history.md](./status-history.md)
53
+ - `@zsherman/charts/bar-list` — `BarList` — [bar-list.md](./bar-list.md)
54
+ - `@zsherman/charts/segmented-bar` — `SegmentedBar` — [segmented-bar.md](./segmented-bar.md)
55
+ - `@zsherman/charts/row-chart` — `RowChart` — [row-chart.md](./row-chart.md)
56
+ - `@zsherman/charts/heat-matrix` — `HeatMatrix` — [heat-matrix.md](./heat-matrix.md)
57
+ - `@zsherman/charts/state-timeline` — `StateTimeline` — [state-timeline.md](./state-timeline.md)
58
+ - `@zsherman/charts/donut` — `Donut`, `DonutLegend` — [donut.md](./donut.md)
59
+
60
+ `@zsherman/charts` re-exports all twelve. The types (`ChartData`, `ChartSeries`, `ChartController`, …) come from `@zsherman/charts/chart`.
61
+
62
+ ## Rules
63
+
64
+ - Chart and ChartGrid data is uPlot's aligned format: `[x, ...ys]`, one array per series, all the same length. On a time axis, x is Unix **seconds** (`date.getTime() / 1000`), not milliseconds. `null` is a missing reading.
65
+ - Every chart needs a `label`: the metric, the period and the main finding. The canvas has no other name.
66
+ - Keep line charts to five series or fewer; split a larger set into a `ChartGrid`.
67
+ - One y axis per chart. Two measures of different scales are two charts.
68
+ - A chart people must read exactly (rather than see the shape of) also shows its values in a table or text.