@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,714 @@
1
+ # Bar & Waterfall
2
+
3
+ > Bar, range bar and waterfall series for comparing values, intervals and running totals.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/chart`
6
+
7
+ **Selectors:** `mona-bar-series`, `mona-range-bar-series`, `mona-waterfall-series`
8
+
9
+ Bar, range bar and waterfall series draw one rectangle per category. A bar compares an amount across categories, side by side with other series or stacked into a total, a range bar spans a low and a high value, and a waterfall walks a running total through increases, decreases, subtotals and a total. Bars and range bars can lie horizontally, and upright ones share a chart with the other Cartesian series. A waterfall has its chart to itself.
10
+
11
+ ## Overview
12
+
13
+ Pick the series by what the reader should compare.
14
+
15
+ | Series | Use it for | Reads |
16
+ | :--- | :--- | :--- |
17
+ | `mona-bar-series` | Amounts across categories, such as revenue per region. Several series sit side by side, or stack into a total or into shares of 100%. | `field` |
18
+ | `mona-range-bar-series` | An interval per category, such as a day's low and high, a price span or a tolerance. | `fromField`, `toField` |
19
+ | `mona-waterfall-series` | How a starting value becomes a final one through increases and decreases, such as a profit and loss bridge or a cash flow. | `field`, `kindField` |
20
+
21
+ Lay bars horizontally when the category names are long or there are many of them, as in a ranking. They're easier to read along a row than rotated under a column.
22
+
23
+ **Use something else when:**
24
+
25
+ - The X values are a continuous measure, such as dates you want spaced by time, and the shape of the change matters. Use a line or area series, see [Line & Area](chart-line-area.md).
26
+ - The values are the parts of one whole and there are only a few of them. Use a pie or donut, see [Pie & Donut](chart-pie.md).
27
+ - The stages narrow from one to the next, as in a sales pipeline. Use a funnel, see [Funnel](chart-funnel.md).
28
+ - You need the open, high, low and close of each period. Use a candlestick or OHLC series, see [Financial](chart-financial.md).
29
+
30
+ The chart, axes, legend, tooltip and interaction parts these series sit in are described on [Chart Overview](chart.md).
31
+
32
+ ## Import & Quick Start
33
+
34
+ ```typescript
35
+ import {
36
+ BarSeriesComponent,
37
+ ChartComponent,
38
+ ChartLegendComponent,
39
+ ChartTooltipComponent,
40
+ ChartXAxisComponent,
41
+ ChartYAxisComponent
42
+ } from "@nanahoshi/mona-ui/chart";
43
+ ```
44
+
45
+ ```html
46
+ <mona-chart aria-label="Revenue by region" class="h-72 w-full" xField="region" [data]="revenue">
47
+ <mona-chart-x-axis />
48
+ <mona-chart-y-axis />
49
+ <mona-bar-series field="total" name="Revenue" />
50
+ <mona-chart-legend />
51
+ <mona-chart-tooltip />
52
+ </mona-chart>
53
+ ```
54
+
55
+ Give the chart a height. It fills its host, and a host without a height has none.
56
+
57
+ ## Anatomy
58
+
59
+ Each series reads its rows from the chart's `data`, unless it has its own `data`. It takes the category from the chart's `xField`, or from its own `xField`, and the value from `field`, or from `fromField` and `toField` for a range bar. A field is a property name or an accessor, `(row, index) => value`.
60
+
61
+ | Input | Bar | Range bar | Waterfall |
62
+ | :--- | :---: | :---: | :---: |
63
+ | `field` | ✓ | | ✓ (default `"value"`) |
64
+ | `fromField`, `toField` | | ✓ (required) | |
65
+ | `kindField`, `startValue` | | | ✓ |
66
+ | `orientation` | ✓ | ✓ | |
67
+ | `stack`, `stackMode` | ✓ | | |
68
+ | `color` | ✓ | ✓ | |
69
+ | `increaseColor`, `decreaseColor`, `neutralColor`, `subtotalColor`, `totalColor` | | | ✓ |
70
+ | `borderRadius`, `fillOpacity`, `maxBarWidth`, `valueFormatter` | ✓ | ✓ | ✓ |
71
+ | `dataLabels` | ✓ | ✓ | |
72
+ | `showLabels`, `maxLabels`, `minLabelWidth` | | | ✓ |
73
+ | `showConnectors`, `connectorColor`, `connectorWidth`, `strokeColor`, `strokeWidth` | | | ✓ |
74
+ | `xAxisId`, `yAxisId` | ✓ | ✓ | |
75
+
76
+ ### Waterfall steps
77
+
78
+ Each waterfall row is a step, and `kindField` (default `"kind"`) says what kind:
79
+
80
+ | Kind | Draws | Reads `field` |
81
+ | :--- | :--- | :--- |
82
+ | `"change"`, or no kind | A floating bar from the running total to the running total plus the value. Positive values are increases, negative ones decreases, and zero is no change. | Yes |
83
+ | `"subtotal"` | A bar from zero to the running total so far. The running total carries on after it. | No |
84
+ | `"total"` | The same bar as a subtotal, in the total color. Use it for the final result. | No |
85
+
86
+ The running total starts at `startValue`, which is `0` by default. The kind is matched without regard to case or surrounding spaces, and an unknown kind counts as a change, with a development warning.
87
+
88
+ ### Templates
89
+
90
+ - `ng-template[monaChartDataLabel]`, inside a bar or range bar series, replaces the text of its data labels. The context is a `ChartDataLabelContext`, with `formattedValue`, `value`, `datum`, the stack values (`stackTotal`, `stackPercentage`) and, for a range bar, `fromValue`, `toValue`, `formattedFrom` and `formattedTo`. Turn `dataLabels` on as well.
91
+ - `ng-template[monaChartWaterfallLabelTemplate]`, inside a waterfall series, replaces the text of its step labels. The context is a `ChartWaterfallLabelTemplateContext`: `let-step` gives the step, with `kind`, `visualKind`, `value`, `deltaValue`, `cumulativeBefore`, `cumulativeAfter`, their formatted versions and `datum`. Turn `showLabels` on as well.
92
+ - The chart, axis, legend and tooltip templates are described on [Chart Overview](chart.md).
93
+
94
+ ## Examples
95
+
96
+ ### Stacked bars
97
+
98
+ Bar series with the same `stack` name stack on top of each other, in the order they're declared, and `valueFormatter` adds the unit to the tooltip. Without `stack`, the same series would stand side by side in each quarter.
99
+
100
+ `bar-example.component.ts`
101
+
102
+ ```typescript
103
+ import { Component } from "@angular/core";
104
+ import {
105
+ BarSeriesComponent,
106
+ ChartComponent,
107
+ ChartLegendComponent,
108
+ ChartTooltipComponent,
109
+ ChartXAxisComponent,
110
+ ChartYAxisComponent
111
+ } from "@nanahoshi/mona-ui/chart";
112
+
113
+ @Component({
114
+ selector: "app-chart-bar-bar-example",
115
+ imports: [
116
+ BarSeriesComponent,
117
+ ChartComponent,
118
+ ChartLegendComponent,
119
+ ChartTooltipComponent,
120
+ ChartXAxisComponent,
121
+ ChartYAxisComponent
122
+ ],
123
+ templateUrl: "./bar-example.component.html"
124
+ })
125
+ export class ChartBarExampleComponent {
126
+ protected readonly sales = [
127
+ { americas: 120, asia: 95, europe: 80, quarter: "Q1" },
128
+ { americas: 135, asia: 110, europe: 92, quarter: "Q2" },
129
+ { americas: 128, asia: 124, europe: 101, quarter: "Q3" },
130
+ { americas: 150, asia: 138, europe: 115, quarter: "Q4" }
131
+ ];
132
+
133
+ protected thousands = (value: unknown): string => `$${String(value)}k`;
134
+ }
135
+ ```
136
+
137
+ `bar-example.component.html`
138
+
139
+ ```html
140
+ <mona-chart aria-label="Quarterly sales by region" class="h-72 w-full" xField="quarter" [data]="sales">
141
+ <mona-chart-x-axis />
142
+ <mona-chart-y-axis title="Sales" />
143
+ <mona-bar-series field="americas" name="Americas" stack="sales" [valueFormatter]="thousands" />
144
+ <mona-bar-series field="europe" name="Europe" stack="sales" [valueFormatter]="thousands" />
145
+ <mona-bar-series field="asia" name="Asia" stack="sales" [borderRadius]="4" [valueFormatter]="thousands" />
146
+ <mona-chart-legend position="bottom" />
147
+ <mona-chart-tooltip />
148
+ </mona-chart>
149
+ ```
150
+
151
+ ### Horizontal bars
152
+
153
+ `orientation="horizontal"` lays the bars along the X axis, which becomes the value axis, and puts the categories on the Y axis. Long names stay readable. `maxBarWidth` keeps a few bars from growing too thick, and `dataLabels` writes each value at the end of its bar.
154
+
155
+ `horizontal-example.component.ts`
156
+
157
+ ```typescript
158
+ import { Component, signal } from "@angular/core";
159
+ import {
160
+ BarSeriesComponent,
161
+ ChartComponent,
162
+ ChartTooltipComponent,
163
+ ChartXAxisComponent,
164
+ ChartYAxisComponent
165
+ } from "@nanahoshi/mona-ui/chart";
166
+ import type { ChartBarOrientation } from "@nanahoshi/mona-ui/chart";
167
+ import { SegmentedComponent } from "@nanahoshi/mona-ui/segmented";
168
+ import type { SegmentedOption } from "@nanahoshi/mona-ui/segmented";
169
+
170
+ @Component({
171
+ selector: "app-chart-bar-horizontal-example",
172
+ imports: [
173
+ BarSeriesComponent,
174
+ ChartComponent,
175
+ ChartTooltipComponent,
176
+ ChartXAxisComponent,
177
+ ChartYAxisComponent,
178
+ SegmentedComponent
179
+ ],
180
+ templateUrl: "./horizontal-example.component.html"
181
+ })
182
+ export class ChartHorizontalBarExampleComponent {
183
+ protected readonly orientation = signal<ChartBarOrientation>("horizontal");
184
+ protected readonly orientations: readonly SegmentedOption<ChartBarOrientation>[] = [
185
+ { label: "Horizontal", value: "horizontal" },
186
+ { label: "Vertical", value: "vertical" }
187
+ ];
188
+ protected readonly products = [
189
+ { product: "Trail running shoes", units: 1840 },
190
+ { product: "Rain jacket", units: 1520 },
191
+ { product: "Merino base layer", units: 1275 },
192
+ { product: "Hiking poles", units: 960 },
193
+ { product: "Insulated bottle", units: 830 },
194
+ { product: "Headlamp", units: 615 }
195
+ ];
196
+
197
+ protected onOrientationChange(orientation: ChartBarOrientation | null): void {
198
+ if (orientation) {
199
+ this.orientation.set(orientation);
200
+ }
201
+ }
202
+ }
203
+ ```
204
+
205
+ `horizontal-example.component.html`
206
+
207
+ ```html
208
+ <div class="flex w-full flex-col gap-3">
209
+ <mona-segmented
210
+ aria-label="Bar orientation"
211
+ size="small"
212
+ [options]="orientations"
213
+ [value]="orientation()"
214
+ (valueChange)="onOrientationChange($event)"></mona-segmented>
215
+ <mona-chart aria-label="Units sold by product" class="h-80 w-full" xField="product" [data]="products">
216
+ <mona-chart-x-axis />
217
+ <mona-chart-y-axis />
218
+ <mona-bar-series
219
+ field="units"
220
+ name="Units sold"
221
+ [dataLabels]="true"
222
+ [maxBarWidth]="28"
223
+ [orientation]="orientation()" />
224
+ <mona-chart-tooltip />
225
+ </mona-chart>
226
+ </div>
227
+ ```
228
+
229
+ ### Range bars
230
+
231
+ A range bar spans `fromField` to `toField`. Here it shows each month's range of temperatures, with a line of the average in the same chart.
232
+
233
+ `range-bar-example.component.ts`
234
+
235
+ ```typescript
236
+ import { Component } from "@angular/core";
237
+ import {
238
+ ChartComponent,
239
+ ChartLegendComponent,
240
+ ChartTooltipComponent,
241
+ ChartXAxisComponent,
242
+ ChartYAxisComponent,
243
+ LineSeriesComponent,
244
+ RangeBarSeriesComponent
245
+ } from "@nanahoshi/mona-ui/chart";
246
+
247
+ @Component({
248
+ selector: "app-chart-bar-range-bar-example",
249
+ imports: [
250
+ ChartComponent,
251
+ ChartLegendComponent,
252
+ ChartTooltipComponent,
253
+ ChartXAxisComponent,
254
+ ChartYAxisComponent,
255
+ LineSeriesComponent,
256
+ RangeBarSeriesComponent
257
+ ],
258
+ templateUrl: "./range-bar-example.component.html"
259
+ })
260
+ export class ChartRangeBarExampleComponent {
261
+ protected readonly temperatures = [
262
+ { high: 6, low: -3, mean: 1.4, month: "Jan" },
263
+ { high: 8, low: -2, mean: 2.9, month: "Feb" },
264
+ { high: 13, low: 1, mean: 6.8, month: "Mar" },
265
+ { high: 18, low: 5, mean: 11.2, month: "Apr" },
266
+ { high: 23, low: 9, mean: 15.9, month: "May" },
267
+ { high: 27, low: 13, mean: 19.8, month: "Jun" },
268
+ { high: 29, low: 15, mean: 22.1, month: "Jul" },
269
+ { high: 28, low: 14, mean: 21.4, month: "Aug" },
270
+ { high: 24, low: 10, mean: 16.8, month: "Sep" },
271
+ { high: 17, low: 6, mean: 11.3, month: "Oct" },
272
+ { high: 11, low: 2, mean: 6.1, month: "Nov" },
273
+ { high: 7, low: -1, mean: 2.5, month: "Dec" }
274
+ ];
275
+
276
+ protected readonly celsius = (value: unknown): string => `${Number(value).toLocaleString("en")} °C`;
277
+ }
278
+ ```
279
+
280
+ `range-bar-example.component.html`
281
+
282
+ ```html
283
+ <mona-chart aria-label="Monthly temperature range" class="h-72 w-full" xField="month" [data]="temperatures">
284
+ <mona-chart-x-axis />
285
+ <mona-chart-y-axis title="°C" />
286
+ <mona-range-bar-series
287
+ fromField="low"
288
+ name="Daily low to high"
289
+ toField="high"
290
+ [borderRadius]="6"
291
+ [maxBarWidth]="24"
292
+ [valueFormatter]="celsius" />
293
+ <mona-line-series field="mean" name="Average" [showPoints]="true" [valueFormatter]="celsius" />
294
+ <mona-chart-legend />
295
+ <mona-chart-tooltip [shared]="true" />
296
+ </mona-chart>
297
+ ```
298
+
299
+ ### Waterfall
300
+
301
+ A profit bridge from revenue to net profit. Rows without a value are subtotals and a total, which the chart works out. `showLabels` writes each step's value, and a `monaChartWaterfallLabelTemplate` puts the subtotals and the total in bold.
302
+
303
+ `waterfall-example.component.ts`
304
+
305
+ ```typescript
306
+ import { Component } from "@angular/core";
307
+ import {
308
+ ChartComponent,
309
+ ChartLegendComponent,
310
+ ChartTooltipComponent,
311
+ ChartWaterfallLabelTemplateDirective,
312
+ ChartXAxisComponent,
313
+ ChartYAxisComponent,
314
+ WaterfallSeriesComponent
315
+ } from "@nanahoshi/mona-ui/chart";
316
+ import type { ChartWaterfallDatumKind } from "@nanahoshi/mona-ui/chart";
317
+
318
+ interface ProfitStep {
319
+ readonly amount?: number;
320
+ readonly kind: ChartWaterfallDatumKind;
321
+ readonly step: string;
322
+ }
323
+
324
+ @Component({
325
+ selector: "app-chart-bar-waterfall-example",
326
+ imports: [
327
+ ChartComponent,
328
+ ChartLegendComponent,
329
+ ChartTooltipComponent,
330
+ ChartWaterfallLabelTemplateDirective,
331
+ ChartXAxisComponent,
332
+ ChartYAxisComponent,
333
+ WaterfallSeriesComponent
334
+ ],
335
+ templateUrl: "./waterfall-example.component.html"
336
+ })
337
+ export class ChartWaterfallExampleComponent {
338
+ protected readonly profit: readonly ProfitStep[] = [
339
+ { amount: 420, kind: "change", step: "Revenue" },
340
+ { amount: -168, kind: "change", step: "Cost of sales" },
341
+ { kind: "subtotal", step: "Gross profit" },
342
+ { amount: -64, kind: "change", step: "Marketing" },
343
+ { amount: -112, kind: "change", step: "Salaries" },
344
+ { amount: 18, kind: "change", step: "Other income" },
345
+ { kind: "subtotal", step: "Operating profit" },
346
+ { amount: -23, kind: "change", step: "Tax" },
347
+ { kind: "total", step: "Net profit" }
348
+ ];
349
+
350
+ protected readonly thousands = (value: unknown): string => {
351
+ const amount = Number(value);
352
+ return `${amount < 0 ? "-" : ""}$${Math.abs(amount)}k`;
353
+ };
354
+ }
355
+ ```
356
+
357
+ `waterfall-example.component.html`
358
+
359
+ ```html
360
+ <mona-chart aria-label="Quarterly profit bridge" class="h-80 w-full" xField="step" [data]="profit">
361
+ <mona-chart-x-axis />
362
+ <mona-chart-y-axis />
363
+ <mona-waterfall-series field="amount" name="Profit" [showLabels]="true" [valueFormatter]="thousands">
364
+ <ng-template monaChartWaterfallLabelTemplate let-step>
365
+ <span [class.font-semibold]="step.kind !== 'change'">{{ step.formattedValue }}</span>
366
+ </ng-template>
367
+ </mona-waterfall-series>
368
+ <mona-chart-legend />
369
+ <mona-chart-tooltip />
370
+ </mona-chart>
371
+ ```
372
+
373
+ ## Appearance & Styling
374
+
375
+ | Input | Values | Effect |
376
+ | :--- | :--- | :--- |
377
+ | `orientation` | `"vertical"`, `"horizontal"` | Upright columns, or rows along the X axis. Bars and range bars only. |
378
+ | `borderRadius` | Pixels, `4` by default | Rounds the end of a bar away from zero. In a stack only the outermost segment is rounded. Range bars and waterfall bars round all four corners. |
379
+ | `maxBarWidth` | Pixels | The most a bar's thickness can be. A narrower bar stays centered in its slot. In a stack the smallest `maxBarWidth` of its series applies. |
380
+ | `fillOpacity` | A number from `0` to `1` | The opacity of the fill. Bars are fully opaque by default. |
381
+ | `color` | Any CSS color | Replaces the palette color of a bar or range bar series. By default series take `--color-chart-1` to `--color-chart-5` in order. |
382
+ | `increaseColor`, `decreaseColor`, `neutralColor` | Any CSS color | The fill of waterfall changes that rise, fall or stay level. |
383
+ | `subtotalColor`, `totalColor` | Any CSS color | The fill of waterfall subtotals and totals. |
384
+ | `showConnectors`, `connectorColor`, `connectorWidth` | `boolean`, CSS color, pixels | The level lines joining each waterfall bar to the next, `1` pixel wide by default. A width of `0` hides them. |
385
+ | `strokeColor`, `strokeWidth` | CSS color, pixels | An outline around each waterfall bar. There's none by default. |
386
+
387
+ ### Data labels
388
+
389
+ `dataLabels` on a bar or range bar series takes `true`, `false` or the options described on [Chart Overview](chart.md). With `position: "auto"`, an unstacked bar tries outside its end first, then inside its end, then its middle. A stacked bar and a range bar try their middle first. A percent-stacked bar shows its share by default.
390
+
391
+ ### Waterfall labels
392
+
393
+ `showLabels` writes the value of each waterfall step: the signed change, such as `+18`, for a change, and the running total for a subtotal or total. A label sits above a bar that rises and below one that falls, and moves inside the bar when there's no room. Bars narrower than `minLabelWidth` (default `24` pixels) get no label, and `maxLabels` (default `100`) keeps totals first, then subtotals, then the largest changes.
394
+
395
+ ## Theming
396
+
397
+ Waterfall colors and sizes can also come from CSS custom properties, set on the chart or on the series through `class`. An input wins over its property.
398
+
399
+ | Property | Default |
400
+ | :--- | :--- |
401
+ | `--mona-chart-waterfall-increase-color` | `--color-emerald-600` |
402
+ | `--mona-chart-waterfall-decrease-color` | `--color-red-500` |
403
+ | `--mona-chart-waterfall-neutral-color` | `--color-muted-foreground` |
404
+ | `--mona-chart-waterfall-subtotal-color` | `--color-chart-2` |
405
+ | `--mona-chart-waterfall-total-color` | `--color-chart-1` |
406
+ | `--mona-chart-waterfall-connector-color` | `--color-muted-foreground` |
407
+ | `--mona-chart-waterfall-connector-width` | `1` |
408
+ | `--mona-chart-waterfall-stroke-color`, `--mona-chart-waterfall-stroke-width` | No outline |
409
+ | `--mona-chart-waterfall-fill-opacity` | `1` |
410
+ | `--mona-chart-waterfall-border-radius` | `4` |
411
+ | `--mona-chart-waterfall-label-color` | The foreground color, or a readable color on the bar for a label inside it |
412
+
413
+ ## Behavior
414
+
415
+ ### Category axis
416
+
417
+ Bars and range bars draw one band per category, so their category axis is always a category axis. Numbers such as years become categories too. On an upright chart the categories are on the X axis and the values on the Y axis; with `orientation="horizontal"` they swap. A category axis set to another `type`, or a value axis set to `"category"`, leaves the series out with a development warning. A bar series also needs a value axis that starts from zero, so a `log` value axis leaves it out.
418
+
419
+ ### Grouping and stacking
420
+
421
+ - In each category, every unstacked bar series, every stack and every range bar series gets its own slot, side by side in the order they're declared.
422
+ - Bar series stack when their `stack` names match after trimming, so several stacks can share one chart. Area series stack the same way, see [Line & Area](chart-line-area.md), but a bar and an area never stack together. Range bars don't stack.
423
+ - Positive values stack up from zero and negative values down from it, so a stack with both reaches either side of the axis.
424
+ - `stackMode="percent"` turns each value into its share of the positive, or negative, total in its category.
425
+ - Every series in a stack needs the same `stackMode`. When they differ, or the value axis isn't `linear`, the stack is left out and a development warning says why. Percent stacks and raw values can't share a value axis either. `stackMode` without a `stack` does nothing, with a warning.
426
+ - A hidden series leaves its stack, and the segments above it move down. With `stackMode="percent"` the shares are worked out again from the visible series.
427
+ - When a stacked series has two rows for one category, only the first is drawn.
428
+
429
+ ### Horizontal charts
430
+
431
+ Only bar and range bar series can lie horizontally, and every visible one in the chart must use the same `orientation`. A horizontal chart with a line, area or another series type, or with bars of both orientations, logs a development warning and leaves the plot empty.
432
+
433
+ ### Missing values
434
+
435
+ A bar whose value is `null`, `undefined` or not a number is not drawn, and the other series keep their slots. A range bar needs both `fromField` and `toField`, in either order, since it spans from the lower to the higher. A waterfall change without a value is skipped, and the running total goes on without it.
436
+
437
+ ### Waterfall rules
438
+
439
+ - A waterfall must be the only series in its chart. A second waterfall, or any other series beside it, leaves the chart empty and logs a development warning.
440
+ - It's always upright. Its X axis is a category axis and its Y axis a linear one, whatever their `type`. Of the axis inputs, it uses `visible`, `position`, `title`, `titlePadding`, `labels`, `labelPadding`, `formatter`, `gridLines`, `axisLine`, `tickMarks` and `tickSize`, and on the Y axis also `min`, `max`, `nice` and `tickCount`. The X labels thin out when they don't fit.
441
+ - A step without a category is named "Step 1", "Step 2" and so on.
442
+ - The legend shows one entry for each kind of step the data has: increase, decrease, no change, subtotal and total. They can't be clicked, so `[(visible)]` is the only way to hide the series.
443
+
444
+ ### Value formatting
445
+
446
+ `valueFormatter` formats a series' values in its tooltip, data labels and screen reader announcements. To format the axis ticks, use the axis `formatter`. A waterfall's Y axis without a `formatter` uses the series' `valueFormatter` for its ticks as well. For a waterfall change, the formatter gets the change; for a subtotal or total, the running total. Without either formatter, numbers follow the library locale, and a waterfall change shows its sign.
447
+
448
+ ### Two-way binding
449
+
450
+ `[(visible)]` holds whether the series is shown. The legend sets it when the user toggles a bar or range bar series.
451
+
452
+ ## Accessibility
453
+
454
+ The chart is the focusable element, and these series add no roles of their own. Each bar is announced with its series name, category and formatted value, so give each series a `name`, and use `valueFormatter` to add a unit the reader would otherwise miss. A range bar reads as its range, from one end to the other. A waterfall step reads as its change and the running total before and after it, such as "increase +18, running total 76 to 94", or as its subtotal or total.
455
+
456
+ - **Don't rely on color alone.** Keep the legend, and use data labels or the tooltip so the values can be read without telling colors apart. A waterfall's increase and decrease colors are green and red by default; with `showLabels` the signed labels carry the direction too, and the announcements always do.
457
+ - **Labels are hidden from screen readers.** Data labels and waterfall labels are `aria-hidden`, because the announcements already read the values. Don't put information in a label template that the announcements don't have.
458
+ - **Say what a percent stack shows.** Its axis and labels are shares, not amounts, so say so in the chart's `title` or `aria-description`.
459
+
460
+ ### Keyboard Navigation
461
+
462
+ On an upright bar or range bar chart:
463
+
464
+ | Key | Action |
465
+ | :--- | :--- |
466
+ | `ArrowRight` / `ArrowLeft` | Move to the next or previous category. |
467
+ | `ArrowUp` / `ArrowDown` | Move to another series in the same category. |
468
+ | `Home` / `End` | Move to the first or last category. |
469
+
470
+ On a horizontal chart, `ArrowDown` and `ArrowUp` move between categories, and `ArrowRight` and `ArrowLeft` between the series in a category. In a waterfall, `ArrowRight` and `ArrowLeft` move from step to step and stop at the ends, and `Home` and `End` go to the first and last step.
471
+
472
+ The rest of the keys, including selection, brushing and navigation, are listed on [Chart Overview](chart.md).
473
+
474
+ ## API
475
+
476
+ Everything below is imported from `@nanahoshi/mona-ui/chart`.
477
+
478
+ ### `WaterfallSeriesComponent`
479
+
480
+ Renders financial cash-flow and contribution movements with positive delta increases, negative delta decreases,
481
+ zero-change neutral bars, intermediate subtotals, and cumulative grand totals.
482
+
483
+ **Selector:** `mona-waterfall-series`
484
+
485
+ #### Inputs
486
+
487
+ | Name | Type | Default | Description |
488
+ | --- | --- | --- | --- |
489
+ | `borderRadius` | `number \| undefined` | `undefined` | Corner radius in pixels applied to the four corners of waterfall bars. |
490
+ | `class` | `string` | `""` | CSS class name applied to the hidden series host element for custom styling hooks. |
491
+ | `connectorColor` | `string` | `""` | Color of the horizontal connector lines joining consecutive bars. |
492
+ | `connectorWidth` | `number \| undefined` | `undefined` | Line width in pixels of the connector lines between steps. |
493
+ | `data` | `readonly unknown[] \| undefined` | `undefined` | Array of step data items overriding chart-level root data. |
494
+ | `decreaseColor` | `string` | `""` | Fill color for negative change steps (decreases). |
495
+ | `field` | `ChartField` | `"value"` | Property key or accessor function extracting the numeric value/delta for each step. |
496
+ | `fillOpacity` | `number \| undefined` | `undefined` | Fill opacity applied to waterfall bars (0 to 1). |
497
+ | `increaseColor` | `string` | `""` | Fill color for positive change steps (increases). |
498
+ | `keyField` | `ChartField \| undefined` | `undefined` | Unique identifier key field for datums. |
499
+ | `kindField` | `ChartField \| undefined` | `"kind"` | Property key or accessor extracting step kind ('change' \| 'subtotal' \| 'total'). |
500
+ | `maxBarWidth` | `number \| undefined` | `undefined` | Maximum width in pixels for waterfall bars. |
501
+ | `maxLabels` | `number` | `100` | Maximum number of visible step labels rendered simultaneously. |
502
+ | `minLabelWidth` | `number \| undefined` | `undefined` | Minimum bar width in pixels required to render its value label. |
503
+ | `name` | `string` | `"Waterfall"` | Descriptive series name displayed in chart legend and tooltips. |
504
+ | `neutralColor` | `string` | `""` | Fill color for zero-change steps. |
505
+ | `showConnectors` | `boolean` | `true` | Controls whether horizontal connector lines are drawn between steps. |
506
+ | `showLabels` | `boolean` | `false` | Controls whether built-in value text labels are rendered. |
507
+ | `startValue` | `number` | `0` | Starting cumulative baseline value before the first step. |
508
+ | `strokeColor` | `string` | `""` | Stroke outline color for waterfall bars. |
509
+ | `strokeWidth` | `number \| undefined` | `undefined` | Stroke width in pixels for waterfall bars. |
510
+ | `subtotalColor` | `string` | `""` | Fill color for subtotal steps that anchor to baseline without resetting cumulative count. |
511
+ | `totalColor` | `string` | `""` | Fill color for final total summary steps. |
512
+ | `valueFormatter` | `ChartValueFormatter \| undefined` | `undefined` | Custom formatter function for numeric values. |
513
+ | `visible` (two-way) | `boolean` | `true` | Controls overall visibility of the waterfall series. |
514
+ | `xField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting category / step names. |
515
+
516
+ #### Outputs
517
+
518
+ | Name | Type | Description |
519
+ | --- | --- | --- |
520
+ | `visibleChange` | `boolean` | Emitted when `visible` changes. |
521
+
522
+ ### `BarSeriesComponent`
523
+
524
+ Renders a Cartesian bar series supporting standalone bars, grouped slots, stacked segments, and 100% normalized
525
+ stacks.
526
+
527
+ **Selector:** `mona-bar-series`
528
+
529
+ #### Inputs
530
+
531
+ | Name | Type | Default | Description |
532
+ | --- | --- | --- | --- |
533
+ | `borderRadius` | `number \| undefined` | `undefined` | Corner radius in pixels for the bar caps. |
534
+ | `class` | `string` | `""` | Additional CSS classes applied to the series host element. |
535
+ | `color` | `string` | `""` | Explicit fill color override for the series bars. |
536
+ | `data` | `readonly unknown[] \| undefined` | `undefined` | Series-specific dataset overriding the root chart data. |
537
+ | `dataLabels` | `ChartDataLabelsInput` | `false` | Data label display options or boolean flag enabling default labels. |
538
+ | `field` | `ChartField` | `""` | Property key or accessor extracting the Y/value for each bar. |
539
+ | `fillOpacity` | `number \| undefined` | `undefined` | Fill opacity applied to the bars. |
540
+ | `keyField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting a stable datum identity across updates. |
541
+ | `maxBarWidth` | `number \| undefined` | `undefined` | Maximum width in pixels for each individual bar. |
542
+ | `name` | `string` | `""` | Name of the series displayed in legends and tooltips. |
543
+ | `orientation` | `ChartBarOrientation` | `"vertical"` | Orientation of the bars ('vertical' for column bars, 'horizontal' for row bars). |
544
+ | `seriesKey` | `string \| undefined` | `undefined` | Optional stable key identifying this series for mark identity and selection across updates. |
545
+ | `stack` | `string \| undefined` | `undefined` | Named stack group to participate in. Series with matching trimmed stack names stack together. |
546
+ | `stackMode` | `ChartStackMode` | `"normal"` | Stacking mode used when stack is specified: 'normal' for raw cumulative values, or 'percent' for 100% normalized segments. |
547
+ | `valueFormatter` | `ChartValueFormatter \| undefined` | `undefined` | Custom formatter for raw Y/data values in tooltips and live region announcements. |
548
+ | `visible` (two-way) | `boolean` | `true` | Whether the series is currently visible on the chart and in calculations. |
549
+ | `xAxisId` | `string \| undefined` | `undefined` | Optional ID of the Cartesian X axis this series binds to. When omitted, the primary X axis is used. |
550
+ | `xField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting the X/category value, overriding the root chart X field. |
551
+ | `yAxisId` | `string \| undefined` | `undefined` | Optional ID of the Cartesian Y axis this series binds to. When omitted, the primary Y axis is used. |
552
+
553
+ #### Outputs
554
+
555
+ | Name | Type | Description |
556
+ | --- | --- | --- |
557
+ | `visibleChange` | `boolean` | Emitted when `visible` changes. |
558
+
559
+ ### `RangeBarSeriesComponent`
560
+
561
+ Renders floating Cartesian range bars spanning between a lower value and an upper value (e.g. min/max temperatures,
562
+ price spans, or SLA tolerances).
563
+
564
+ **Selector:** `mona-range-bar-series`
565
+
566
+ #### Inputs
567
+
568
+ | Name | Type | Default | Description |
569
+ | --- | --- | --- | --- |
570
+ | `borderRadius` | `number \| undefined` | `undefined` | Corner radius in pixels for the floating bar caps. |
571
+ | `class` | `string` | `""` | Additional CSS classes applied to the series host element. |
572
+ | `color` | `string` | `""` | Explicit fill color override for the range bars. |
573
+ | `data` | `readonly unknown[] \| undefined` | `undefined` | Series-specific dataset overriding the root chart data. |
574
+ | `dataLabels` | `ChartDataLabelsInput` | `false` | Data label display options or boolean flag enabling default labels. |
575
+ | `fillOpacity` | `number \| undefined` | `undefined` | Fill opacity applied to the range bars. |
576
+ | `fromField` (required) | `ChartField` | — | Property key or accessor extracting the starting range value for each bar. |
577
+ | `keyField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting a stable datum identity across updates. |
578
+ | `maxBarWidth` | `number \| undefined` | `undefined` | Maximum width in pixels for each individual range bar. |
579
+ | `name` | `string` | `"Range Bar"` | Name of the series displayed in legends, tooltips, and live region announcements. |
580
+ | `orientation` | `ChartBarOrientation` | `"vertical"` | Orientation of the range bars ('vertical' for vertical spans, 'horizontal' for horizontal intervals). |
581
+ | `seriesKey` | `string \| undefined` | `undefined` | Optional stable key identifying this series for mark identity and selection across updates. |
582
+ | `toField` (required) | `ChartField` | — | Property key or accessor extracting the ending range value for each bar. |
583
+ | `valueFormatter` | `ChartValueFormatter \| undefined` | `undefined` | Custom formatter for raw range values in tooltips and live region announcements. |
584
+ | `visible` (two-way) | `boolean` | `true` | Whether the series is currently visible on the chart and in calculations. |
585
+ | `xAxisId` | `string \| undefined` | `undefined` | Optional ID of the Cartesian X axis this series binds to. When omitted, the primary X axis is used. |
586
+ | `xField` | `ChartField \| undefined` | `undefined` | Property key or accessor extracting the X/category value, overriding the root chart X field. |
587
+ | `yAxisId` | `string \| undefined` | `undefined` | Optional ID of the Cartesian Y axis this series binds to. When omitted, the primary Y axis is used. |
588
+
589
+ #### Outputs
590
+
591
+ | Name | Type | Description |
592
+ | --- | --- | --- |
593
+ | `visibleChange` | `boolean` | Emitted when `visible` changes. |
594
+
595
+ ### `ChartWaterfallLabelTemplateDirective`
596
+
597
+ **Selector:** `ng-template[monaChartWaterfallLabelTemplate]`
598
+
599
+ #### Template context
600
+
601
+ | Name | Type |
602
+ | --- | --- |
603
+ | `$implicit` | `ChartWaterfallPointContext<unknown>` |
604
+ | `barEnd` | `number` |
605
+ | `barStart` | `number` |
606
+ | `bounds` | `ChartRect` |
607
+ | `category` | `unknown` |
608
+ | `color` | `string` |
609
+ | `cumulativeAfter` | `number` |
610
+ | `cumulativeBefore` | `number` |
611
+ | `dataIndex` | `number` |
612
+ | `datum` | `unknown` |
613
+ | `deltaValue?` | `number \| undefined` |
614
+ | `formattedCategory` | `string` |
615
+ | `formattedCumulativeAfter` | `string` |
616
+ | `formattedCumulativeBefore` | `string` |
617
+ | `formattedDelta?` | `string \| undefined` |
618
+ | `formattedValue` | `string` |
619
+ | `kind` | `ChartWaterfallDatumKind` |
620
+ | `step` | `ChartWaterfallPointContext<unknown>` |
621
+ | `textColor?` | `string \| undefined` |
622
+ | `value` | `number` |
623
+ | `visualKind` | `ChartWaterfallVisualKind` |
624
+
625
+ ### Types
626
+
627
+ #### `ChartWaterfallLabelTemplateContext`
628
+
629
+ **Type parameters:** `T = unknown`
630
+
631
+ | Name | Type |
632
+ | --- | --- |
633
+ | `$implicit` (read-only) | `ChartWaterfallPointContext<T>` |
634
+ | `barEnd` (read-only) | `number` |
635
+ | `barStart` (read-only) | `number` |
636
+ | `bounds` (read-only) | `ChartRect` |
637
+ | `category` (read-only) | `unknown` |
638
+ | `color` (read-only) | `string` |
639
+ | `cumulativeAfter` (read-only) | `number` |
640
+ | `cumulativeBefore` (read-only) | `number` |
641
+ | `dataIndex` (read-only) | `number` |
642
+ | `datum` (read-only) | `T` |
643
+ | `deltaValue?` (read-only) | `number` |
644
+ | `formattedCategory` (read-only) | `string` |
645
+ | `formattedCumulativeAfter` (read-only) | `string` |
646
+ | `formattedCumulativeBefore` (read-only) | `string` |
647
+ | `formattedDelta?` (read-only) | `string` |
648
+ | `formattedValue` (read-only) | `string` |
649
+ | `kind` (read-only) | `ChartWaterfallDatumKind` |
650
+ | `step` (read-only) | `ChartWaterfallPointContext<T>` |
651
+ | `textColor?` (read-only) | `string` |
652
+ | `value` (read-only) | `number` |
653
+ | `visualKind` (read-only) | `ChartWaterfallVisualKind` |
654
+
655
+ #### `ChartWaterfallPointContext`
656
+
657
+ **Type parameters:** `T = unknown`
658
+
659
+ | Name | Type |
660
+ | --- | --- |
661
+ | `barEnd` (read-only) | `number` |
662
+ | `barStart` (read-only) | `number` |
663
+ | `bounds` (read-only) | `ChartRect` |
664
+ | `category` (read-only) | `unknown` |
665
+ | `color` (read-only) | `string` |
666
+ | `cumulativeAfter` (read-only) | `number` |
667
+ | `cumulativeBefore` (read-only) | `number` |
668
+ | `dataIndex` (read-only) | `number` |
669
+ | `datum` (read-only) | `T` |
670
+ | `deltaValue?` (read-only) | `number` |
671
+ | `formattedCategory` (read-only) | `string` |
672
+ | `formattedCumulativeAfter` (read-only) | `string` |
673
+ | `formattedCumulativeBefore` (read-only) | `string` |
674
+ | `formattedDelta?` (read-only) | `string` |
675
+ | `formattedValue` (read-only) | `string` |
676
+ | `kind` (read-only) | `ChartWaterfallDatumKind` |
677
+ | `textColor?` (read-only) | `string` |
678
+ | `value` (read-only) | `number` |
679
+ | `visualKind` (read-only) | `ChartWaterfallVisualKind` |
680
+
681
+ #### `ChartWaterfallPointValue`
682
+
683
+ | Name | Type |
684
+ | --- | --- |
685
+ | `barEnd` (read-only) | `number` |
686
+ | `barStart` (read-only) | `number` |
687
+ | `cumulativeAfter` (read-only) | `number` |
688
+ | `cumulativeBefore` (read-only) | `number` |
689
+ | `deltaValue?` (read-only) | `number` |
690
+ | `formattedCumulativeAfter` (read-only) | `string` |
691
+ | `formattedCumulativeBefore` (read-only) | `string` |
692
+ | `formattedDelta?` (read-only) | `string` |
693
+ | `kind` (read-only) | `ChartWaterfallDatumKind` |
694
+ | `valueKind` (read-only) | `"waterfall"` |
695
+
696
+ #### `ChartBarOrientation`
697
+
698
+ ```typescript
699
+ type ChartBarOrientation = "horizontal" | "vertical";
700
+ ```
701
+
702
+ #### `ChartWaterfallDatumKind`
703
+
704
+ ```typescript
705
+ type ChartWaterfallDatumKind = "change" | "subtotal" | "total";
706
+ ```
707
+
708
+ #### `ChartWaterfallVisualKind`
709
+
710
+ ```typescript
711
+ type ChartWaterfallVisualKind = "decrease" | "increase" | "neutral" | "subtotal" | "total";
712
+ ```
713
+
714
+ **Documented elsewhere:** [`ChartDataLabelsInput`](chart.md), [`ChartField`](chart.md), [`ChartRect`](chart.md), [`ChartStackMode`](chart.md), [`ChartValueFormatter`](chart.md)