@nanahoshi/mona-ui 0.26.0 → 0.26.2

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.
@@ -0,0 +1,535 @@
1
+ # Heatmap
2
+
3
+ > A heatmap series that colors a grid of cells by value, with a color legend.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/chart`
6
+
7
+ **Selector:** `mona-heatmap-series`
8
+
9
+ A heatmap series draws a grid of cells, one column per X category and one row per Y category, and colors each cell by its value. It suits values that depend on two categories at once, such as activity by weekday and hour, or a measure by month and year. It goes inside a `mona-chart` on its own, with an X and a Y axis for the category labels and a legend that shows the color scale.
10
+
11
+ ## Overview
12
+
13
+ A heatmap answers "where is it high, and where is it low?" across two categories. Each row of data is one cell: a column, a row and a value, and the value picks the cell's color from a scale.
14
+
15
+ | Color mode | Use it for | Colors |
16
+ | :--- | :--- | :--- |
17
+ | `"sequential"` (default) | Amounts that run from low to high, such as visits, orders or load. | Two or more stops, from the lowest value to the highest. |
18
+ | `"diverging"` | Values that run both ways from a meaningful middle, such as a change, a difference from a target, or a temperature anomaly. | Exactly three stops: below, at and above the midpoint. |
19
+
20
+ **Use something else when:**
21
+
22
+ - Readers need to compare exact amounts. Color is hard to read precisely, so bars compare values better, see [Bar & Waterfall](chart-bar.md).
23
+ - One of the dimensions is continuous time and the trend matters more than the pattern. Use a line or area series, see [Line & Area](chart-line-area.md).
24
+ - Both dimensions are numbers and each point stands alone. Use a scatter or bubble series, see [Scatter & Bubble](chart-scatter.md).
25
+
26
+ The chart, axes, legend, tooltip and interaction parts the series sits in are described on [Chart Overview](chart.md).
27
+
28
+ ## Import & Quick Start
29
+
30
+ ```typescript
31
+ import {
32
+ ChartComponent,
33
+ ChartLegendComponent,
34
+ ChartTooltipComponent,
35
+ ChartXAxisComponent,
36
+ ChartYAxisComponent,
37
+ HeatmapSeriesComponent
38
+ } from "@nanahoshi/mona-ui/chart";
39
+ ```
40
+
41
+ ```html
42
+ <mona-chart aria-label="Visits by day and hour" class="h-80 w-full" xField="hour" [data]="visits">
43
+ <mona-chart-x-axis />
44
+ <mona-chart-y-axis />
45
+ <mona-heatmap-series field="visits" name="Visits" yField="day" />
46
+ <mona-chart-legend />
47
+ <mona-chart-tooltip />
48
+ </mona-chart>
49
+ ```
50
+
51
+ Each item of `visits` is one cell, such as `{ day: "Mon", hour: "09:00", visits: 42 }`. Give the chart a height. It fills its host, and a host without a height has none.
52
+
53
+ ## Anatomy
54
+
55
+ | Part | Input | Description |
56
+ | :--- | :--- | :--- |
57
+ | Columns | `xField`, `xCategories` | The X category of each row. The series' `xField` wins over the chart's. |
58
+ | Rows | `yField`, `yCategories` | The Y category of each row. Required. |
59
+ | Value | `field` | The number that colors the cell. Required. |
60
+ | Color scale | `colorMode`, `colors`, `color`, `min`, `max`, `midpoint` | How values become colors. |
61
+ | Cells | `cellGap`, `borderRadius`, `strokeColor`, `strokeWidth`, `fillOpacity`, `showValues` | How each cell is drawn. |
62
+ | Color legend | `mona-chart-legend` | A gradient bar with the lowest, highest and, in diverging mode, the midpoint value. |
63
+
64
+ The series reads the chart's `data` unless it has its own `data`. A field is a property name or an accessor, `(row, index) => value`.
65
+
66
+ ### Categories
67
+
68
+ Columns and rows appear in the order the data first uses them, left to right and top to bottom. `xCategories` and `yCategories` set the order instead:
69
+
70
+ - Listed categories come first, in the order given.
71
+ - A listed category with no data stays in the grid as an empty column or row.
72
+ - A category in the data but missing from the list is added after the listed ones.
73
+
74
+ A category is a string, a finite number, a boolean or a date. `"5"` and `5` are different categories. Dates are shown as numeric dates in the library locale; use the axis `formatter` to show them another way.
75
+
76
+ ### Templates
77
+
78
+ The heatmap has no templates of its own. The tooltip, legend item, title, subtitle and no-data templates work as described on [Chart Overview](chart.md). The tooltip context of a cell has `formattedXValue` for its column, `formattedYCategory` for its row, `formattedY` for its formatted value and `color` for its fill. Axis label templates aren't used by heatmap axes.
79
+
80
+ ## Examples
81
+
82
+ ### Weekly activity
83
+
84
+ A sequential scale from the theme's first chart color, with `showValues` writing each value inside its cell.
85
+
86
+ `weekly-activity-example.component.ts`
87
+
88
+ ```typescript
89
+ import { Component } from "@angular/core";
90
+ import {
91
+ ChartComponent,
92
+ ChartLegendComponent,
93
+ ChartTooltipComponent,
94
+ ChartXAxisComponent,
95
+ ChartYAxisComponent,
96
+ HeatmapSeriesComponent
97
+ } from "@nanahoshi/mona-ui/chart";
98
+
99
+ const DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
100
+ const SLOTS = ["00h", "02h", "04h", "06h", "08h", "10h", "12h", "14h", "16h", "18h", "20h", "22h"];
101
+
102
+ @Component({
103
+ selector: "app-chart-heatmap-weekly-activity-example",
104
+ imports: [
105
+ ChartComponent,
106
+ ChartLegendComponent,
107
+ ChartTooltipComponent,
108
+ ChartXAxisComponent,
109
+ ChartYAxisComponent,
110
+ HeatmapSeriesComponent
111
+ ],
112
+ templateUrl: "./weekly-activity-example.component.html"
113
+ })
114
+ export class ChartHeatmapWeeklyActivityExampleComponent {
115
+ /** One row per cell: the day, the two-hour slot and the number of orders placed in it. */
116
+ protected readonly orders = DAYS.flatMap((day, dayIndex) =>
117
+ SLOTS.map((slot, slotIndex) => {
118
+ const weekend = dayIndex >= 5;
119
+ const peak = weekend ? 7 : 6;
120
+ const orders = Math.round(
121
+ 4 + 46 * Math.exp(-((slotIndex - peak) ** 2) / (weekend ? 6 : 3)) + ((dayIndex + slotIndex) % 5)
122
+ );
123
+ return { day, orders, slot };
124
+ })
125
+ );
126
+ }
127
+ ```
128
+
129
+ `weekly-activity-example.component.html`
130
+
131
+ ```html
132
+ <mona-chart aria-label="Orders by day and time" class="h-80 w-full" xField="slot" [data]="orders">
133
+ <mona-chart-x-axis title="Time of day" />
134
+ <mona-chart-y-axis />
135
+ <mona-heatmap-series field="orders" name="Orders" yField="day" [showValues]="true" />
136
+ <mona-chart-legend />
137
+ <mona-chart-tooltip />
138
+ </mona-chart>
139
+ ```
140
+
141
+ ### Diverging scale
142
+
143
+ `colorMode="diverging"` with three `colors` centers the scale on `midpoint`, so values below and above it read as opposites. The legend sits at the end and shows the midpoint, and `valueFormatter` adds the sign and the unit.
144
+
145
+ `diverging-example.component.ts`
146
+
147
+ ```typescript
148
+ import { Component } from "@angular/core";
149
+ import {
150
+ ChartComponent,
151
+ ChartLegendComponent,
152
+ ChartTooltipComponent,
153
+ ChartXAxisComponent,
154
+ ChartYAxisComponent,
155
+ HeatmapSeriesComponent
156
+ } from "@nanahoshi/mona-ui/chart";
157
+ import type { ChartValueFormatter } from "@nanahoshi/mona-ui/chart";
158
+
159
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
160
+ const YEARS = [2019, 2020, 2021, 2022, 2023, 2024, 2025];
161
+
162
+ @Component({
163
+ selector: "app-chart-heatmap-diverging-example",
164
+ imports: [
165
+ ChartComponent,
166
+ ChartLegendComponent,
167
+ ChartTooltipComponent,
168
+ ChartXAxisComponent,
169
+ ChartYAxisComponent,
170
+ HeatmapSeriesComponent
171
+ ],
172
+ templateUrl: "./diverging-example.component.html"
173
+ })
174
+ export class ChartHeatmapDivergingExampleComponent {
175
+ /** Each month's difference from the long-term average, in °C. */
176
+ protected readonly anomalies = YEARS.flatMap((year, yearIndex) =>
177
+ MONTHS.map((month, monthIndex) => ({
178
+ anomaly: Math.round((yearIndex * 0.35 - 1 + Math.sin(monthIndex * 1.3 + yearIndex) * 0.9) * 10) / 10,
179
+ month,
180
+ year
181
+ }))
182
+ );
183
+ /** Blue below the long-term average, white at it and red above. */
184
+ protected readonly colors = ["#2166ac", "#f7f7f7", "#b2182b"];
185
+ protected readonly signedCelsius: ChartValueFormatter = value => {
186
+ const degrees = Number(value);
187
+ return `${degrees > 0 ? "+" : ""}${degrees.toFixed(1)} °C`;
188
+ };
189
+ }
190
+ ```
191
+
192
+ `diverging-example.component.html`
193
+
194
+ ```html
195
+ <mona-chart aria-label="Monthly temperature anomaly by year" class="h-80 w-full" xField="month" [data]="anomalies">
196
+ <mona-chart-x-axis />
197
+ <mona-chart-y-axis />
198
+ <mona-heatmap-series
199
+ colorMode="diverging"
200
+ field="anomaly"
201
+ name="Difference from average"
202
+ yField="year"
203
+ [colors]="colors"
204
+ [midpoint]="0"
205
+ [valueFormatter]="signedCelsius" />
206
+ <mona-chart-legend position="end" />
207
+ <mona-chart-tooltip />
208
+ </mona-chart>
209
+ ```
210
+
211
+ ### Ordered categories and cell clicks
212
+
213
+ `xCategories` and `yCategories` fix the order of the columns and rows and keep a week with no data as an empty column. The chart's `pointClick` reports the clicked cell, also when the user presses Enter on it.
214
+
215
+ `cell-details-example.component.ts`
216
+
217
+ ```typescript
218
+ import { Component, signal } from "@angular/core";
219
+ import {
220
+ ChartComponent,
221
+ ChartTooltipComponent,
222
+ ChartXAxisComponent,
223
+ ChartYAxisComponent,
224
+ HeatmapSeriesComponent
225
+ } from "@nanahoshi/mona-ui/chart";
226
+ import type { ChartPointEvent } from "@nanahoshi/mona-ui/chart";
227
+
228
+ @Component({
229
+ selector: "app-chart-heatmap-cell-details-example",
230
+ imports: [ChartComponent, ChartTooltipComponent, ChartXAxisComponent, ChartYAxisComponent, HeatmapSeriesComponent],
231
+ templateUrl: "./cell-details-example.component.html"
232
+ })
233
+ export class ChartHeatmapCellDetailsExampleComponent {
234
+ /** Pull requests reviewed by each team per week. Mobile has no reviews in week 3, so that cell stays empty. */
235
+ protected readonly reviews = [
236
+ { reviews: 14, team: "Web", week: "W1" },
237
+ { reviews: 9, team: "Web", week: "W2" },
238
+ { reviews: 17, team: "Web", week: "W3" },
239
+ { reviews: 21, team: "Web", week: "W4" },
240
+ { reviews: 6, team: "Mobile", week: "W1" },
241
+ { reviews: 11, team: "Mobile", week: "W2" },
242
+ { reviews: 8, team: "Mobile", week: "W4" },
243
+ { reviews: 3, team: "Platform", week: "W2" },
244
+ { reviews: 5, team: "Platform", week: "W3" },
245
+ { reviews: 12, team: "Platform", week: "W4" },
246
+ { reviews: 4, team: "Platform", week: "W1" }
247
+ ];
248
+ protected readonly selected = signal("Click a cell, or move to one with the arrow keys and press Enter.");
249
+ /** The rows in this order, top to bottom, whatever order the data comes in. */
250
+ protected readonly teams = ["Platform", "Web", "Mobile"];
251
+ /** The columns, including a week with no data yet, which stays an empty column. */
252
+ protected readonly weeks = ["W1", "W2", "W3", "W4", "W5"];
253
+
254
+ protected onPointClick(event: ChartPointEvent): void {
255
+ this.selected.set(`${event.formattedYCategory}, ${event.formattedXValue}: ${event.yValue} reviews`);
256
+ }
257
+ }
258
+ ```
259
+
260
+ `cell-details-example.component.html`
261
+
262
+ ```html
263
+ <div class="flex w-full flex-col gap-3">
264
+ <mona-chart
265
+ aria-label="Code reviews by team and week"
266
+ class="h-64 w-full"
267
+ xField="week"
268
+ [data]="reviews"
269
+ (pointClick)="onPointClick($event)">
270
+ <mona-chart-x-axis />
271
+ <mona-chart-y-axis />
272
+ <mona-heatmap-series
273
+ color="#7c3aed"
274
+ field="reviews"
275
+ name="Reviews"
276
+ yField="team"
277
+ [borderRadius]="6"
278
+ [cellGap]="4"
279
+ [showValues]="true"
280
+ [xCategories]="weeks"
281
+ [yCategories]="teams" />
282
+ <mona-chart-tooltip />
283
+ </mona-chart>
284
+ <p aria-live="polite" class="text-sm text-muted-foreground">{{ selected() }}</p>
285
+ </div>
286
+ ```
287
+
288
+ ## Appearance & Styling
289
+
290
+ | Input | Values | Effect |
291
+ | :--- | :--- | :--- |
292
+ | `colorMode` | `"sequential"`, `"diverging"` | Whether the scale runs from low to high, or both ways from `midpoint`. |
293
+ | `colors` | An array of CSS colors | The color stops. Sequential takes two or more, spread evenly from the lowest value to the highest. Diverging takes exactly three. A stop may be a CSS variable, such as `"var(--color-chart-2)"`. |
294
+ | `color` | Any CSS color | Without `colors`, the high end of a sequential scale. It defaults to `--color-chart-1`. Diverging ignores it. |
295
+ | `min`, `max` | Numbers | The ends of the scale. Values beyond them take the end color. |
296
+ | `midpoint` | A number | The value at the middle color of a diverging scale. |
297
+ | `cellGap` | Pixels, default `1` | The space between cells. |
298
+ | `borderRadius` | Pixels, default `2` | The corner radius of each cell, at most half its size. |
299
+ | `strokeColor`, `strokeWidth` | A CSS color, pixels | A border around each cell. It needs both. |
300
+ | `fillOpacity` | `0` to `1`, default `1` | The opacity of the cells. |
301
+ | `showValues` | `boolean` | Writes each formatted value inside its cell. |
302
+
303
+ Colors between the stops are blended in the OKLab color space, so a ramp changes evenly in lightness. Without `colors`, a sequential scale runs from a pale blue to `color`, and a diverging one from blue through near-white to red.
304
+
305
+ - **Value labels** take white or a dark color, whichever contrasts more with the cell. A label is left out when its cell is too small for it.
306
+ - **Grid lines** between the columns and rows come from the axes. Turn them off with `[gridLines]="false"` on an axis.
307
+ - **Axis labels** are thinned when the columns or rows are too narrow for all of them, and the last one is always kept.
308
+
309
+ ## Theming
310
+
311
+ These CSS variables, set on the series or on the chart, change the heatmap's defaults. An input with a value wins over its variable.
312
+
313
+ | Variable | Default | Effect |
314
+ | :--- | :--- | :--- |
315
+ | `--mona-chart-heatmap-low-color` | A pale blue, or blue in diverging mode | The lowest color when there are no `colors`. |
316
+ | `--mona-chart-heatmap-mid-color` | Near-white | The middle color of a diverging scale when there are no `colors`. |
317
+ | `--mona-chart-heatmap-high-color` | `color`, or red in diverging mode | The highest color when there are no `colors`. It wins over `color`. |
318
+ | `--mona-chart-heatmap-cell-border-color` | None | The border color, like `strokeColor`. |
319
+ | `--mona-chart-heatmap-cell-border-width` | `0` | The border width, like `strokeWidth`. |
320
+ | `--mona-chart-heatmap-cell-radius` | `2` | The corner radius, like `borderRadius`. |
321
+ | `--mona-chart-heatmap-fill-opacity` | `1` | The cell opacity, like `fillOpacity`. |
322
+ | `--mona-chart-heatmap-hover-outline-color` | `--color-border-control` | The outline of the cell under the pointer. |
323
+
324
+ The grid lines use `--mona-chart-grid-color`, and the focused cell's outline uses `--color-ring`.
325
+
326
+ ## Behavior
327
+
328
+ ### One heatmap per chart
329
+
330
+ A chart draws one heatmap and nothing else. With a second heatmap, or with another kind of series beside it, the chart draws nothing and a development warning says why. The axes are always category axes: an axis `type` other than `"auto"` or `"category"` is treated as a category axis, with a development warning.
331
+
332
+ ### Value domain
333
+
334
+ - Without `min` and `max`, the scale runs from the lowest to the highest value in the data.
335
+ - With only one of them, the other end comes from the data, and the scale still covers the bound you set.
336
+ - When `min` is greater than `max`, they are swapped.
337
+ - When every value is the same, every cell takes the middle color of the scale.
338
+
339
+ ### Diverging midpoint
340
+
341
+ Without `midpoint`, the midpoint is `0` when the values run both below and above zero, and halfway between the ends otherwise. A `midpoint` outside the domain is ignored, with a development warning. Each side of the midpoint uses its own half of the scale, so the lowest value always takes the first color and the highest value the last, however far each is from the midpoint.
342
+
343
+ ### Invalid colors
344
+
345
+ Sequential mode needs at least two valid colors and diverging mode exactly three. Otherwise the series uses its default colors and a development warning says why.
346
+
347
+ ### Missing and duplicate values
348
+
349
+ - A row whose value is `null`, `undefined` or not a finite number adds its categories but no cell, so its place stays empty.
350
+ - A row without a valid X or Y category is skipped.
351
+ - When two rows land on the same cell, the first one is kept and a development warning names the cell.
352
+ - When there are no cells to draw, or the series is hidden, the chart shows its no-data message.
353
+
354
+ ### Value formatting
355
+
356
+ `valueFormatter` formats a cell's value in its label, the tooltip, the color legend, the data table and screen reader announcements. Without it, values follow the library locale, and values of 1,000 or more are shortened, as in `1.2K`. The axis `formatter` formats the column and row names, on the axis and in the tooltip and announcements.
357
+
358
+ ### Color legend
359
+
360
+ `mona-chart-legend` shows the color scale by default, with `mode="auto"`. Its title is the series `name`. At `start`, `end`, `left` or `right` it is a vertical bar. While the series is hidden or has nothing to draw, the legend shows a series entry instead, so the user can show the series again. `mode="series"` always shows that entry, and `mode="color"` asks for the color scale.
361
+
362
+ ### Tooltips and clicks
363
+
364
+ The tooltip shows the series name, the cell's column and row, and its value. A heatmap tooltip always describes one cell, so `shared` has no effect.
365
+
366
+ The chart's `pointClick` emits a `ChartPointEvent` for the clicked cell: `xValue` is its column, `yCategory` its row, `yValue` its value and `datum` the row of data, with `formattedXValue` and `formattedYCategory` as shown. `HeatmapCellClickEvent` is deprecated, since nothing emits it.
367
+
368
+ ### Animation and identity
369
+
370
+ When the data changes and the columns and rows stay the same, each cell animates to its new color. When the categories change, the old grid cross-fades into the new one. A cell is matched across updates by its column and row; `keyField` adds your own key to that, so a cell whose key changes fades out and in instead of changing color.
371
+
372
+ The heatmap is never downsampled.
373
+
374
+ ### Two-way binding
375
+
376
+ `[(visible)]` holds whether the series is shown. The legend sets it when the user toggles the series entry.
377
+
378
+ ## Accessibility
379
+
380
+ The chart is the focusable element, and the heatmap adds no roles of its own. When a cell is focused, the chart announces the series name, the column and row, each after its axis title when the axis has one, and the formatted value. Give the series a `name`, give the axes a `title` when the categories don't explain themselves, and use `valueFormatter` to add a unit.
381
+
382
+ - **Don't rely on color alone.** Turn on `showValues` when the cells are large enough, keep the tooltip, and consider `dataTable` on the chart, which lists each column as a row with a cell per heatmap row.
383
+ - **Pick ramps that change in lightness.** A sequential ramp from light to dark, or a diverging ramp with a pale middle, stays readable for color-blind readers and in grayscale. Avoid red to green.
384
+ - **The color legend is described in words.** Its accessible name is the series name and the range, such as "Visits, 3 to 120", and includes the midpoint in diverging mode.
385
+
386
+ ### Keyboard Navigation
387
+
388
+ | Key | Action |
389
+ | :--- | :--- |
390
+ | `ArrowRight` / `ArrowLeft` | Move to the next or previous cell in the row, skipping empty cells. |
391
+ | `ArrowDown` / `ArrowUp` | Move to the next or previous cell in the column, skipping empty cells. |
392
+ | `Home` / `End` | Move to the first or last cell in the row. |
393
+ | `Ctrl` + `Home` / `Ctrl` + `End` (`Cmd` on macOS) | Move to the first or last cell of the grid. |
394
+ | `Enter` / `Space` | Activate the focused cell, which emits `pointClick`. |
395
+
396
+ The first arrow key, `Home` or `End` focuses the first or last cell. The rest of the keys are listed on [Chart Overview](chart.md).
397
+
398
+ ## API
399
+
400
+ Everything below is imported from `@nanahoshi/mona-ui/chart`.
401
+
402
+ ### `HeatmapSeriesComponent`
403
+
404
+ Renders a matrix of cells colored by value, with a color scale in the legend.
405
+
406
+ **Selector:** `mona-heatmap-series`
407
+
408
+ #### Inputs
409
+
410
+ | Name | Type | Default | Description |
411
+ | --- | --- | --- | --- |
412
+ | `borderRadius` | `number \| undefined` | `undefined` | Corner radius in pixels for each individual heat cell. |
413
+ | `cellGap` | `number` | `1` | Spacing gap in pixels between adjacent cells. |
414
+ | `class` | `string` | `""` | Additional CSS classes applied to the series host element. |
415
+ | `color` | `string` | `""` | Explicit primary base color used to derive the heat palette. |
416
+ | `colorMode` | `ChartHeatmapColorMode` | `"sequential"` | Color scale mapping mode: 'sequential' for continuous single-hue intensity or 'diverging' for dual-pole deviations. |
417
+ | `colors` | `readonly string[] \| undefined` | `undefined` | Explicit array of color stops defining the gradient palette. |
418
+ | `data` | `readonly unknown[] \| undefined` | `undefined` | Series-specific dataset overriding root chart data. |
419
+ | `field` (required) | `ChartField` | — | Property key or accessor extracting the numeric heat value for each cell. |
420
+ | `fillOpacity` | `number \| undefined` | `undefined` | Fill opacity applied to the heat cells (0 to 1). |
421
+ | `keyField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting a stable datum identity across updates. |
422
+ | `max` | `number \| undefined` | `undefined` | Explicit upper bound for the numeric value color domain. |
423
+ | `midpoint` | `number \| undefined` | `undefined` | Explicit central midpoint for diverging color scales. |
424
+ | `min` | `number \| undefined` | `undefined` | Explicit lower bound for the numeric value color domain. |
425
+ | `name` | `string` | `"Heatmap"` | Name of the series displayed in legends, tooltips, and live region announcements. |
426
+ | `showValues` | `boolean` | `false` | Whether to render numeric value labels inside individual heat cells on Canvas. |
427
+ | `strokeColor` | `string` | `""` | Explicit border stroke color for individual heat cells. |
428
+ | `strokeWidth` | `number \| undefined` | `undefined` | Stroke width in pixels for cell borders. |
429
+ | `valueFormatter` | `ChartValueFormatter \| undefined` | `undefined` | Custom formatter for raw cell values in labels, tooltips, and live regions. |
430
+ | `visible` (two-way) | `boolean` | `true` | Whether the series is currently visible on the chart and in calculations. |
431
+ | `xCategories` | `readonly unknown[] \| undefined` | `undefined` | Explicit category ordering for the X axis columns. |
432
+ | `xField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting the X column category for each cell. |
433
+ | `yCategories` | `readonly unknown[] \| undefined` | `undefined` | Explicit category ordering for the Y axis rows. |
434
+ | `yField` (required) | `ChartField` | — | Property key or accessor extracting the Y row category for each cell. |
435
+
436
+ #### Outputs
437
+
438
+ | Name | Type | Description |
439
+ | --- | --- | --- |
440
+ | `visibleChange` | `boolean` | Emitted when `visible` changes. |
441
+
442
+ ### Types
443
+
444
+ #### `ChartColorLegendScale`
445
+
446
+ | Name | Type |
447
+ | --- | --- |
448
+ | `formattedMax` (read-only) | `string` |
449
+ | `formattedMidpoint?` (read-only) | `string` |
450
+ | `formattedMin` (read-only) | `string` |
451
+ | `kind` (read-only) | `"color"` |
452
+ | `midpoint?` (read-only) | `number` |
453
+ | `mode` (read-only) | `ChartHeatmapColorMode` |
454
+ | `stops` (read-only) | `readonly ChartColorLegendStop[]` |
455
+ | `ticks` (read-only) | `readonly ChartColorLegendTick[]` |
456
+ | `title` (read-only) | `string` |
457
+
458
+ #### `ChartColorLegendStop`
459
+
460
+ | Name | Type |
461
+ | --- | --- |
462
+ | `color` (read-only) | `string` |
463
+ | `offset` (read-only) | `number` |
464
+ | `value` (read-only) | `number` |
465
+
466
+ #### `ChartColorLegendTick`
467
+
468
+ | Name | Type |
469
+ | --- | --- |
470
+ | `formattedValue` (read-only) | `string` |
471
+ | `offset` (read-only) | `number` |
472
+ | `value` (read-only) | `number` |
473
+
474
+ #### `ChartHeatmapCategory`
475
+
476
+ | Name | Type |
477
+ | --- | --- |
478
+ | `formattedValue` (read-only) | `string` |
479
+ | `index` (read-only) | `number` |
480
+ | `key` (read-only) | `string` |
481
+ | `value` (read-only) | `unknown` |
482
+
483
+ #### `ChartHeatmapCellData`
484
+
485
+ **Type parameters:** `TDatum = unknown`
486
+
487
+ | Name | Type |
488
+ | --- | --- |
489
+ | `categoryX` (read-only) | `string` |
490
+ | `categoryY` (read-only) | `string` |
491
+ | `datum` (read-only) | `TDatum` |
492
+ | `formattedValue` (read-only) | `string` |
493
+ | `formattedX` (read-only) | `string` |
494
+ | `formattedY` (read-only) | `string` |
495
+ | `numericValue` (read-only) | `number \| null` |
496
+ | `rawValue` (read-only) | `unknown` |
497
+ | `xIndex` (read-only) | `number` |
498
+ | `yIndex` (read-only) | `number` |
499
+
500
+ #### `HeatmapCellClickEvent`
501
+
502
+ **Deprecated.** Nothing emits this. Use `pointClick` on the chart.
503
+
504
+ **Type parameters:** `T = unknown`
505
+
506
+ | Name | Type |
507
+ | --- | --- |
508
+ | `categoryX` (read-only) | `string` |
509
+ | `categoryY` (read-only) | `string` |
510
+ | `datum` (read-only) | `T` |
511
+ | `formattedValue` (read-only) | `string` |
512
+ | `rawValue` (read-only) | `unknown` |
513
+ | `seriesId` (read-only) | `string` |
514
+ | `seriesName` (read-only) | `string` |
515
+ | `seriesType` (read-only) | `"heatmap"` |
516
+ | `value` (read-only) | `number \| null` |
517
+ | `xIndex` (read-only) | `number` |
518
+ | `yIndex` (read-only) | `number` |
519
+
520
+ #### `HeatmapColorStop`
521
+
522
+ **Deprecated.** No chart input takes this.
523
+
524
+ | Name | Type |
525
+ | --- | --- |
526
+ | `color` (read-only) | `string` |
527
+ | `offset` (read-only) | `number` |
528
+
529
+ #### `ChartHeatmapColorMode`
530
+
531
+ ```typescript
532
+ type ChartHeatmapColorMode = "diverging" | "sequential";
533
+ ```
534
+
535
+ **Documented elsewhere:** [`ChartField`](chart.md), [`ChartValueFormatter`](chart.md)