@cngx/common 0.1.0-rc.5 → 0.1.0-rc.7

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 (63) hide show
  1. package/chart/README.md +85 -0
  2. package/command/README.md +157 -0
  3. package/data/README.md +23 -0
  4. package/fesm2022/cngx-common-a11y.mjs +247 -85
  5. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  6. package/fesm2022/cngx-common-audio.mjs +37 -37
  7. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  8. package/fesm2022/cngx-common-card.mjs +13 -9
  9. package/fesm2022/cngx-common-card.mjs.map +1 -1
  10. package/fesm2022/cngx-common-chart.mjs +3404 -1392
  11. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  12. package/fesm2022/cngx-common-command.mjs +144 -0
  13. package/fesm2022/cngx-common-command.mjs.map +1 -0
  14. package/fesm2022/cngx-common-data.mjs +304 -213
  15. package/fesm2022/cngx-common-data.mjs.map +1 -1
  16. package/fesm2022/cngx-common-dialog.mjs +369 -100
  17. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  18. package/fesm2022/cngx-common-display.mjs +144 -30
  19. package/fesm2022/cngx-common-display.mjs.map +1 -1
  20. package/fesm2022/cngx-common-interactive.mjs +1089 -459
  21. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  22. package/fesm2022/cngx-common-layout.mjs +113 -61
  23. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  24. package/fesm2022/cngx-common-popover.mjs +430 -54
  25. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  26. package/fesm2022/cngx-common-stepper.mjs +107 -49
  27. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  28. package/fesm2022/cngx-common-tabs.mjs +1170 -752
  29. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  30. package/fesm2022/cngx-common-timeline.mjs +1086 -0
  31. package/fesm2022/cngx-common-timeline.mjs.map +1 -0
  32. package/fesm2022/cngx-common.mjs +2 -2
  33. package/fesm2022/cngx-common.mjs.map +1 -1
  34. package/package.json +11 -1
  35. package/stepper/README.md +1 -1
  36. package/theming/components/cngx-accordion.css +20 -6
  37. package/theming/components/cngx-badge.css +22 -0
  38. package/theming/components/cngx-bottom-sheet.css +14 -2
  39. package/theming/components/cngx-breadcrumb.css +9 -1
  40. package/theming/components/cngx-button-toggle.css +44 -2
  41. package/theming/components/cngx-data-grid.css +69 -4
  42. package/theming/components/cngx-dialog.css +12 -0
  43. package/theming/components/cngx-divider.css +12 -0
  44. package/theming/components/cngx-listbox.css +27 -0
  45. package/theming/components/cngx-menu.css +36 -0
  46. package/theming/components/cngx-ripple.css +1 -1
  47. package/theming/components/cngx-slider.css +1 -1
  48. package/theming/components/cngx-tooltip.css +11 -0
  49. package/types/cngx-common-a11y.d.ts +63 -17
  50. package/types/cngx-common-audio.d.ts +32 -32
  51. package/types/cngx-common-card.d.ts +10 -3
  52. package/types/cngx-common-chart.d.ts +1281 -141
  53. package/types/cngx-common-command.d.ts +167 -0
  54. package/types/cngx-common-data.d.ts +264 -98
  55. package/types/cngx-common-dialog.d.ts +214 -25
  56. package/types/cngx-common-display.d.ts +83 -13
  57. package/types/cngx-common-interactive.d.ts +708 -174
  58. package/types/cngx-common-layout.d.ts +48 -1
  59. package/types/cngx-common-popover.d.ts +120 -3
  60. package/types/cngx-common-stepper.d.ts +55 -5
  61. package/types/cngx-common-tabs.d.ts +386 -25
  62. package/types/cngx-common-timeline.d.ts +1059 -0
  63. package/types/cngx-common.d.ts +1 -1
@@ -1,6 +1,6 @@
1
- import * as _cngx_common_chart from '@cngx/common/chart';
2
1
  import * as _angular_core from '@angular/core';
3
- import { TemplateRef, InjectionToken, Signal } from '@angular/core';
2
+ import { Signal, InjectionToken, TemplateRef, DestroyRef, Provider } from '@angular/core';
3
+ import * as _cngx_common_chart from '@cngx/common/chart';
4
4
  import * as _cngx_common_data from '@cngx/common/data';
5
5
  import { AsyncView } from '@cngx/common/data';
6
6
  import { CngxAsyncState } from '@cngx/core/utils';
@@ -87,6 +87,214 @@ declare function createBandScale<T>(domain: readonly T[], range: readonly [numbe
87
87
  */
88
88
  declare function createOrdinalScale<T>(domain: readonly T[], colors: readonly string[]): (v: T) => string;
89
89
 
90
+ /**
91
+ * Largest-Triangle-Three-Buckets downsampling. Reduces a dense series to
92
+ * `targetSize` points while preserving the perceptual shape of the line -
93
+ * peaks, troughs, and inflections survive where naive uniform (every-Nth)
94
+ * sampling would drop them. This is the realtime-charting literature's
95
+ * default downsampler (Steinarsson 2013).
96
+ *
97
+ * Pure TS: no Angular, no signal, no RxJS dependency. Tree-shakeable, so
98
+ * static-chart consumers that never buffer pay nothing. The `<cngx-chart>`
99
+ * buffer ({@link injectChartBuffer}) is the single downsampling boundary at
100
+ * v2; this is its algorithm.
101
+ *
102
+ * The first and last points are always kept. The middle `targetSize - 2`
103
+ * points are chosen one per bucket by the largest-triangle-area heuristic:
104
+ * for each bucket, the point forming the largest triangle with the previous
105
+ * selected point and the next bucket's average is retained.
106
+ *
107
+ * @param data source series, read-only.
108
+ * @param targetSize desired output length. When `>= data.length` (or `<= 0`),
109
+ * the input is returned unchanged by reference - no allocation, no copy.
110
+ * @param xAccessor projects a row to its numeric X (typically a timestamp or
111
+ * positional index).
112
+ * @param yAccessor projects a row to its numeric Y (the value the triangle
113
+ * area is computed against).
114
+ * @returns a fresh array of at most `targetSize` rows, or the input by
115
+ * reference when no reduction is needed.
116
+ *
117
+ * @category common/chart/buffer
118
+ */
119
+ declare function downsampleLTTB<T>(data: readonly T[], targetSize: number, xAccessor: (d: T, i: number) => number, yAccessor: (d: T, i: number) => number): readonly T[];
120
+
121
+ /**
122
+ * Construction options for {@link injectChartBuffer}.
123
+ *
124
+ * @category common/chart/buffer
125
+ */
126
+ interface ChartBufferOptions<T> {
127
+ /** Ring capacity - the maximum rows retained before eviction. */
128
+ readonly capacity: number;
129
+ /**
130
+ * When set and the ring holds more than this many rows, `points` is
131
+ * LTTB-downsampled to exactly this length. Omit to emit the raw window.
132
+ */
133
+ readonly downsampleTo?: number;
134
+ /** Projects a row to its numeric X for the LTTB triangle area. */
135
+ readonly xAccessor: (d: T, i: number) => number;
136
+ /** Projects a row to its numeric Y for the LTTB triangle area. */
137
+ readonly yAccessor: (d: T, i: number) => number;
138
+ }
139
+ /**
140
+ * The realtime feed handle returned by {@link injectChartBuffer}. Bind
141
+ * `points` to a chart data input; drive it from any high-frequency producer
142
+ * via `push` / `pushBatch`.
143
+ *
144
+ * @category common/chart/buffer
145
+ */
146
+ interface CngxChartBuffer<T> {
147
+ /**
148
+ * The current (optionally downsampled) window, rAF-coalesced. Carries an
149
+ * element-wise `equal` guard so a flush reselecting the same rows does not
150
+ * cascade downstream.
151
+ */
152
+ readonly points: Signal<readonly T[]>;
153
+ /** Append one row; schedules a flush for the next animation frame. */
154
+ push(value: T): void;
155
+ /** Append many rows in order; schedules a single flush. */
156
+ pushBatch(values: readonly T[]): void;
157
+ /** Empty the ring; the emptied window emits on the next flush. */
158
+ clear(): void;
159
+ /** The fixed ring capacity. */
160
+ readonly capacity: number;
161
+ /** Current retained row count, `0..capacity`, reflecting the last flush. */
162
+ readonly length: Signal<number>;
163
+ /** `true` while a flush is scheduled but not yet applied - drive a busy hint. */
164
+ readonly pendingFlush: Signal<boolean>;
165
+ }
166
+ /**
167
+ * Bounded, rAF-coalesced realtime feed for `<cngx-chart>`. Wraps a
168
+ * fixed-capacity ring ({@link createRingBuffer}) with an optional LTTB
169
+ * downsample ({@link downsampleLTTB}) and exposes the window as a `Signal`.
170
+ *
171
+ * Multiple `push` / `pushBatch` / `clear` calls within one animation frame
172
+ * collapse into a single `points` emission: each mutation writes the ring
173
+ * imperatively and schedules one `requestAnimationFrame(flush)`; the flush
174
+ * bumps a revision signal that `points` derives from. The flush is a plain
175
+ * callback writing a signal - not an `effect()` body - so no reactive
176
+ * exception class is involved.
177
+ *
178
+ * Runs in an injection context; the rAF handle is cancelled via `DestroyRef`.
179
+ *
180
+ * ```typescript
181
+ * export class Telemetry {
182
+ * private readonly buffer = injectChartBuffer<Sample>({
183
+ * capacity: 1000,
184
+ * downsampleTo: 600,
185
+ * xAccessor: (s) => s.t,
186
+ * yAccessor: (s) => s.value,
187
+ * });
188
+ * protected readonly points = this.buffer.points; // -> <cngx-chart [data]>
189
+ * onSample(s: Sample): void {
190
+ * this.buffer.push(s);
191
+ * }
192
+ * }
193
+ * ```
194
+ *
195
+ * @category common/chart/buffer
196
+ */
197
+ declare function injectChartBuffer<T>(opts: ChartBufferOptions<T>): CngxChartBuffer<T>;
198
+
199
+ /**
200
+ * Numeric input shape every concrete scale accepts. Linear scales take
201
+ * `number`, time scales take `Date | number`, band scales take `string`
202
+ * or arbitrary references via {@link createBandScale}'s generic. The
203
+ * union narrows at the layer atom (`[cngxLine]`, `[cngxBar]`, ...);
204
+ * the chart context surface stays scale-agnostic.
205
+ *
206
+ * @category common/chart
207
+ */
208
+ type XScaleInput = number | Date | string;
209
+ /**
210
+ * Generic scale function shape. Maps a domain value of type `TIn` to a
211
+ * range value (typically a pixel coordinate). Mirrors the result type
212
+ * of every `create*Scale` factory in `@cngx/common/chart`.
213
+ *
214
+ * @category common/chart
215
+ */
216
+ type ScaleFn<TIn> = (v: TIn) => number;
217
+ /**
218
+ * The rectangle the chart's scales map onto: the viewBox minus the
219
+ * space reserved for axis decoration, in viewBox user units. Without
220
+ * axes it equals the box.
221
+ *
222
+ * `x0`/`y0` are the top-left corner, `x1`/`y1` the bottom-right one,
223
+ * and `width`/`height` the extents between them. Every chart child that
224
+ * needs to know where the plot starts reads this rather than
225
+ * subtracting an inset from the box itself - one derivation, so the
226
+ * scales and the axis lines cannot drift apart.
227
+ *
228
+ * A collapsed plot (a box narrower than the room its axes need) reports
229
+ * `width` or `height` at or below `0`. Readers guard on the extent; the
230
+ * chart hands out its NOOP scale in the same case.
231
+ *
232
+ * @category common/chart
233
+ */
234
+ interface CngxChartPlotArea {
235
+ readonly x0: number;
236
+ readonly y0: number;
237
+ readonly x1: number;
238
+ readonly y1: number;
239
+ readonly width: number;
240
+ readonly height: number;
241
+ }
242
+ /**
243
+ * Reactive context published by `<cngx-chart>` to its content children.
244
+ * Layer atoms (`[cngxLine]`, `[cngxBar]`, ...) and `[cngxAxis]` inject
245
+ * {@link CNGX_CHART_CONTEXT} to read the parent chart's scales,
246
+ * dimensions, data length, and data array without needing a direct
247
+ * reference to the parent class. Token is non-generic at the DI
248
+ * boundary; layer atoms call `data<T>()` to narrow the array to their
249
+ * own `<T>` - the single boundary cast lives inside `CngxChart`'s
250
+ * `data<U>()` method, not at every consumer site.
251
+ *
252
+ * @category common/chart
253
+ */
254
+ interface CngxChartContext<TX = XScaleInput, TY = number> {
255
+ readonly xScale: Signal<ScaleFn<TX>>;
256
+ readonly yScale: Signal<ScaleFn<TY>>;
257
+ readonly dimensions: Signal<{
258
+ width: number;
259
+ height: number;
260
+ }>;
261
+ /**
262
+ * The plot rectangle inside the viewBox, after the room the projected
263
+ * axes need for their decoration. The chart's own scale ranges and
264
+ * `[cngxAxis]`'s line placement both read this single derivation, so
265
+ * ticks always line up with marks. A chart without axes gets the full
266
+ * box.
267
+ */
268
+ readonly plot: Signal<CngxChartPlotArea>;
269
+ readonly dataLength: Signal<number>;
270
+ /**
271
+ * Generic-aware data accessor. Reads the chart's reactive data
272
+ * array; the consumer's `<T>` parameter narrows the returned type
273
+ * without a per-call cast at the consumer site. The chart performs
274
+ * one boundary cast in its implementation.
275
+ */
276
+ data<T = unknown>(): readonly T[];
277
+ /**
278
+ * SVG-output gate (default `true`). Layer atoms wrap their own
279
+ * `<svg:path>` / `<svg:rect>` / `<svg:circle>` emission behind
280
+ * `@if (ctx.renderSvg())`. The chart shell drives this `false` only
281
+ * when Canvas mode is active - an atom asks "should I render my own
282
+ * SVG?", never "what mode am I in?".
283
+ */
284
+ readonly renderSvg: Signal<boolean>;
285
+ }
286
+ /**
287
+ * Injection token consumed by every chart child (`[cngxAxis]`, layer
288
+ * atoms, `<cngx-chart-data-table>`). `<cngx-chart>` provides itself
289
+ * via `useExisting`; child queries narrow the generic on the consumer
290
+ * side.
291
+ *
292
+ * @category common/chart
293
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
294
+ * @since 0.1.0
295
+ */
296
+ declare const CNGX_CHART_CONTEXT: InjectionToken<CngxChartContext<XScaleInput, number>>;
297
+
90
298
  /**
91
299
  * Common context shape passed into every chart slot template
92
300
  * (loading, empty, error). Carries the chart's current rendered
@@ -116,6 +324,23 @@ interface CngxChartSlotContext {
116
324
  readonly width: number;
117
325
  readonly height: number;
118
326
  readonly small: boolean;
327
+ /**
328
+ * The rectangle the chart's marks occupy: the viewBox minus the room
329
+ * the projected axes reserved for their decoration. Without axes it
330
+ * equals the box.
331
+ *
332
+ * Slot templates paint over the chart, and since the axis gutter
333
+ * landed the box is no longer the drawing surface - a fallback
334
+ * centred on `width`/`height` sits off-centre from the marks it
335
+ * replaces. Align to this instead when the fallback should line up
336
+ * with the plot rather than with the host.
337
+ *
338
+ * In viewBox user units. `width`/`height` above stay the *rendered*
339
+ * host size, so the two are in different spaces whenever an explicit
340
+ * `[width]` chart is squeezed; use the `--cngx-chart-plot-*` custom
341
+ * properties for CSS-side alignment, which are resolution-independent.
342
+ */
343
+ readonly plot: CngxChartPlotArea;
119
344
  }
120
345
  /**
121
346
  * Threshold (px) below which `CngxChartSlotContext.small` is true.
@@ -143,7 +368,7 @@ declare const CHART_SMALL_BREAKPOINT_PX = 400;
143
368
  * @category common/chart
144
369
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
145
370
  * @since 0.1.0
146
- * @relatedTo CngxChartEmpty, CngxChartError, CngxChart
371
+ * @relatedTo CngxChartSlotContext, CngxChartEmpty, CngxChartError, CngxChart
147
372
  */
148
373
  declare class CngxChartLoading {
149
374
  readonly templateRef: TemplateRef<any>;
@@ -157,10 +382,18 @@ declare class CngxChartLoading {
157
382
  * a richer surface (`<cngx-empty-state>`, illustration, action) at
158
383
  * regular sizes.
159
384
  *
385
+ * ```html
386
+ * <cngx-chart [state]="state()">
387
+ * <ng-template cngxChartEmpty let-small="small" let-plot="plot">
388
+ * <span>No readings in this range ({{ plot.width }} wide)</span>
389
+ * </ng-template>
390
+ * </cngx-chart>
391
+ * ```
392
+ *
160
393
  * @category common/chart
161
394
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
162
395
  * @since 0.1.0
163
- * @relatedTo CngxChartLoading, CngxChartError, CngxChart
396
+ * @relatedTo CngxChartSlotContext, CngxChartLoading, CngxChartError, CngxChart
164
397
  */
165
398
  declare class CngxChartEmpty {
166
399
  readonly templateRef: TemplateRef<any>;
@@ -183,74 +416,232 @@ interface CngxChartErrorContext extends CngxChartSlotContext {
183
416
  * `*cngxChartError` slot - overrides the chart-level error placeholder.
184
417
  * Receives a {@link CngxChartErrorContext}.
185
418
  *
419
+ * ```html
420
+ * <cngx-chart [state]="state()">
421
+ * <ng-template cngxChartError let-error let-small="small">
422
+ * <span>Could not load: {{ error?.message }}</span>
423
+ * </ng-template>
424
+ * </cngx-chart>
425
+ * ```
426
+ *
186
427
  * @category common/chart
187
428
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
188
429
  * @since 0.1.0
189
- * @relatedTo CngxChartLoading, CngxChartEmpty, CngxChart
430
+ * @relatedTo CngxChartErrorContext, CngxChartLoading, CngxChartEmpty, CngxChart
190
431
  */
191
432
  declare class CngxChartError {
192
433
  readonly templateRef: TemplateRef<any>;
193
434
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxChartError, never>;
194
435
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxChartError, "ng-template[cngxChartError]", never, {}, {}, never, never, true, never>;
195
436
  }
196
-
197
437
  /**
198
- * Numeric input shape every concrete scale accepts. Linear scales take
199
- * `number`, time scales take `Date | number`, band scales take `string`
200
- * or arbitrary references via {@link createBandScale}'s generic. The
201
- * union narrows at the layer atom (`[cngxLine]`, `[cngxBar]`, ...);
202
- * the chart context surface stays scale-agnostic.
438
+ * Context for the connection-lifecycle slots (`*cngxChartConnectionError`,
439
+ * `*cngxChartReconnecting`). Extends the common slot context with the live
440
+ * connection error value via `$implicit` / `error`, mirroring
441
+ * {@link CngxChartErrorContext}. The connection channel is separate from
442
+ * the data `[state]` channel, so this context reflects `[connectionState]`.
203
443
  *
204
444
  * @category common/chart
205
445
  */
206
- type XScaleInput = number | Date | string;
446
+ interface CngxChartConnectionContext extends CngxChartSlotContext {
447
+ readonly $implicit: unknown;
448
+ readonly error: unknown;
449
+ }
207
450
  /**
208
- * Generic scale function shape. Maps a domain value of type `TIn` to a
209
- * range value (typically a pixel coordinate). Mirrors the result type
210
- * of every `create*Scale` factory in `@cngx/common/chart`.
451
+ * `*cngxChartConnectionError` slot - overrides the default banner shown
452
+ * when `[connectionState]` reports `'error'` (connection lost). Overlaid on
453
+ * top of the data view with `role="alert"`; receives a
454
+ * {@link CngxChartConnectionContext}.
455
+ *
456
+ * ```html
457
+ * <cngx-chart [connectionState]="socket">
458
+ * <ng-template cngxChartConnectionError let-error>
459
+ * <span>Live feed lost: {{ error?.message }}</span>
460
+ * </ng-template>
461
+ * </cngx-chart>
462
+ * ```
211
463
  *
212
464
  * @category common/chart
465
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
466
+ * @since 0.1.0
467
+ * @relatedTo CngxChartConnectionContext, CngxChartReconnecting, CngxChart
213
468
  */
214
- type ScaleFn<TIn> = (v: TIn) => number;
469
+ declare class CngxChartConnectionError {
470
+ readonly templateRef: TemplateRef<any>;
471
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxChartConnectionError, never>;
472
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxChartConnectionError, "ng-template[cngxChartConnectionError]", never, {}, {}, never, never, true, never>;
473
+ }
215
474
  /**
216
- * Reactive context published by `<cngx-chart>` to its content children.
217
- * Layer atoms (`[cngxLine]`, `[cngxBar]`, ...) and `[cngxAxis]` inject
218
- * {@link CNGX_CHART_CONTEXT} to read the parent chart's scales,
219
- * dimensions, data length, and data array without needing a direct
220
- * reference to the parent class. Token is non-generic at the DI
221
- * boundary; layer atoms call `data<T>()` to narrow the array to their
222
- * own `<T>` - the single boundary cast lives inside `CngxChart`'s
223
- * `data<U>()` method, not at every consumer site.
475
+ * `*cngxChartReconnecting` slot - overrides the default subtle indicator
476
+ * shown when `[connectionState]` reports `'refreshing'` (reconnecting).
477
+ * Overlaid with `role="status"` (polite); receives a
478
+ * {@link CngxChartConnectionContext}.
479
+ *
480
+ * ```html
481
+ * <cngx-chart [connectionState]="socket">
482
+ * <ng-template cngxChartReconnecting let-small="small">
483
+ * <span>{{ small ? 'Reconnecting' : 'Reconnecting to the live feed' }}</span>
484
+ * </ng-template>
485
+ * </cngx-chart>
486
+ * ```
224
487
  *
225
488
  * @category common/chart
489
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
490
+ * @since 0.1.0
491
+ * @relatedTo CngxChartConnectionContext, CngxChartConnectionError, CngxChart
226
492
  */
227
- interface CngxChartContext<TX = XScaleInput, TY = number> {
228
- readonly xScale: Signal<ScaleFn<TX>>;
229
- readonly yScale: Signal<ScaleFn<TY>>;
230
- readonly dimensions: Signal<{
231
- width: number;
232
- height: number;
233
- }>;
234
- readonly dataLength: Signal<number>;
493
+ declare class CngxChartReconnecting {
494
+ readonly templateRef: TemplateRef<any>;
495
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxChartReconnecting, never>;
496
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxChartReconnecting, "ng-template[cngxChartReconnecting]", never, {}, {}, never, never, true, never>;
497
+ }
498
+ /**
499
+ * `*cngxChartOverlay` slot - projects HTML *on top of the marks*, inside
500
+ * the plot area. Unlike the loading / empty / error slots (which replace
501
+ * the marks in their respective fallback arms), the overlay renders in the
502
+ * `@default` content arm alongside the drawn chart, so it is where
503
+ * crosshair readouts, hover tooltips, annotation callouts and brush
504
+ * affordances belong.
505
+ *
506
+ * The chart positions the overlay frame itself, inset to the plot area via
507
+ * the `--cngx-chart-plot-*` custom properties it already publishes - the
508
+ * consumer performs no `exportAs`, no `plot()` / `dimensions()` arithmetic,
509
+ * and needs no wrapper of their own to act as a containing block. Receives
510
+ * the shared {@link CngxChartSlotContext}, so `plot` / `width` / `height` /
511
+ * `small` are all readable from the template:
512
+ *
513
+ * ```html
514
+ * <cngx-chart [data]="series()" [width]="480" [height]="200">
515
+ * <svg:g cngxAxis position="left" type="linear" [domain]="[0, 100000]"></svg:g>
516
+ * <svg:g cngxLine></svg:g>
517
+ * <ng-template cngxChartOverlay let-plot="plot">
518
+ * <div class="my-callout">{{ plot.width }}x{{ plot.height }} plot</div>
519
+ * </ng-template>
520
+ * </cngx-chart>
521
+ * ```
522
+ *
523
+ * Pointer events: the frame is `pointer-events: none`, so it never
524
+ * intercepts a click, hover or drag meant for the marks beneath it. An
525
+ * interactive element inside the overlay opts back in per element with
526
+ * `pointer-events: auto`. The default is off deliberately - an overlay
527
+ * that silently swallows every pointer event on the chart is invisible
528
+ * until some other interaction (a tooltip, a brush) stops firing, and
529
+ * that is a debugging session; opting a single element back in is one
530
+ * declaration.
531
+ *
532
+ * Accessibility: the chart host is `role="img"` with an auto-summary
533
+ * `aria-label`, so assistive technology sees the chart as a single
534
+ * labelled graphic and never traverses into the overlay. Treat overlay
535
+ * content as *visual* - a hover readout, a tint, an annotation callout.
536
+ * Any state that has to reach AT belongs on the reactive summary or the
537
+ * SR data-table (the `aria-describedby` channel the chart already owns),
538
+ * not on an element projected here.
539
+ *
540
+ * @category common/chart
541
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
542
+ * @since 0.1.0
543
+ * @relatedTo CngxChartSlotContext, CngxChartLoading, CngxChartEmpty, CngxChartError, CngxChart
544
+ */
545
+ declare class CngxChartOverlay {
546
+ readonly templateRef: TemplateRef<any>;
547
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxChartOverlay, never>;
548
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxChartOverlay, "ng-template[cngxChartOverlay]", never, {}, {}, never, never, true, never>;
549
+ }
550
+
551
+ /**
552
+ * Backend-agnostic geometry a layer atom publishes for rendering. A
553
+ * discriminated union: each variant carries exactly the primitives its
554
+ * kind needs, and nothing more. Both the SVG self-render path and the
555
+ * Canvas renderer paint against this same shape, so a single
556
+ * layer-authoring API drives either backend.
557
+ *
558
+ * Coordinates are already scale-projected (pixel space); `color` is
559
+ * `null` when the atom defers to its CSS custom property (the SVG path
560
+ * reads the var directly, the Canvas renderer resolves it via
561
+ * `getComputedStyle`).
562
+ *
563
+ * @category common/chart/layers
564
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/chart-layer.ts
565
+ * @since 0.1.0
566
+ */
567
+ type LayerGeometry = {
568
+ readonly kind: 'line' | 'area';
569
+ readonly d: string;
570
+ readonly color: string | null;
571
+ readonly strokeWidth: number | string | null;
572
+ readonly fill?: string | null;
573
+ readonly opacity?: number | null;
235
574
  /**
236
- * Generic-aware data accessor. Reads the chart's reactive data
237
- * array; the consumer's `<T>` parameter narrows the returned type
238
- * without a per-call cast at the consumer site. The chart performs
239
- * one boundary cast in its implementation.
575
+ * Optional point-marker pass a mark layer emits alongside its
576
+ * path - the scale-projected centres of the datapoints the layer
577
+ * chooses to mark (e.g. the lone datum of a warming series). Both
578
+ * the SVG template and the Canvas renderer paint these as small
579
+ * filled circles in the layer's resolved colour. Absent / empty
580
+ * when the layer draws no markers.
240
581
  */
241
- data<T = unknown>(): readonly T[];
582
+ readonly points?: readonly {
583
+ readonly cx: number;
584
+ readonly cy: number;
585
+ }[];
586
+ } | {
587
+ readonly kind: 'bar';
588
+ readonly rects: readonly {
589
+ readonly x: number;
590
+ readonly y: number;
591
+ readonly w: number;
592
+ readonly h: number;
593
+ readonly color: string | null;
594
+ }[];
595
+ } | {
596
+ readonly kind: 'scatter';
597
+ readonly marks: readonly {
598
+ readonly cx: number;
599
+ readonly cy: number;
600
+ readonly r: number;
601
+ readonly color: string | null;
602
+ }[];
603
+ } | {
604
+ readonly kind: 'threshold';
605
+ readonly x1: number;
606
+ readonly y1: number;
607
+ readonly x2: number;
608
+ readonly y2: number;
609
+ readonly color: string | null;
610
+ readonly dashed: boolean;
611
+ } | {
612
+ readonly kind: 'band';
613
+ readonly x: number;
614
+ readonly y: number;
615
+ readonly w: number;
616
+ readonly h: number;
617
+ readonly color: string | null;
618
+ readonly opacity: number | null;
619
+ };
620
+ /**
621
+ * Contract every layer atom (`[cngxLine]`, `[cngxBar]`, ...) self-provides
622
+ * via {@link CNGX_CHART_LAYER}. The chart shell and the Canvas renderer
623
+ * read layer geometry through this token instead of scraping the DOM.
624
+ *
625
+ * @category common/chart/layers
626
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/chart-layer.ts
627
+ * @since 0.1.0
628
+ */
629
+ interface CngxChartLayer {
630
+ /** The layer's scale-projected geometry, cascade-guarded by an `equal` fn. */
631
+ readonly geometry: Signal<LayerGeometry>;
242
632
  }
243
633
  /**
244
- * Injection token consumed by every chart child (`[cngxAxis]`, layer
245
- * atoms, `<cngx-chart-data-table>`). `<cngx-chart>` provides itself
246
- * via `useExisting`; child queries narrow the generic on the consumer
247
- * side.
634
+ * Injection token each layer atom provides via
635
+ * `{ provide: CNGX_CHART_LAYER, useExisting: CngxX }`. A
636
+ * `contentChildren(CNGX_CHART_LAYER, { descendants: true })` query on the
637
+ * chart shell collects every mounted layer's geometry through DI.
248
638
  *
249
- * @category common/chart
250
- * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
639
+ * @category common/chart/layers
640
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/chart-layer.ts
251
641
  * @since 0.1.0
642
+ * @relatedTo CngxLine, CngxArea, CngxBar, CngxScatter, CngxThreshold, CngxBand
252
643
  */
253
- declare const CNGX_CHART_CONTEXT: InjectionToken<CngxChartContext<XScaleInput, number>>;
644
+ declare const CNGX_CHART_LAYER: InjectionToken<CngxChartLayer>;
254
645
 
255
646
  /**
256
647
  * Top-level chart container. Hosts an `<svg>` viewBox, applies
@@ -276,21 +667,55 @@ declare const CNGX_CHART_CONTEXT: InjectionToken<CngxChartContext<XScaleInput, n
276
667
  * The `[width]` / `[height]` inputs override the resize observer for
277
668
  * fixed-dimension presets (inline sparkline at 80×24, etc.).
278
669
  *
670
+ * ## The plot area
671
+ *
672
+ * Marks are mapped onto the *plot area*, not onto the whole viewBox:
673
+ * the viewBox minus the room the projected axes need for their tick
674
+ * labels and titles. The chart publishes the resulting rectangle on
675
+ * {@link CngxChartContext.plot}, and both its own scale ranges and
676
+ * every `[cngxAxis]` line resolve against that one derivation, so a
677
+ * tick can never drift away from the mark it labels.
678
+ *
679
+ * The reserved room is derived, not configured. Which sides reserve
680
+ * comes from the projected axis set; how much each side reserves comes
681
+ * from the axis itself, which sizes the gutter from the tick labels it
682
+ * already formats. There is no input, no CSS custom property and no DI
683
+ * token to tune it - a chart without axes reserves nothing and fills
684
+ * its box exactly as it did before the plot area existed, as does one
685
+ * whose axes are {@link CngxAxisDomain}, which draws nothing.
686
+ *
687
+ * Every axis reserves on its own side and a little on the two
688
+ * perpendicular ones, because a tick label is centred on its tick and
689
+ * the end ticks sit on the plot corners.
690
+ *
691
+ * Nothing here reads the DOM. The gutter is arithmetic over label
692
+ * strings, so it is at final width in the first painted frame and
693
+ * renders identically under SSR. The cost is that one character's
694
+ * width is an estimate rather than the font's real advance width; a
695
+ * consumer restyling `--cngx-axis-font-size` gets labels at their own
696
+ * size inside a gutter sized for the default.
697
+ *
279
698
  * @category common/chart
280
699
  * @docsKind primary
281
700
  * @wcag AA
282
701
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart.component.ts
283
702
  * @since 0.1.0
284
703
  * @relatedTo CngxAxis, CngxLine, CngxArea, CngxBar, CngxChartLegend
285
- */
286
- /**
704
+ *
287
705
  * <example-url>http://localhost:4200/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
288
706
  * <example-url>http://localhost:4200/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
289
707
  * <example-url>http://localhost:4200/#/common/chart/primitives/line-area-threshold-band</example-url>
290
708
  * <example-url>http://localhost:4200/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
709
+ * <example-url>http://localhost:4200/#/common/chart/primitives/overlay-aligned-to-the-plot</example-url>
291
710
  * <example-url>http://localhost:4200/#/common/chart/primitives/responsive-fills-parent-width</example-url>
292
711
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
293
712
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
713
+ * @slot cngxChartLoading Replaces the centred spinner shown during the first load.
714
+ * @slot cngxChartEmpty Rendered when the data resolves to nothing.
715
+ * @slot cngxChartError Rendered when the load fails; gets the error.
716
+ * @slot cngxChartConnectionError Rendered over the chart when the live connection drops.
717
+ * @slot cngxChartReconnecting Rendered over the chart while the connection retries.
718
+ * @slot cngxChartOverlay HTML layered over the marks in the content view; the chart insets it to the plot area, pointer-events off by default.
294
719
  */
295
720
  declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, number> {
296
721
  /**
@@ -337,25 +762,50 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
337
762
  *
338
763
  * Accepts the standard `CngxAsyncState<T>` shape (any producer:
339
764
  * `createManualState`, `createAsyncState`, `injectAsyncState`,
340
- * `fromHttpResource`, `tap*` pipeline output). The chart provides
341
- * `CNGX_STATEFUL` for downstream bridge directives - composing
342
- * `<cngx-toast-on />` etc. inside the chart works automatically.
765
+ * `fromHttpResource`, `tap*` pipeline output). The chart exposes its
766
+ * state via this explicit input, not a `CNGX_STATEFUL` provision - bind
767
+ * bridges directly, e.g. `<cngx-toast-on [state]="chart.state()">`. The
768
+ * separate `[connectionState]` input tracks connection lifecycle so the
769
+ * two channels never contend for a single precedence seat.
343
770
  */
344
771
  readonly state: _angular_core.InputSignal<CngxAsyncState<readonly T[]> | undefined>;
772
+ /**
773
+ * Optional connection-lifecycle envelope, additive and independent of
774
+ * `[state]`. Bind a websocket/SSE adapter's `CngxAsyncState<unknown>` so
775
+ * connection blips surface via the `*cngxChartConnectionError` /
776
+ * `*cngxChartReconnecting` overlays without overriding the data view.
777
+ * Consumers care only about the status surface, hence `unknown` as `T`.
778
+ */
779
+ readonly connectionState: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
345
780
  private readonly resize;
781
+ private readonly hostEl;
782
+ private readonly destroyRef;
783
+ private readonly rendererFactory;
784
+ private readonly threshold;
346
785
  private readonly axes;
347
786
  private readonly thresholds;
787
+ private readonly layers;
348
788
  protected readonly i18n: _cngx_common_chart.CngxChartI18n;
349
789
  protected readonly dataTableId: string;
350
790
  private readonly loadingSlot;
351
791
  private readonly emptySlot;
352
792
  private readonly errorSlot;
793
+ private readonly connectionErrorSlot;
794
+ private readonly reconnectingSlot;
795
+ private readonly overlaySlot;
796
+ private readonly overlaySlots;
353
797
  /** Resolved consumer-projected loading template (null when no slot bound). */
354
- protected readonly loadingTpl: _angular_core.Signal<_angular_core.TemplateRef<any> | null>;
798
+ protected readonly loadingTpl: Signal<_angular_core.TemplateRef<any> | null>;
355
799
  /** Resolved consumer-projected empty template (null when no slot bound). */
356
- protected readonly emptyTpl: _angular_core.Signal<_angular_core.TemplateRef<any> | null>;
800
+ protected readonly emptyTpl: Signal<_angular_core.TemplateRef<any> | null>;
357
801
  /** Resolved consumer-projected error template (null when no slot bound). */
358
- protected readonly errorTpl: _angular_core.Signal<_angular_core.TemplateRef<any> | null>;
802
+ protected readonly errorTpl: Signal<_angular_core.TemplateRef<any> | null>;
803
+ /** Resolved consumer-projected connection-error template. */
804
+ protected readonly connectionErrorTpl: Signal<_angular_core.TemplateRef<any> | null>;
805
+ /** Resolved consumer-projected reconnecting template. */
806
+ protected readonly reconnectingTpl: Signal<_angular_core.TemplateRef<any> | null>;
807
+ /** Resolved consumer-projected overlay template (null when no slot bound). */
808
+ protected readonly overlayTpl: Signal<_angular_core.TemplateRef<any> | null>;
359
809
  /**
360
810
  * Common context for every slot template (loading, empty, error).
361
811
  * Carries the chart's current rendered width/height plus a `small`
@@ -376,22 +826,37 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
376
826
  * viewport: the rendered width is what the consumer cares about
377
827
  * for fallback layout, not the logical viewBox dimension.
378
828
  */
379
- protected readonly slotContext: _angular_core.Signal<CngxChartSlotContext>;
829
+ protected readonly slotContext: Signal<CngxChartSlotContext>;
380
830
  /**
381
831
  * Error-slot context - extends {@link slotContext} with the live
382
832
  * error value under `$implicit` and `error` keys, so a consumer can
383
833
  * render a typed message AND branch on chart size in the same
384
834
  * template.
385
835
  */
386
- protected readonly errorContext: _angular_core.Signal<{
836
+ protected readonly errorContext: Signal<{
387
837
  $implicit: {} | null;
388
838
  error: {} | null;
389
839
  width: number;
390
840
  height: number;
391
841
  small: boolean;
842
+ plot: CngxChartPlotArea;
392
843
  }>;
844
+ /**
845
+ * Connection-lifecycle view derived from `[connectionState]`'s status.
846
+ * NOT routed through `resolveAsyncView` - that `AsyncView` union has no
847
+ * `'refreshing'` member and folds a refreshing status into the data
848
+ * view. The connection channel maps status directly: `'error'` ->
849
+ * connection-lost overlay, `'refreshing'` -> reconnecting overlay,
850
+ * everything else -> no overlay. Independent of `activeView()`.
851
+ */
852
+ protected readonly connectionView: Signal<"error" | "reconnecting" | "none">;
853
+ /**
854
+ * Context for the connection-slot templates - the connection-channel
855
+ * twin of {@link errorContext}, carrying the live connection error.
856
+ */
857
+ protected readonly connectionCtx: Signal<CngxChartConnectionContext>;
393
858
  constructor();
394
- readonly dataLength: _angular_core.Signal<number>;
859
+ readonly dataLength: Signal<number>;
395
860
  /**
396
861
  * Generic-aware data accessor satisfying {@link CngxChartContext.data}.
397
862
  * The single boundary cast lives here; layer atoms call
@@ -399,22 +864,108 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
399
864
  * per-site `as` cast.
400
865
  */
401
866
  data<U = T>(): readonly U[];
402
- readonly dimensions: _angular_core.Signal<{
867
+ readonly dimensions: Signal<{
403
868
  width: number;
404
869
  height: number;
405
870
  }>;
406
- protected readonly viewBox: _angular_core.Signal<string>;
871
+ /**
872
+ * Room the projected axes need for their decoration, per side.
873
+ * Chart-internal: it exists only to produce {@link plot}, which is
874
+ * what every reader actually wants.
875
+ *
876
+ * Which sides reserve is derived from the same `axes()` query the
877
+ * scale lookups below already read - a consumer input would be a
878
+ * second source for something the chart can see. How much each side
879
+ * reserves is the axis's own {@link CngxChartAxis.reservation}: the
880
+ * chart never learns what a tick label is, and the axis never learns
881
+ * where the plot ends. A side with no axis on it stays `0`, which is
882
+ * why a chart whose axes all draw nothing resolves to
883
+ * {@link ZERO_INSET} and renders exactly as it did before the inset
884
+ * existed.
885
+ */
886
+ private readonly inset;
887
+ /**
888
+ * The plot inset as percentages of the host box, published as the
889
+ * `--cngx-chart-plot-*` custom properties.
890
+ *
891
+ * Custom properties inherit downwards, so these reach the chart's own
892
+ * subtree. An overlay outside the host does not see them and reads
893
+ * {@link plot} off the exported instance instead
894
+ * (`#chart="cngxChart"`) - projected content lands inside the `<svg>`,
895
+ * so an HTML overlay is always a sibling.
896
+ *
897
+ * Percentages rather than pixels, because a user unit is not always a
898
+ * CSS pixel: an explicit `[width]="520"` chart squeezed by
899
+ * `max-width: 100%` keeps a 520-unit viewBox inside a 400px box. A
900
+ * fraction of the viewBox survives that scaling where a px value
901
+ * would not. Block values resolve against the containing block's
902
+ * height and inline values against its width, matching what `top` and
903
+ * `inset-inline-end` expect.
904
+ *
905
+ * Exact while the host's aspect ratio matches the viewBox, which is
906
+ * what {@link explicitAspectRatio} holds it to whenever both `[width]`
907
+ * and `[height]` are bound. Bind only one and it returns `null` on
908
+ * purpose (the consumer drove one dimension deliberately); the SVG
909
+ * then letterboxes under `preserveAspectRatio`, and these percentages
910
+ * address the host box rather than the letterboxed drawing area. The
911
+ * error is the letterbox margin - zero until the host is forced away
912
+ * from the viewBox ratio. Bind both dimensions when an overlay has to
913
+ * land on the plot edge exactly.
914
+ */
915
+ protected readonly plotVars: Signal<{
916
+ inlineStart: string;
917
+ inlineEnd: string;
918
+ blockStart: string;
919
+ blockEnd: string;
920
+ }>;
921
+ /**
922
+ * The plot rectangle published on {@link CngxChartContext}: the
923
+ * viewBox minus {@link inset}. Both scale ranges below and every
924
+ * `[cngxAxis]` resolve against this one derivation, so there is no
925
+ * second place where the box and the reserved room are subtracted
926
+ * from each other and no way for the two to disagree.
927
+ */
928
+ readonly plot: Signal<CngxChartPlotArea>;
929
+ /**
930
+ * Render backend: `'canvas'` once the datapoint count exceeds the
931
+ * configured threshold, `'svg'` otherwise. The threshold is a DI
932
+ * constant ({@link CNGX_CHART_RENDERER_THRESHOLD}, default `500`),
933
+ * resolved once at construction; a consumer tunes it via
934
+ * `withChartRendererThreshold(...)` or replaces the whole factory.
935
+ */
936
+ readonly renderMode: Signal<"svg" | "canvas">;
937
+ /**
938
+ * SVG-output gate published on {@link CngxChartContext}. Derived from
939
+ * {@link renderMode} - layer atoms self-render their SVG only in SVG
940
+ * mode. Single source of truth; the renderer never writes it.
941
+ */
942
+ readonly renderSvg: Signal<boolean>;
943
+ /**
944
+ * Aggregate layer geometries the Canvas backend paints. Element-wise
945
+ * guarded: an unchanged layer contributes a reference-stable geometry
946
+ * object (its own `equal` fn holds), so the mapped array is
947
+ * element-wise-equal and the paint cascade short-circuits.
948
+ */
949
+ protected readonly geometries: Signal<readonly LayerGeometry[]>;
950
+ protected readonly viewBox: Signal<string>;
407
951
  private readonly xScaleCache;
408
952
  private readonly yScaleCache;
409
- readonly xScale: _angular_core.Signal<ScaleFn<XScaleInput>>;
410
- readonly yScale: _angular_core.Signal<ScaleFn<number>>;
953
+ readonly xScale: Signal<ScaleFn<XScaleInput>>;
954
+ readonly yScale: Signal<ScaleFn<number>>;
411
955
  /**
412
956
  * Auto-Summary derived from `data` and `<cngx-threshold>` content
413
957
  * children. Drives the host's reactive `aria-label`. Layer atoms do
414
- * not contribute to the summary on Phase 3 - Phase 5/6 may extend
415
- * with per-layer hints.
958
+ * not contribute to the summary today; per-layer hints may extend it
959
+ * later.
960
+ */
961
+ readonly summary: Signal<_cngx_common_chart.CngxChartSummary>;
962
+ /**
963
+ * The most recent significant transition (trend-flip or threshold-cross)
964
+ * derived from {@link summary}, or `null`. The chart stays
965
+ * pure-derivation - a companion `<cngx-chart-announcer>` subscribes to
966
+ * this surface and voices it to assistive technology.
416
967
  */
417
- readonly summary: _angular_core.Signal<_cngx_common_chart.CngxChartSummary>;
968
+ readonly significantChange: Signal<_cngx_common_chart.CngxSignificantChange | null>;
418
969
  /**
419
970
  * Active view for the optional state-machine envelope. Returns
420
971
  * `'content'` when no `[state]` is bound, falling through to the
@@ -423,9 +974,17 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
423
974
  * / empty triple every preset and async-aware atom in the library
424
975
  * uses.
425
976
  */
426
- protected readonly activeView: _angular_core.Signal<AsyncView>;
977
+ protected readonly activeView: Signal<AsyncView>;
427
978
  /** True when the chart is currently rendering its skeleton view. */
428
- protected readonly busy: _angular_core.Signal<boolean>;
979
+ protected readonly busy: Signal<boolean>;
980
+ /**
981
+ * True when a fallback view (skeleton / empty / error / none) has
982
+ * replaced the data content. The Canvas overlay is a sibling of the
983
+ * `@switch` and would otherwise keep painting the chart on top of the
984
+ * fallback in canvas mode - this gates it off so the fallback stands
985
+ * alone.
986
+ */
987
+ protected readonly contentHidden: Signal<boolean>;
429
988
  /**
430
989
  * Responsive mode is active when neither `[width]` nor `[height]` is
431
990
  * bound. The host then fills its parent's width and derives height
@@ -434,7 +993,7 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
434
993
  * the SVG sizing + scale math, so axes and layer atoms re-flow
435
994
  * reactively as the parent resizes.
436
995
  */
437
- protected readonly isResponsive: _angular_core.Signal<boolean>;
996
+ protected readonly isResponsive: Signal<boolean>;
438
997
  /**
439
998
  * Aspect-ratio host style for the explicit-dimension case. Computed
440
999
  * from `[width] / [height]` so the chart stays proportional when
@@ -445,16 +1004,16 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
445
1004
  * wins, and `null` when only one of width/height is bound (caller
446
1005
  * intentionally drove just one dimension; we do not invent a ratio).
447
1006
  */
448
- protected readonly explicitAspectRatio: _angular_core.Signal<string | null>;
1007
+ protected readonly explicitAspectRatio: Signal<string | null>;
449
1008
  /**
450
1009
  * Reactive `aria-label` text the host announces. Skeleton / empty /
451
1010
  * error states announce localised i18n strings; the auto-Summary
452
1011
  * runs only in the content branch so AT does not read stale data
453
1012
  * during a refetch.
454
1013
  */
455
- protected readonly ariaLabelText: _angular_core.Signal<string>;
1014
+ protected readonly ariaLabelText: Signal<string>;
456
1015
  /** Numeric projection of `data` reused by the data-table view. */
457
- protected readonly summaryValues: _angular_core.Signal<readonly number[]>;
1016
+ protected readonly summaryValues: Signal<readonly number[]>;
458
1017
  /**
459
1018
  * Auto-mode predicate. Drives the data-table's `aria-hidden`
460
1019
  * binding. The id on `aria-describedby` is invariant - it stays on
@@ -462,9 +1021,156 @@ declare class CngxChart<T = unknown> implements CngxChartContext<XScaleInput, nu
462
1021
  * speak via the `aria-label` summary; multi-value charts add the
463
1022
  * table for row-by-row exploration.
464
1023
  */
465
- protected readonly tableActive: _angular_core.Signal<boolean>;
1024
+ protected readonly tableActive: Signal<boolean>;
466
1025
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxChart<any>, never>;
467
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxChart<any>, "cngx-chart", ["cngxChart"], { "dataInput": { "alias": "data"; "required": true; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "preserveAspectRatio": { "alias": "preserveAspectRatio"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "summaryAccessor": { "alias": "summaryAccessor"; "required": false; "isSignal": true; }; "accessibleTable": { "alias": "accessibleTable"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; }, {}, ["axes", "thresholds", "loadingSlot", "emptySlot", "errorSlot"], ["*"], true, [{ directive: typeof i1.CngxResizeObserver; inputs: {}; outputs: {}; }]>;
1026
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxChart<any>, "cngx-chart", ["cngxChart"], { "dataInput": { "alias": "data"; "required": true; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "preserveAspectRatio": { "alias": "preserveAspectRatio"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "summaryAccessor": { "alias": "summaryAccessor"; "required": false; "isSignal": true; }; "accessibleTable": { "alias": "accessibleTable"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "connectionState": { "alias": "connectionState"; "required": false; "isSignal": true; }; }, {}, ["axes", "thresholds", "layers", "loadingSlot", "emptySlot", "errorSlot", "connectionErrorSlot", "reconnectingSlot", "overlaySlot", "overlaySlots"], ["*"], true, [{ directive: typeof i1.CngxResizeObserver; inputs: {}; outputs: {}; }]>;
1027
+ }
1028
+
1029
+ /**
1030
+ * Summary input describing the chart's current data shape. Consumed by
1031
+ * `CngxChartI18n.summary()` to produce the `aria-label` text the
1032
+ * `<cngx-chart>` host announces to screen readers.
1033
+ *
1034
+ * @category common/chart/i18n
1035
+ */
1036
+ interface CngxChartSummary {
1037
+ readonly trend: 'up' | 'down' | 'flat';
1038
+ readonly min: number;
1039
+ readonly max: number;
1040
+ readonly current: number;
1041
+ readonly thresholds: readonly number[];
1042
+ }
1043
+ /**
1044
+ * i18n surface for `@cngx/common/chart`. Mirrors the `CNGX_RECYCLER_I18N`
1045
+ * shape from `@cngx/common/data` - factory defaults supply English;
1046
+ * consumers override per-app via {@link provideChartI18n}.
1047
+ *
1048
+ * @category common/chart/i18n
1049
+ */
1050
+ interface CngxChartI18n {
1051
+ readonly summary: (input: CngxChartSummary) => string;
1052
+ readonly dataTable: () => string;
1053
+ readonly valueColumnLabel: () => string;
1054
+ readonly trendChanged: (trend: 'up' | 'down' | 'flat') => string;
1055
+ readonly thresholdAlert: (threshold: number) => string;
1056
+ readonly connectionLost: () => string;
1057
+ readonly connectionReconnecting: () => string;
1058
+ readonly connectionRestored: () => string;
1059
+ readonly empty: () => string;
1060
+ readonly loading: () => string;
1061
+ readonly error: () => string;
1062
+ }
1063
+ /**
1064
+ * Injection token for chart i18n strings. Defaults to English via
1065
+ * `factory:`. Override at app root with {@link provideChartI18n}.
1066
+ *
1067
+ * @category common/chart/i18n
1068
+ * @wcag AA
1069
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/i18n/chart-i18n.ts
1070
+ * @since 0.1.0
1071
+ */
1072
+ declare const CNGX_CHART_I18N: InjectionToken<CngxChartI18n>;
1073
+ /**
1074
+ * Provider helper for custom chart i18n strings.
1075
+ *
1076
+ * ```typescript
1077
+ * providers: [provideChartI18n({
1078
+ * summary: ({ trend, min, max, current, thresholds }) =>
1079
+ * `${trend === 'up' ? 'Aufwärtstrend' : 'Abwärtstrend'}. Min ${min}, Max ${max}, aktuell ${current}.`,
1080
+ * dataTable: () => 'Datentabelle',
1081
+ * // ...remaining keys
1082
+ * })]
1083
+ * ```
1084
+ *
1085
+ * @category common/chart/i18n
1086
+ */
1087
+ declare function provideChartI18n(i18n: CngxChartI18n): {
1088
+ provide: typeof CNGX_CHART_I18N;
1089
+ useValue: CngxChartI18n;
1090
+ };
1091
+
1092
+ /** @internal */
1093
+ type Trend = 'up' | 'down' | 'flat';
1094
+ /**
1095
+ * A significant, AT-worthy transition derived from the chart summary:
1096
+ * either the trend flipped, or the current value crossed a threshold.
1097
+ * A discriminated union - each variant carries exactly its own fields.
1098
+ *
1099
+ * @category common/chart
1100
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/significant-change.ts
1101
+ * @since 0.1.0
1102
+ */
1103
+ type CngxSignificantChange = {
1104
+ readonly kind: 'trend-flip';
1105
+ readonly from: Trend;
1106
+ readonly to: Trend;
1107
+ } | {
1108
+ readonly kind: 'threshold-cross';
1109
+ readonly threshold: number;
1110
+ readonly direction: 'up' | 'down';
1111
+ };
1112
+ /**
1113
+ * Derive the most recent significant transition from a chart-summary
1114
+ * signal, or `null` when the latest update carried no significance.
1115
+ *
1116
+ * Mirrors `createTransitionTracker`'s current/previous discipline: an
1117
+ * internal `linkedSignal` holds the current summary and the one before it
1118
+ * (structural-equality guarded), and the public signal is a `computed`
1119
+ * with its own structural `equal` - so a summary that re-emits an
1120
+ * equivalent shape yields the same `null` reference and never re-fires a
1121
+ * downstream effect. Threshold crossings take precedence over trend flips
1122
+ * (they are operationally more significant).
1123
+ *
1124
+ * The chart stays pure-derivation: effects that react to the event live in
1125
+ * the companion announcer, not here.
1126
+ *
1127
+ * @param summary the chart's `CngxChartSummary` signal.
1128
+ *
1129
+ * @category common/chart
1130
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/significant-change.ts
1131
+ * @since 0.1.0
1132
+ */
1133
+ declare function createSignificantChangeTracker(summary: Signal<CngxChartSummary>): Signal<CngxSignificantChange | null>;
1134
+
1135
+ /**
1136
+ * Companion live-region announcer for `<cngx-chart>`. Mount it next to a
1137
+ * chart and bind the chart instance; it voices the chart's
1138
+ * `significantChange()` events to assistive technology through two
1139
+ * always-in-DOM regions with a severity split (W3C ARIA practice):
1140
+ *
1141
+ * - trend flips -> a polite `role="status"` region (informational);
1142
+ * - threshold crossings -> an assertive `role="alert"` region
1143
+ * (operationally significant, warrants interruption).
1144
+ *
1145
+ * Both announcements are pure-derivation `computed`s the template
1146
+ * interpolates - there is no `effect()` bridge and nothing to wrap in
1147
+ * `untracked()` (same shape as `CngxRecyclerAnnouncer`). Text is localised
1148
+ * through {@link CNGX_CHART_I18N}.
1149
+ *
1150
+ * ```html
1151
+ * <cngx-chart #c [data]="points()" />
1152
+ * <cngx-chart-announcer [cngxChartAnnouncer]="c" />
1153
+ * ```
1154
+ *
1155
+ * @category common/chart
1156
+ * @docsKind primary
1157
+ * @wcag AA
1158
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-announcer.component.ts
1159
+ * @since 0.1.0
1160
+ * @relatedTo CngxChart, createSignificantChangeTracker
1161
+ *
1162
+ * <example-url>http://localhost:4200/#/common/chart/realtime/streaming-telemetry</example-url>
1163
+ */
1164
+ declare class CngxChartAnnouncer {
1165
+ /** The chart instance whose `significantChange()` this announcer voices. */
1166
+ readonly chart: _angular_core.InputSignal<CngxChart<unknown>>;
1167
+ private readonly i18n;
1168
+ /** Polite (informational) text for trend flips; empty otherwise. */
1169
+ protected readonly politeAnnouncement: _angular_core.Signal<string>;
1170
+ /** Assertive (interrupting) text for threshold crossings; empty otherwise. */
1171
+ protected readonly assertiveAnnouncement: _angular_core.Signal<string>;
1172
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxChartAnnouncer, never>;
1173
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxChartAnnouncer, "cngx-chart-announcer", never, { "chart": { "alias": "cngxChartAnnouncer"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
468
1174
  }
469
1175
 
470
1176
  /**
@@ -483,6 +1189,69 @@ type CngxAxisPosition = 'top' | 'right' | 'bottom' | 'left';
483
1189
  * @category common/chart/axis
484
1190
  */
485
1191
  type CngxAxisType = 'linear' | 'time' | 'band';
1192
+
1193
+ /**
1194
+ * What `<cngx-chart>` needs from an axis, and nothing more.
1195
+ *
1196
+ * Two things travel over this contract. The scale half (`position` /
1197
+ * `type` / `domain`) tells the chart which scale to build and over what
1198
+ * range of values. The geometry half (`reservation` /
1199
+ * `crossReservation`) tells it how much of the box that axis's
1200
+ * decoration needs, so the chart can shrink the plot area to fit.
1201
+ *
1202
+ * Both implementations in the library are axes in the loose sense but
1203
+ * differ in what they do: {@link CngxAxis} draws ticks, labels and a
1204
+ * title and reserves room for them; `CngxAxisDomain` draws nothing and
1205
+ * reserves nothing, existing purely to publish a scale domain. The
1206
+ * chart cannot tell them apart, which is the point - it places and
1207
+ * sizes against the contract, never against a concrete class.
1208
+ *
1209
+ * Implement it on your own directive when you need an axis the chart
1210
+ * participates with but the library does not ship: a logarithmic scale
1211
+ * publisher, an axis whose domain comes from a service, a decoration
1212
+ * you draw yourself. Provide it with `useExisting` and the chart picks
1213
+ * the directive up through its content query.
1214
+ *
1215
+ * @category common/chart/axis
1216
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/chart-axis.ts
1217
+ * @since 0.1.0
1218
+ * @relatedTo CngxAxis, CngxAxisDomain, CngxChart
1219
+ */
1220
+ interface CngxChartAxis {
1221
+ /** Which edge of the plot area this axis occupies. */
1222
+ readonly position: Signal<CngxAxisPosition>;
1223
+ /** Scale kind the chart builds for this axis's dimension. */
1224
+ readonly type: Signal<CngxAxisType>;
1225
+ /** Value range the scale maps from. `undefined` yields a NOOP scale. */
1226
+ readonly domain: Signal<readonly unknown[] | undefined>;
1227
+ /**
1228
+ * How far this axis's decoration extends perpendicular to its own
1229
+ * line, in viewBox user units. The chart reserves it on the side
1230
+ * {@link position} names. Return `0` to claim no room.
1231
+ */
1232
+ readonly reservation: Signal<number>;
1233
+ /**
1234
+ * How far this axis's decoration extends *along* its own line, past
1235
+ * the plot corner at either end. The chart reserves it on the two
1236
+ * sides perpendicular to {@link position}. Return `0` to claim no
1237
+ * room.
1238
+ */
1239
+ readonly crossReservation: Signal<number>;
1240
+ }
1241
+ /**
1242
+ * Contract token every axis provides and `<cngx-chart>` queries.
1243
+ *
1244
+ * The chart's content query resolves this rather than a concrete class,
1245
+ * so a consumer-authored axis participates in scale building and plot
1246
+ * insetting on equal terms with the ones the library ships.
1247
+ *
1248
+ * @category common/chart/axis
1249
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/chart-axis.ts
1250
+ * @since 0.1.0
1251
+ * @relatedTo CngxChartAxis, CngxAxis, CngxAxisDomain
1252
+ */
1253
+ declare const CNGX_CHART_AXIS: InjectionToken<CngxChartAxis>;
1254
+
486
1255
  /** @internal */
487
1256
  interface AxisLabelGeometry {
488
1257
  readonly transform: string;
@@ -560,7 +1329,7 @@ interface TickRendering {
560
1329
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
561
1330
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
562
1331
  */
563
- declare class CngxAxis {
1332
+ declare class CngxAxis implements CngxChartAxis {
564
1333
  readonly position: _angular_core.InputSignal<CngxAxisPosition>;
565
1334
  readonly type: _angular_core.InputSignal<CngxAxisType>;
566
1335
  readonly domain: _angular_core.InputSignal<readonly unknown[] | undefined>;
@@ -595,7 +1364,84 @@ declare class CngxAxis {
595
1364
  * 3. Otherwise → empty array. Axis still renders the line.
596
1365
  */
597
1366
  readonly tickValues: _angular_core.Signal<readonly unknown[]>;
1367
+ /**
1368
+ * How far this axis's decoration extends perpendicular to its own
1369
+ * line, in viewBox user units. The parent chart reads it to size the
1370
+ * plot inset on the side {@link position} names; nothing else
1371
+ * consumes it.
1372
+ *
1373
+ * The magnitude is derived, not configured. A vertical axis reserves
1374
+ * for the tick gap plus the *longest formatted tick label*, because a
1375
+ * left label grows leftward with its character count. A horizontal
1376
+ * axis reserves the tick gap plus one line box, because a bottom
1377
+ * label grows downward by its height no matter how long it is. An
1378
+ * axis carrying a {@link axisLabel} title reserves at least the
1379
+ * title's own fixed offset plus its line box, since
1380
+ * `buildAxisLabelGeometry` places the title at a constant distance
1381
+ * from the line rather than beyond the ticks - so the two extents
1382
+ * are alternatives, not addends.
1383
+ *
1384
+ * Character width is an estimate ({@link CHAR_ADVANCE_RATIO}), which
1385
+ * is the one value here that is not derived from state the axis
1386
+ * owns. Everything else comes from {@link tickValues} and
1387
+ * {@link format}, which the component already computes to render the
1388
+ * labels themselves - so this reads no DOM, measures no text, and
1389
+ * returns the same number under SSR as in the browser.
1390
+ *
1391
+ * Acyclic by construction: {@link tickValues} reads `domain` /
1392
+ * `ticks` / `type` and never the scale, so
1393
+ * `reservation -> inset -> plot -> scale -> tickRenderings` has no
1394
+ * back edge.
1395
+ */
1396
+ readonly reservation: _angular_core.Signal<number>;
1397
+ /**
1398
+ * How far this axis's decoration extends *along* its own line, past
1399
+ * the plot corner at either end. The parent chart reserves it on the
1400
+ * two sides perpendicular to {@link position}.
1401
+ *
1402
+ * A tick label is centred on its tick, and the extreme ticks sit
1403
+ * exactly on the plot corners - so half of the first and last label
1404
+ * hangs outside the plot no matter how much room the axis's own side
1405
+ * reserves. A left axis's topmost label overhangs upward by half a
1406
+ * line box; a bottom axis's last label overhangs rightward by half
1407
+ * its width. Reserving only on the side the axis occupies leaves
1408
+ * both of those painting outside the viewBox, which is the defect
1409
+ * this pairs with {@link reservation} to close.
1410
+ *
1411
+ * The widest label stands in for the two extreme ones. Being wrong
1412
+ * here means over-reserving by a few units on an axis whose ends
1413
+ * happen to carry its shortest labels, which is cheaper than the
1414
+ * per-end bookkeeping the exact answer would need.
1415
+ */
1416
+ readonly crossReservation: _angular_core.Signal<number>;
1417
+ /**
1418
+ * Estimated width of the widest formatted tick label, in viewBox user
1419
+ * units. Split out so a horizontal axis reads it only where label
1420
+ * width actually matters - its own reservation is a line box, and
1421
+ * only its cross-axis overhang depends on the strings.
1422
+ */
1423
+ private readonly widestTickLabel;
1424
+ /**
1425
+ * Character count of the widest formatted tick label. Split out so
1426
+ * that {@link reservation} on a horizontal axis never reads it - a
1427
+ * bottom label's own gutter is its height, so tracking the label
1428
+ * strings there would add a dependency that cannot change the result.
1429
+ * {@link crossReservation} does read it in the horizontal case, where
1430
+ * the label's width is exactly what overhangs the plot corner.
1431
+ */
1432
+ private readonly longestTickLabel;
598
1433
  protected readonly hostClass: _angular_core.Signal<string>;
1434
+ /**
1435
+ * The chart's plot area, or `null` once it has collapsed on either
1436
+ * dimension - the same condition under which the chart hands out its
1437
+ * NOOP scale, so a collapsed chart renders no axis rather than an
1438
+ * axis against a backwards range.
1439
+ *
1440
+ * The rectangle itself is the chart's derivation, read straight off
1441
+ * the context. The axis narrows it to a render/do-not-render
1442
+ * decision; it never reconstructs it from the box.
1443
+ */
1444
+ private readonly plot;
599
1445
  protected readonly axisLabelGeometry: _angular_core.Signal<AxisLabelGeometry | null>;
600
1446
  protected readonly axisGeometry: _angular_core.Signal<AxisGeometry | null>;
601
1447
  protected readonly tickRenderings: _angular_core.Signal<readonly TickRendering[]>;
@@ -603,12 +1449,69 @@ declare class CngxAxis {
603
1449
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxAxis, "[cngxAxis]", ["cngxAxis"], { "position": { "alias": "position"; "required": true; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "domain": { "alias": "domain"; "required": false; "isSignal": true; }; "tickCount": { "alias": "ticks"; "required": false; "isSignal": true; }; "format": { "alias": "format"; "required": false; "isSignal": true; }; "showGrid": { "alias": "grid"; "required": false; "isSignal": true; }; "axisLabel": { "alias": "label"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
604
1450
  }
605
1451
 
1452
+ /**
1453
+ * Declares a scale domain to the parent `<cngx-chart>` without drawing
1454
+ * anything.
1455
+ *
1456
+ * A chart builds its `xScale` from whichever projected axis occupies a
1457
+ * horizontal edge and its `yScale` from a vertical one. Usually that
1458
+ * axis also draws ticks and labels, and `[cngxAxis]` is what you want.
1459
+ * Sometimes the domain is all you need: a sparkline has no room for
1460
+ * decoration, but its line still has to know that y runs 0 to 100.
1461
+ *
1462
+ * ```html
1463
+ * <cngx-chart [data]="readings()">
1464
+ * <svg:g cngxAxisDomain position="bottom" type="band" [domain]="labels()"></svg:g>
1465
+ * <svg:g cngxAxisDomain position="left" [domain]="[0, 100]"></svg:g>
1466
+ * <svg:g cngxLine></svg:g>
1467
+ * </cngx-chart>
1468
+ * ```
1469
+ *
1470
+ * Reserving nothing is the behavioural difference that matters. The
1471
+ * chart shrinks its plot area by the room each axis's decoration needs;
1472
+ * this one has none, so an 80x24 sparkline keeps all 80x24 for its mark
1473
+ * instead of losing a gutter to ticks nobody draws.
1474
+ *
1475
+ * Attribute-selector on `<svg:g>` for the same reason `[cngxAxis]` is:
1476
+ * a `<cngx-axis-domain>` element inside `<svg>` would land in the XHTML
1477
+ * namespace. Nothing renders either way, but the host stays a legal SVG
1478
+ * child.
1479
+ *
1480
+ * @category common/chart/axis
1481
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/axis-domain.ts
1482
+ * @since 0.1.0
1483
+ * @relatedTo CngxAxis, CngxChart, CngxChartAxis
1484
+ *
1485
+ * <example-url>http://localhost:4200/#/ui/chart-panel/basic/titled-panel-with-legend</example-url>
1486
+ * <example-url>http://localhost:4200/#/ui/chart-panel/slots/actions-and-footer</example-url>
1487
+ */
1488
+ declare class CngxAxisDomain implements CngxChartAxis {
1489
+ /** Which edge the scale this publishes belongs to. */
1490
+ readonly position: _angular_core.InputSignal<CngxAxisPosition>;
1491
+ /** Scale kind the chart builds for this dimension. */
1492
+ readonly type: _angular_core.InputSignal<CngxAxisType>;
1493
+ /** Value range the scale maps from. */
1494
+ readonly domain: _angular_core.InputSignal<readonly unknown[] | undefined>;
1495
+ /**
1496
+ * Always `0`. Not an opt-out from a gutter this directive would
1497
+ * otherwise get - it draws nothing, so there is nothing to reserve
1498
+ * for, and the number stays derived from what the unit does.
1499
+ */
1500
+ readonly reservation: Signal<number>;
1501
+ /** Always `0`, for the same reason as {@link reservation}. */
1502
+ readonly crossReservation: Signal<number>;
1503
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAxisDomain, never>;
1504
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAxisDomain, "[cngxAxisDomain]", ["cngxAxisDomain"], { "position": { "alias": "position"; "required": true; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "domain": { "alias": "domain"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1505
+ }
1506
+
606
1507
  /**
607
1508
  * Single legend entry. `color` is optional - when omitted the swatch
608
- * falls back to the chart-level primary token. `value` is intentionally
609
- * unconstrained so consumers can carry their domain key (id, layer
610
- * name, accessor return type, ...) for later interactions without a
611
- * second lookup.
1509
+ * falls back to the chart-level primary token. `value` is rendered as a
1510
+ * trailing `.cngx-chart-legend__value` node when present (`!= null`, so a
1511
+ * literal `0` still shows), turning a legend into a readout. It stays
1512
+ * intentionally unconstrained so the same field a consumer weights in the
1513
+ * row can still carry their domain key (id, layer name, accessor return
1514
+ * type, ...) for later interactions without a second lookup.
612
1515
  *
613
1516
  * @category common/chart/legend
614
1517
  */
@@ -642,7 +1545,10 @@ interface CngxChartLegendItem<T = unknown> {
642
1545
  *
643
1546
  * Theming via `--cngx-chart-legend-gap`,
644
1547
  * `--cngx-chart-legend-swatch-size`, `--cngx-chart-legend-swatch-radius`,
645
- * `--cngx-chart-legend-font-size`. `[orientation]` flips between row
1548
+ * `--cngx-chart-legend-font-size`. A rendered `value` carries its own
1549
+ * `--cngx-chart-legend-value-color` and `--cngx-chart-legend-value-font-weight`
1550
+ * so a legend doubling as a readout can weight the number apart from the
1551
+ * label without a wrapper element. `[orientation]` flips between row
646
1552
  * and column; `[align]` aligns along the main axis (`start`, `center`,
647
1553
  * `end`).
648
1554
  *
@@ -766,12 +1672,23 @@ interface PathBuilder<T> {
766
1672
  */
767
1673
  declare function createPathBuilder<T>(opts: PathBuilderOptions<T>): PathBuilder<T>;
768
1674
 
1675
+ /**
1676
+ * Scale-projected centre of a single point marker on a line / area
1677
+ * layer.
1678
+ *
1679
+ * @internal
1680
+ */
1681
+ interface PointMark {
1682
+ readonly cx: number;
1683
+ readonly cy: number;
1684
+ }
1685
+
769
1686
  /**
770
1687
  * Line layer atom. Renders a single SVG `<path>` connecting the data
771
1688
  * points projected through the parent chart's scales. Reads scales
772
1689
  * from {@link CNGX_CHART_CONTEXT}, NOT from a parent class.
773
1690
  *
774
- * Attribute-selector on `<svg:g>` — the host element IS the SVG group.
1691
+ * Attribute-selector on `<svg:g>` - the host element IS the SVG group.
775
1692
  * Element selectors create XHTML-namespaced custom elements inside
776
1693
  * SVG, which break layout for the namespaced children. Apply this
777
1694
  * directive on an `<svg:g>` host instead.
@@ -779,9 +1696,14 @@ declare function createPathBuilder<T>(opts: PathBuilderOptions<T>): PathBuilder<
779
1696
  * The `d` string is cascade-guarded with string equality on its
780
1697
  * `computed` so downstream effects only re-run when the path
781
1698
  * geometry actually changes. The `createPathBuilder` cache provides
782
- * the **compute guard** — same `(data, xScale, yScale)` triple by
1699
+ * the **compute guard** - same `(data, xScale, yScale)` triple by
783
1700
  * reference skips the per-datapoint projection work.
784
1701
  *
1702
+ * A single-point series draws no visible path (`M x y` has no length),
1703
+ * so a series shorter than two points paints a point marker instead of
1704
+ * nothing. `[points]` controls this: `'auto'` (default) marks only the
1705
+ * one-datum case, `'always'` marks every datum, `'never'` suppresses it.
1706
+ *
785
1707
  * @category common/chart/layers
786
1708
  * @docsKind primary
787
1709
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/line.component.ts
@@ -796,19 +1718,34 @@ declare function createPathBuilder<T>(opts: PathBuilderOptions<T>): PathBuilder<
796
1718
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
797
1719
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
798
1720
  */
799
- declare class CngxLine<T = unknown> {
1721
+ declare class CngxLine<T = unknown> implements CngxChartLayer {
800
1722
  readonly accessor: _angular_core.InputSignal<LineYAccessor<T>>;
801
1723
  readonly xAccessor: _angular_core.InputSignal<LineXAccessor<T> | undefined>;
802
1724
  readonly color: _angular_core.InputSignal<string | null>;
803
1725
  readonly strokeWidth: _angular_core.InputSignal<string | number | null>;
804
1726
  readonly curve: _angular_core.InputSignal<CngxCurve>;
805
1727
  readonly data: _angular_core.InputSignal<readonly T[] | undefined>;
806
- private readonly ctx;
1728
+ /**
1729
+ * Point-marker mode. `'auto'` (default) draws a marker only when the
1730
+ * resolved series has exactly one datum - the frame a warming buffer
1731
+ * passes through on every reload, which paints nothing otherwise.
1732
+ * `'always'` marks every datum; `'never'` suppresses markers.
1733
+ */
1734
+ readonly points: _angular_core.InputSignal<"auto" | "always" | "never">;
1735
+ protected readonly ctx: _cngx_common_chart.CngxChartContext<_cngx_common_chart.XScaleInput, number>;
807
1736
  private readonly builder;
808
1737
  private readonly resolvedData;
809
1738
  protected readonly d: _angular_core.Signal<string>;
1739
+ readonly geometry: _angular_core.Signal<LayerGeometry>;
1740
+ /**
1741
+ * Template view of the geometry's marker pass. Forwards the array
1742
+ * reference the `geometry` computed already holds - `lineAreaGeomEqual`
1743
+ * keeps that reference stable across a no-op refresh, so this
1744
+ * projection stays stable too without a second equality guard.
1745
+ */
1746
+ protected readonly pointMarks: _angular_core.Signal<readonly PointMark[]>;
810
1747
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxLine<any>, never>;
811
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxLine<any>, "[cngxLine]", ["cngxLine"], { "accessor": { "alias": "accessor"; "required": false; "isSignal": true; }; "xAccessor": { "alias": "xAccessor"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; "isSignal": true; }; "curve": { "alias": "curve"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1748
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxLine<any>, "[cngxLine]", ["cngxLine"], { "accessor": { "alias": "accessor"; "required": false; "isSignal": true; }; "xAccessor": { "alias": "xAccessor"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; "isSignal": true; }; "curve": { "alias": "curve"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "points": { "alias": "points"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
812
1749
  }
813
1750
 
814
1751
  /**
@@ -816,11 +1753,16 @@ declare class CngxLine<T = unknown> {
816
1753
  * (same compute guard as `[cngxLine]`) and closes the polygon to a
817
1754
  * `[baseline]` (default `0`) so SVG can fill it.
818
1755
  *
819
- * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1756
+ * Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
820
1757
  *
821
1758
  * The `d` string is cascade-guarded with string equality on its
822
1759
  * `computed` so a no-op data refresh does not force a fill repaint.
823
1760
  *
1761
+ * A single-datum area closes on itself at one x and covers no pixels,
1762
+ * so a series shorter than two points paints a point marker instead of
1763
+ * nothing. `[points]` mirrors {@link CngxLine}: `'auto'` (default) marks
1764
+ * only the one-datum case, `'always'` every datum, `'never'` none.
1765
+ *
824
1766
  * @category common/chart/layers
825
1767
  * @docsKind primary
826
1768
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/area.component.ts
@@ -835,19 +1777,33 @@ declare class CngxLine<T = unknown> {
835
1777
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
836
1778
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
837
1779
  */
838
- declare class CngxArea<T = unknown> {
1780
+ declare class CngxArea<T = unknown> implements CngxChartLayer {
839
1781
  readonly accessor: _angular_core.InputSignal<LineYAccessor<T>>;
840
1782
  readonly xAccessor: _angular_core.InputSignal<LineXAccessor<T> | undefined>;
841
1783
  readonly opacity: _angular_core.InputSignal<string | number | null>;
842
1784
  readonly curve: _angular_core.InputSignal<CngxCurve>;
843
1785
  readonly baseline: _angular_core.InputSignal<number>;
844
1786
  readonly data: _angular_core.InputSignal<readonly T[] | undefined>;
845
- private readonly ctx;
1787
+ /**
1788
+ * Point-marker mode, mirroring {@link CngxLine}. `'auto'` (default)
1789
+ * draws a marker only for a single-datum series - an area closed on
1790
+ * itself at one x covers no pixels and paints nothing otherwise.
1791
+ * `'always'` marks every datum; `'never'` suppresses markers.
1792
+ */
1793
+ readonly points: _angular_core.InputSignal<"auto" | "always" | "never">;
1794
+ protected readonly ctx: _cngx_common_chart.CngxChartContext<_cngx_common_chart.XScaleInput, number>;
846
1795
  private readonly builder;
847
1796
  private readonly resolvedData;
848
1797
  protected readonly d: _angular_core.Signal<string>;
1798
+ readonly geometry: _angular_core.Signal<LayerGeometry>;
1799
+ /**
1800
+ * Template view of the geometry's marker pass. Forwards the reference
1801
+ * the `geometry` computed already holds - `lineAreaGeomEqual` keeps it
1802
+ * stable across a no-op refresh, so no second equality guard is needed.
1803
+ */
1804
+ protected readonly pointMarks: _angular_core.Signal<readonly PointMark[]>;
849
1805
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxArea<any>, never>;
850
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxArea<any>, "[cngxArea]", ["cngxArea"], { "accessor": { "alias": "accessor"; "required": false; "isSignal": true; }; "xAccessor": { "alias": "xAccessor"; "required": false; "isSignal": true; }; "opacity": { "alias": "opacity"; "required": false; "isSignal": true; }; "curve": { "alias": "curve"; "required": false; "isSignal": true; }; "baseline": { "alias": "baseline"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1806
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxArea<any>, "[cngxArea]", ["cngxArea"], { "accessor": { "alias": "accessor"; "required": false; "isSignal": true; }; "xAccessor": { "alias": "xAccessor"; "required": false; "isSignal": true; }; "opacity": { "alias": "opacity"; "required": false; "isSignal": true; }; "curve": { "alias": "curve"; "required": false; "isSignal": true; }; "baseline": { "alias": "baseline"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "points": { "alias": "points"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
851
1807
  }
852
1808
 
853
1809
  /**
@@ -868,13 +1824,13 @@ interface BarRect {
868
1824
  * Bar layer atom. Renders one `<rect>` per datapoint. Bar width comes
869
1825
  * from `dimensions.width / dataLength` (one slot per datapoint) shrunk
870
1826
  * by the optional `[gap]` ratio. Bar height runs from `yScale(value)`
871
- * down to `yScale(baseline)` (default 0) — SVG bottom-anchored.
1827
+ * down to `yScale(baseline)` (default 0) - SVG bottom-anchored.
872
1828
  *
873
1829
  * Bar does NOT require a band X scale; the slot width is purely
874
1830
  * geometric. This keeps the atom usable with linear or band X axes
875
1831
  * interchangeably.
876
1832
  *
877
- * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1833
+ * Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
878
1834
  *
879
1835
  * @category common/chart/layers
880
1836
  * @docsKind primary
@@ -890,14 +1846,15 @@ interface BarRect {
890
1846
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
891
1847
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
892
1848
  */
893
- declare class CngxBar<T = unknown> {
1849
+ declare class CngxBar<T = unknown> implements CngxChartLayer {
894
1850
  readonly accessor: _angular_core.InputSignal<BarYAccessor<T>>;
895
1851
  readonly gap: _angular_core.InputSignal<number>;
896
1852
  readonly baseline: _angular_core.InputSignal<number>;
897
1853
  readonly data: _angular_core.InputSignal<readonly T[] | undefined>;
898
- private readonly ctx;
1854
+ protected readonly ctx: _cngx_common_chart.CngxChartContext<_cngx_common_chart.XScaleInput, number>;
899
1855
  private readonly resolvedData;
900
1856
  protected readonly rects: _angular_core.Signal<readonly BarRect[]>;
1857
+ readonly geometry: _angular_core.Signal<LayerGeometry>;
901
1858
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBar<any>, never>;
902
1859
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxBar<any>, "[cngxBar]", ["cngxBar"], { "accessor": { "alias": "accessor"; "required": false; "isSignal": true; }; "gap": { "alias": "gap"; "required": false; "isSignal": true; }; "baseline": { "alias": "baseline"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
903
1860
  }
@@ -941,14 +1898,15 @@ interface ScatterCircle {
941
1898
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
942
1899
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
943
1900
  */
944
- declare class CngxScatter<T = unknown> {
1901
+ declare class CngxScatter<T = unknown> implements CngxChartLayer {
945
1902
  readonly x: _angular_core.InputSignal<ScatterXAccessor<T>>;
946
1903
  readonly y: _angular_core.InputSignal<ScatterYAccessor<T>>;
947
1904
  readonly radius: _angular_core.InputSignal<number>;
948
1905
  readonly data: _angular_core.InputSignal<readonly T[] | undefined>;
949
- private readonly ctx;
1906
+ protected readonly ctx: _cngx_common_chart.CngxChartContext<XScaleInput, number>;
950
1907
  private readonly resolvedData;
951
1908
  protected readonly circles: _angular_core.Signal<readonly ScatterCircle[]>;
1909
+ readonly geometry: _angular_core.Signal<LayerGeometry>;
952
1910
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxScatter<any>, never>;
953
1911
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxScatter<any>, "[cngxScatter]", ["cngxScatter"], { "x": { "alias": "x"; "required": true; "isSignal": true; }; "y": { "alias": "y"; "required": true; "isSignal": true; }; "radius": { "alias": "radius"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
954
1912
  }
@@ -978,15 +1936,17 @@ declare class CngxScatter<T = unknown> {
978
1936
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
979
1937
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
980
1938
  */
981
- declare class CngxThreshold {
1939
+ declare class CngxThreshold implements CngxChartLayer {
982
1940
  readonly value: _angular_core.InputSignal<number>;
983
1941
  readonly label: _angular_core.InputSignal<string | null>;
984
1942
  readonly dashed: _angular_core.InputSignal<boolean>;
985
- private readonly ctx;
986
- protected readonly geometry: _angular_core.Signal<{
987
- width: number;
1943
+ protected readonly ctx: _cngx_common_chart.CngxChartContext<_cngx_common_chart.XScaleInput, number>;
1944
+ protected readonly bounds: _angular_core.Signal<{
1945
+ x1: number;
1946
+ x2: number;
988
1947
  y: number;
989
1948
  } | null>;
1949
+ readonly geometry: _angular_core.Signal<LayerGeometry>;
990
1950
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxThreshold, never>;
991
1951
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxThreshold, "[cngxThreshold]", ["cngxThreshold"], { "value": { "alias": "value"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "dashed": { "alias": "dashed"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
992
1952
  }
@@ -999,7 +1959,7 @@ declare class CngxThreshold {
999
1959
  * Default opacity is low (`var(--cngx-band-opacity, 0.12)`) so the
1000
1960
  * band sits behind line / area / bar layers without dominating.
1001
1961
  *
1002
- * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1962
+ * Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
1003
1963
  *
1004
1964
  * @category common/chart/layers
1005
1965
  * @docsKind primary
@@ -1015,80 +1975,254 @@ declare class CngxThreshold {
1015
1975
  * <example-url>http://localhost:4200/#/common/chart/primitives/scatter-with-performance-zones</example-url>
1016
1976
  * <example-url>http://localhost:4200/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
1017
1977
  */
1018
- declare class CngxBand {
1978
+ declare class CngxBand implements CngxChartLayer {
1019
1979
  readonly from: _angular_core.InputSignal<number>;
1020
1980
  readonly to: _angular_core.InputSignal<number>;
1021
1981
  readonly label: _angular_core.InputSignal<string | null>;
1022
1982
  readonly opacity: _angular_core.InputSignal<string | number | null>;
1023
- private readonly ctx;
1983
+ protected readonly ctx: _cngx_common_chart.CngxChartContext<_cngx_common_chart.XScaleInput, number>;
1024
1984
  protected readonly rect: _angular_core.Signal<{
1985
+ x: number;
1025
1986
  width: number;
1026
1987
  y: number;
1027
1988
  height: number;
1028
1989
  } | null>;
1990
+ readonly geometry: _angular_core.Signal<LayerGeometry>;
1029
1991
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBand, never>;
1030
1992
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxBand, "[cngxBand]", ["cngxBand"], { "from": { "alias": "from"; "required": true; "isSignal": true; }; "to": { "alias": "to"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "opacity": { "alias": "opacity"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1031
1993
  }
1032
1994
 
1033
1995
  /**
1034
- * Summary input describing the chart's current data shape. Consumed by
1035
- * `CngxChartI18n.summary()` to produce the `aria-label` text the
1036
- * `<cngx-chart>` host announces to screen readers.
1996
+ * Construction dependencies shared by every renderer backend. The
1997
+ * renderer reads scales / dimensions through the chart context and
1998
+ * schedules its own teardown through the `DestroyRef` - it never injects
1999
+ * the concrete `CngxChart` class.
1037
2000
  *
1038
- * @category common/chart/i18n
2001
+ * @category common/chart/renderer
1039
2002
  */
1040
- interface CngxChartSummary {
1041
- readonly trend: 'up' | 'down' | 'flat';
1042
- readonly min: number;
1043
- readonly max: number;
1044
- readonly current: number;
1045
- readonly thresholds: readonly number[];
2003
+ interface ChartRendererDeps {
2004
+ readonly ctx: CngxChartContext;
2005
+ readonly destroyRef: DestroyRef;
1046
2006
  }
1047
2007
  /**
1048
- * i18n surface for `@cngx/common/chart`. Mirrors the `CNGX_RECYCLER_I18N`
1049
- * shape from `@cngx/common/data` - factory defaults supply English;
1050
- * consumers override per-app via {@link provideChartI18n}.
2008
+ * A rendering backend for `<cngx-chart>`. Both backends compose against
2009
+ * the same {@link LayerGeometry} surface the layer atoms publish, so a
2010
+ * single chart-authoring API drives either one with no consumer change.
1051
2011
  *
1052
- * @category common/chart/i18n
2012
+ * The SVG backend is a passthrough (layer atoms self-render); the Canvas
2013
+ * backend paints the geometries onto a `<canvas>` 2D context.
2014
+ *
2015
+ * @category common/chart/renderer
2016
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/chart-renderer.ts
2017
+ * @since 0.1.0
1053
2018
  */
1054
- interface CngxChartI18n {
1055
- readonly summary: (input: CngxChartSummary) => string;
1056
- readonly dataTable: () => string;
1057
- readonly valueColumnLabel: () => string;
1058
- readonly trendChanged: (trend: 'up' | 'down' | 'flat') => string;
1059
- readonly thresholdAlert: (threshold: number) => string;
1060
- readonly empty: () => string;
1061
- readonly loading: () => string;
1062
- readonly error: () => string;
2019
+ interface CngxChartRenderer {
2020
+ /** Which backend this instance is. */
2021
+ readonly mode: 'svg' | 'canvas';
2022
+ /** Attach to the chart host (insert a `<canvas>`, wire teardown, ...). */
2023
+ mount(host: HTMLElement, ctx: CngxChartContext): void;
2024
+ /** Paint the current layer geometries. Called on every geometry emission. */
2025
+ paint(geometries: readonly LayerGeometry[]): void;
2026
+ /** Detach and release resources. */
2027
+ destroy(): void;
2028
+ /** Drop any cached theme colors (called on layout/theming reflow). Optional. */
2029
+ invalidateColorCache?(): void;
1063
2030
  }
1064
2031
  /**
1065
- * Injection token for chart i18n strings. Defaults to English via
1066
- * `factory:`. Override at app root with {@link provideChartI18n}.
2032
+ * Builds a {@link CngxChartRenderer} for the requested `mode`. The
2033
+ * default implementation ({@link createDefaultChartRenderer}) dispatches
2034
+ * to the SVG or Canvas backend; consumers override the whole factory via
2035
+ * {@link CNGX_CHART_RENDERER_FACTORY} to add a third backend (WebGL, ...)
2036
+ * without touching layer atoms.
2037
+ *
2038
+ * @category common/chart/renderer
2039
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/chart-renderer.ts
2040
+ * @since 0.1.0
2041
+ */
2042
+ type CngxChartRendererFactory = (mode: 'svg' | 'canvas', deps: ChartRendererDeps) => CngxChartRenderer;
2043
+
2044
+ /**
2045
+ * SVG passthrough renderer. Layer atoms render their own `<svg:path>` /
2046
+ * `<svg:rect>` / `<svg:circle>`, gated by the chart shell's `renderSvg`
2047
+ * computed, so this backend has nothing to do: every method is a no-op.
2048
+ * It never writes back to the chart context - `renderSvg` ownership stays
2049
+ * in the chart shell as the single source of truth.
1067
2050
  *
1068
- * @category common/chart/i18n
1069
- * @wcag AA
1070
- * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/i18n/chart-i18n.ts
2051
+ * @param _deps unused; kept for factory signature symmetry with
2052
+ * {@link createCanvasRenderer}.
2053
+ *
2054
+ * @category common/chart/renderer
2055
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/svg-renderer.ts
1071
2056
  * @since 0.1.0
1072
2057
  */
1073
- declare const CNGX_CHART_I18N: InjectionToken<CngxChartI18n>;
2058
+ declare function createSvgRenderer(_deps: ChartRendererDeps): CngxChartRenderer;
2059
+
1074
2060
  /**
1075
- * Provider helper for custom chart i18n strings.
2061
+ * Canvas rendering backend. Mounts a `<canvas>` absolutely positioned
2062
+ * over the chart's SVG frame and paints each {@link LayerGeometry} onto
2063
+ * its 2D context: `Path2D` stroke/fill for line/area, per-mark loops for
2064
+ * bar/scatter, `moveTo`/`lineTo` for threshold, `fillRect` for band.
2065
+ *
2066
+ * Colors resolve through a closure-local cache: the first `paint()` reads
2067
+ * each CSS custom property once via `getComputedStyle(host)`; subsequent
2068
+ * paints hit the cache, so the paint hot path performs zero synchronous
2069
+ * DOM reads. {@link CngxChartRenderer.invalidateColorCache} clears it -
2070
+ * the renderer controller calls it on a `dimensions()` change (a proxy
2071
+ * for layout / theming reflow). It never writes the chart context's
2072
+ * `renderSvg` gate; the shell owns that.
2073
+ *
2074
+ * The plot inset needs no handling here. Every geometry this backend
2075
+ * paints was derived from `ctx.xScale()` / `ctx.yScale()`, whose ranges
2076
+ * are already the inset plot area, so canvas marks land exactly where
2077
+ * SVG marks would without the renderer knowing an inset exists. Axis
2078
+ * decoration never reaches this file at all: there is no axis branch in
2079
+ * {@link KIND_VARS} and no text call anywhere in the backend, because
2080
+ * `CngxAxis` renders its own SVG ungated by `renderSvg` in both modes.
2081
+ * The two paths therefore cannot disagree on where the plot area is,
2082
+ * and only one of them ever draws an axis.
2083
+ *
2084
+ * They do differ on what happens past the box edge: a canvas clips
2085
+ * natively at the element bounds, and since the SVG root no longer sets
2086
+ * `overflow: visible` it now clips there too. Out-of-domain data is cut
2087
+ * off on both paths.
2088
+ *
2089
+ * @category common/chart/renderer
2090
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/canvas-renderer.ts
2091
+ * @since 0.1.0
2092
+ */
2093
+ declare function createCanvasRenderer(deps: ChartRendererDeps): CngxChartRenderer;
2094
+
2095
+ /**
2096
+ * Datapoint count above which `<cngx-chart>` auto-switches from SVG to
2097
+ * Canvas rendering. Default `500` - the point at which the SVG backend's
2098
+ * per-layer DOM-node cost starts to dominate on a mid-range laptop.
2099
+ *
2100
+ * Override enterprise-wide via {@link withChartRendererThreshold} (or a
2101
+ * bare provider) to tune the SVG/Canvas crossover for a given app's
2102
+ * hardware profile.
2103
+ *
2104
+ * @category common/chart/renderer
2105
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-threshold.ts
2106
+ * @since 0.1.0
2107
+ * @relatedTo provideChartRenderer, withChartRendererThreshold
2108
+ */
2109
+ declare const CNGX_CHART_RENDERER_THRESHOLD: InjectionToken<number>;
2110
+
2111
+ /**
2112
+ * The default renderer factory: dispatches `'svg'` to
2113
+ * {@link createSvgRenderer} and `'canvas'` to {@link createCanvasRenderer}.
2114
+ * Inlines the two-backend switch; a consumer wanting a third backend
2115
+ * (WebGL, ...) supplies a whole replacement via
2116
+ * {@link withChartRendererFactory}.
2117
+ *
2118
+ * @category common/chart/renderer
2119
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
2120
+ * @since 0.1.0
2121
+ */
2122
+ declare const createDefaultChartRenderer: CngxChartRendererFactory;
2123
+ /**
2124
+ * The renderer-factory the chart shell resolves to build its backend.
2125
+ * Default {@link createDefaultChartRenderer}; override enterprise-wide via
2126
+ * {@link withChartRendererFactory} to add a backend without touching layer
2127
+ * atoms.
2128
+ *
2129
+ * @category common/chart/renderer
2130
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
2131
+ * @since 0.1.0
2132
+ * @relatedTo provideChartRenderer, withChartRendererFactory
2133
+ */
2134
+ declare const CNGX_CHART_RENDERER_FACTORY: InjectionToken<CngxChartRendererFactory>;
2135
+ /**
2136
+ * A single renderer-config override produced by a `with*` feature and
2137
+ * folded by {@link provideChartRenderer}.
2138
+ *
2139
+ * @category common/chart/renderer
2140
+ */
2141
+ interface CngxChartRendererFeature {
2142
+ readonly providers: Provider[];
2143
+ }
2144
+ /**
2145
+ * Override the SVG->Canvas auto-switch cutoff (default `500`).
2146
+ *
2147
+ * @category common/chart/renderer
2148
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
2149
+ * @since 0.1.0
2150
+ */
2151
+ declare function withChartRendererThreshold(n: number): CngxChartRendererFeature;
2152
+ /**
2153
+ * Replace the renderer factory - e.g. to force one backend or add a
2154
+ * third. Consumers wanting a heuristic swap supply a custom factory here
2155
+ * (the heuristic-swap axis ships no dedicated token at v2).
2156
+ *
2157
+ * @category common/chart/renderer
2158
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
2159
+ * @since 0.1.0
2160
+ */
2161
+ declare function withChartRendererFactory(fn: CngxChartRendererFactory): CngxChartRendererFeature;
2162
+ /**
2163
+ * Aggregate renderer-config features into a provider set. Place in a
2164
+ * bootstrap `providers` array (app-wide) or a component's `viewProviders`
2165
+ * (subtree scope).
1076
2166
  *
1077
2167
  * ```typescript
1078
- * providers: [provideChartI18n({
1079
- * summary: ({ trend, min, max, current, thresholds }) =>
1080
- * `${trend === 'up' ? 'Aufwärtstrend' : 'Abwärtstrend'}. Min ${min}, Max ${max}, aktuell ${current}.`,
1081
- * dataTable: () => 'Datentabelle',
1082
- * // ...remaining keys
1083
- * })]
2168
+ * provideChartRenderer(withChartRendererThreshold(2000))
1084
2169
  * ```
1085
2170
  *
1086
- * @category common/chart/i18n
2171
+ * @category common/chart/renderer
2172
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
2173
+ * @since 0.1.0
2174
+ * @relatedTo withChartRendererThreshold, withChartRendererFactory
1087
2175
  */
1088
- declare function provideChartI18n(i18n: CngxChartI18n): {
1089
- provide: typeof CNGX_CHART_I18N;
1090
- useValue: CngxChartI18n;
1091
- };
2176
+ declare function provideChartRenderer(...features: CngxChartRendererFeature[]): Provider[];
2177
+
2178
+ /**
2179
+ * Construction dependencies for {@link createChartRendererController}.
2180
+ *
2181
+ * @category common/chart/renderer
2182
+ */
2183
+ interface ChartRendererControllerDeps {
2184
+ readonly host: HTMLElement;
2185
+ readonly ctx: CngxChartContext;
2186
+ readonly mode: Signal<'svg' | 'canvas'>;
2187
+ readonly geometries: Signal<readonly LayerGeometry[]>;
2188
+ readonly factory: CngxChartRendererFactory;
2189
+ readonly destroyRef: DestroyRef;
2190
+ }
2191
+ /**
2192
+ * Handle returned by {@link createChartRendererController}.
2193
+ *
2194
+ * @category common/chart/renderer
2195
+ */
2196
+ interface CngxChartRendererController {
2197
+ readonly currentMode: Signal<'svg' | 'canvas'>;
2198
+ destroy(): void;
2199
+ }
2200
+ /**
2201
+ * Owns the renderer mount / destroy / paint reactive lifecycle so the
2202
+ * chart shell holds no rendering brain. Installs two effects:
2203
+ *
2204
+ * - **mount** - tracks `mode()`; on change, destroys the previous backend,
2205
+ * builds the new one via `factory`, mounts it, and seeds the first paint.
2206
+ * - **paint** - tracks `geometries()` and the (structurally-deduped)
2207
+ * dimensions; repaints on every geometry emission and invalidates the
2208
+ * backend's color cache when the dimensions actually change.
2209
+ *
2210
+ * Both effects wrap their imperative renderer calls in `untracked()` so
2211
+ * the renderer's own signal reads never feed back into the effect graph.
2212
+ * The dimensions are tracked through a `linkedSignal` guarded by
2213
+ * {@link dimensionsEqual}, so a resize observer re-emitting the same
2214
+ * width/height literal does not trigger a redundant cache invalidation.
2215
+ *
2216
+ * Must run in an injection context (the chart shell calls it from a field
2217
+ * initialiser / constructor). Ships as a plain `create*` factory the shell
2218
+ * calls directly - no DI token, since the only second consumer today is a
2219
+ * test double, which injects a fake `factory` through the deps.
2220
+ *
2221
+ * @category common/chart/renderer
2222
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/chart-renderer-controller.ts
2223
+ * @since 0.1.0
2224
+ */
2225
+ declare function createChartRendererController(deps: ChartRendererControllerDeps): CngxChartRendererController;
1092
2226
 
1093
2227
  /**
1094
2228
  * Inline sparkline - a tiny line chart for KPI cards and dashboard
@@ -1139,6 +2273,12 @@ declare class CngxSparkline {
1139
2273
  * indicators; `aria-valuenow` / `aria-valuemin` / `aria-valuemax`
1140
2274
  * tell AT the exact reading without a separate Summary.
1141
2275
  *
2276
+ * `label` renders a visible caption above the track and doubles as the
2277
+ * host's accessible name: with `label` bound and `[aria-label]` unbound
2278
+ * the meter names itself from the caption, so it is no longer an unnamed
2279
+ * `role="meter"`. A bound `[aria-label]` always wins and overrides the
2280
+ * visible caption.
2281
+ *
1142
2282
  * @category common/chart/presets
1143
2283
  * @docsKind primary
1144
2284
  * @wcag AA
@@ -1374,5 +2514,5 @@ declare class CngxStackedBar {
1374
2514
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxStackedBar, "cngx-stacked-bar", ["cngxStackedBar"], { "segments": { "alias": "segments"; "required": true; "isSignal": true; }; "total": { "alias": "total"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1375
2515
  }
1376
2516
 
1377
- export { CHART_SMALL_BREAKPOINT_PX, CNGX_CHART_CONTEXT, CNGX_CHART_I18N, CngxArea, CngxAxis, CngxBand, CngxBar, CngxBullet, CngxChart, CngxChartEmpty, CngxChartError, CngxChartLegend, CngxChartLoading, CngxDeviationBar, CngxDonut, CngxLine, CngxMiniArea, CngxMiniBar, CngxScatter, CngxSparkline, CngxStackedBar, CngxThreshold, buildCurvePath, createBandScale, createLinearScale, createOrdinalScale, createPathBuilder, createTimeScale, provideChartI18n };
1378
- export type { BandScale, BarYAccessor, CngxAxisPosition, CngxAxisType, CngxBulletRange, CngxChartContext, CngxChartErrorContext, CngxChartI18n, CngxChartLegendItem, CngxChartSlotContext, CngxChartSummary, CngxCurve, CngxStackedSegment, LineXAccessor, LineYAccessor, PathBuilder, PathBuilderOptions, PathPoint, ScaleFn, ScatterXAccessor, ScatterYAccessor, XScaleInput };
2517
+ export { CHART_SMALL_BREAKPOINT_PX, CNGX_CHART_AXIS, CNGX_CHART_CONTEXT, CNGX_CHART_I18N, CNGX_CHART_LAYER, CNGX_CHART_RENDERER_FACTORY, CNGX_CHART_RENDERER_THRESHOLD, CngxArea, CngxAxis, CngxAxisDomain, CngxBand, CngxBar, CngxBullet, CngxChart, CngxChartAnnouncer, CngxChartConnectionError, CngxChartEmpty, CngxChartError, CngxChartLegend, CngxChartLoading, CngxChartOverlay, CngxChartReconnecting, CngxDeviationBar, CngxDonut, CngxLine, CngxMiniArea, CngxMiniBar, CngxScatter, CngxSparkline, CngxStackedBar, CngxThreshold, buildCurvePath, createBandScale, createCanvasRenderer, createChartRendererController, createDefaultChartRenderer, createLinearScale, createOrdinalScale, createPathBuilder, createSignificantChangeTracker, createSvgRenderer, createTimeScale, downsampleLTTB, injectChartBuffer, provideChartI18n, provideChartRenderer, withChartRendererFactory, withChartRendererThreshold };
2518
+ export type { BandScale, BarYAccessor, ChartBufferOptions, ChartRendererControllerDeps, ChartRendererDeps, CngxAxisPosition, CngxAxisType, CngxBulletRange, CngxChartAxis, CngxChartBuffer, CngxChartConnectionContext, CngxChartContext, CngxChartErrorContext, CngxChartI18n, CngxChartLayer, CngxChartLegendItem, CngxChartPlotArea, CngxChartRenderer, CngxChartRendererController, CngxChartRendererFactory, CngxChartRendererFeature, CngxChartSlotContext, CngxChartSummary, CngxCurve, CngxSignificantChange, CngxStackedSegment, LayerGeometry, LineXAccessor, LineYAccessor, PathBuilder, PathBuilderOptions, PathPoint, ScaleFn, ScatterXAccessor, ScatterYAccessor, XScaleInput };