@cngx/common 0.1.0-rc.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/README.md +15 -2
- package/button/README.md +258 -0
- package/command/README.md +42 -2
- package/data/README.md +15 -12
- package/fesm2022/cngx-common-a11y.mjs +1076 -319
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +99 -77
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-button.mjs +1084 -0
- package/fesm2022/cngx-common-button.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +138 -78
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +799 -327
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +101 -25
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +861 -423
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +198 -160
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +693 -329
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7303 -2774
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2174 -442
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-menu-button.mjs +557 -0
- package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +2109 -557
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +548 -419
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +442 -331
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +44 -71
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +10 -10
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +30 -19
- package/layout/README.md +17 -1
- package/menu-button/README.md +234 -0
- package/package.json +31 -8
- package/popover/README.md +81 -4
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +96 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -5
- package/theming/components/cngx-accordion.css +36 -7
- package/theming/components/cngx-async.css +185 -37
- package/theming/components/cngx-backdrop.css +3 -1
- package/theming/components/cngx-badge.css +20 -5
- package/theming/components/cngx-bottom-sheet.css +2 -0
- package/theming/components/cngx-breadcrumb.css +3 -1
- package/theming/components/cngx-button-group.css +325 -0
- package/theming/components/cngx-button-toggle.css +55 -23
- package/theming/components/cngx-button.css +975 -0
- package/theming/components/cngx-data-grid.css +2 -0
- package/theming/components/cngx-dialog.css +3 -1
- package/theming/components/cngx-divider.css +24 -9
- package/theming/components/cngx-drawer.css +153 -0
- package/theming/components/cngx-icon-glyph.css +76 -0
- package/theming/components/cngx-listbox.css +79 -25
- package/theming/components/cngx-menu.css +112 -52
- package/theming/components/cngx-nav.css +1220 -0
- package/theming/components/cngx-popover-sheet.css +434 -0
- package/theming/components/cngx-popover.css +37 -9
- package/theming/components/cngx-recycler-placeholder.css +2 -0
- package/theming/components/cngx-ripple.css +74 -16
- package/theming/components/cngx-sidebar.css +71 -0
- package/theming/components/cngx-slider.css +3 -1
- package/theming/components/cngx-tooltip.css +2 -0
- package/timeline/README.md +2 -2
- package/types/cngx-common-a11y.d.ts +488 -112
- package/types/cngx-common-audio.d.ts +60 -88
- package/types/cngx-common-button.d.ts +698 -0
- package/types/cngx-common-card.d.ts +104 -78
- package/types/cngx-common-chart.d.ts +677 -389
- package/types/cngx-common-command.d.ts +55 -41
- package/types/cngx-common-data.d.ts +506 -360
- package/types/cngx-common-dialog.d.ts +94 -127
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4383 -1721
- package/types/cngx-common-layout.d.ts +1399 -288
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +990 -268
- package/types/cngx-common-stepper.d.ts +374 -465
- package/types/cngx-common-tabs.d.ts +309 -403
- package/types/cngx-common-timeline.d.ts +50 -109
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { CngxRuntimeError, clamp, cngxDevWarn, arrayEqual } from '@cngx/utils';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, DestroyRef, signal, computed, InjectionToken, input, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, linkedSignal, untracked, effect, ElementRef, contentChildren, contentChild,
|
|
3
|
+
import { inject, DestroyRef, signal, computed, InjectionToken, input, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, linkedSignal, untracked, effect, ElementRef, contentChildren, contentChild, afterNextRender, afterRenderEffect } from '@angular/core';
|
|
3
4
|
import { NgTemplateOutlet } from '@angular/common';
|
|
4
5
|
import * as i1 from '@cngx/common/layout';
|
|
5
6
|
import { CngxResizeObserver } from '@cngx/common/layout';
|
|
6
7
|
import { resolveAsyncView } from '@cngx/common/data';
|
|
7
8
|
import { numberFormatterFor, createOverrideMerge, nextUid, injectLocale, createMediaQuerySignal, createTransitionTracker, dateTimeFormatterFor } from '@cngx/core/utils';
|
|
8
9
|
import { formatMessage, createLanguageSection, createSectionBundle } from '@cngx/core/i18n';
|
|
9
|
-
import { clamp, arrayEqual } from '@cngx/utils';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Pure-TS linear scale. Maps a numeric domain `[d0, d1]` to a numeric
|
|
@@ -21,8 +21,6 @@ import { clamp, arrayEqual } from '@cngx/utils';
|
|
|
21
21
|
* scale to a constant function returning `range[0]`.
|
|
22
22
|
* @param range `[start, end]` output range (typically pixel coordinates).
|
|
23
23
|
* @returns `(v: number) => number` mapping domain values to range values.
|
|
24
|
-
*
|
|
25
|
-
* @category common/chart/scales
|
|
26
24
|
*/
|
|
27
25
|
function createLinearScale(domain, range) {
|
|
28
26
|
const [d0, d1] = domain;
|
|
@@ -45,8 +43,6 @@ function createLinearScale(domain, range) {
|
|
|
45
43
|
* @param range `[start, end]` output range (typically pixel coordinates).
|
|
46
44
|
* @returns `(v: Date | number) => number` mapping time values to range
|
|
47
45
|
* values.
|
|
48
|
-
*
|
|
49
|
-
* @category common/chart/scales
|
|
50
46
|
*/
|
|
51
47
|
function createTimeScale(domain, range) {
|
|
52
48
|
const d0 = toMs$2(domain[0]);
|
|
@@ -63,8 +59,6 @@ function toMs$2(v) {
|
|
|
63
59
|
* Construct a {@link BandScale} from a categorical domain and a numeric
|
|
64
60
|
* range. See the type-level documentation above for parameter
|
|
65
61
|
* semantics.
|
|
66
|
-
*
|
|
67
|
-
* @category common/chart/scales
|
|
68
62
|
*/
|
|
69
63
|
function createBandScale(domain, range, padding = 0) {
|
|
70
64
|
const [r0, r1] = range;
|
|
@@ -95,15 +89,16 @@ function createBandScale(domain, range, padding = 0) {
|
|
|
95
89
|
* @param domain Ordered list of categorical values. Values are matched
|
|
96
90
|
* by reference equality on lookup.
|
|
97
91
|
* @param colors Palette to cycle through. Must have at least one entry;
|
|
98
|
-
* an empty palette throws
|
|
92
|
+
* an empty palette throws a `CngxRuntimeError` ([`CNGX1049`](/error-codes/cngx1049.md))
|
|
93
|
+
* synchronously at construction time.
|
|
99
94
|
* @returns Callable `(v: T) => string` returning the palette entry for
|
|
100
95
|
* `v`. Lookup of an unknown value returns the palette's first entry.
|
|
101
|
-
*
|
|
102
|
-
* @category common/chart/scales
|
|
103
96
|
*/
|
|
104
97
|
function createOrdinalScale(domain, colors) {
|
|
105
98
|
if (colors.length === 0) {
|
|
106
|
-
throw new
|
|
99
|
+
throw new CngxRuntimeError('CNGX1049', typeof ngDevMode !== 'undefined' &&
|
|
100
|
+
ngDevMode &&
|
|
101
|
+
'createOrdinalScale(): colors palette must not be empty');
|
|
107
102
|
}
|
|
108
103
|
const lookup = new Map();
|
|
109
104
|
for (let i = 0; i < domain.length; i++) {
|
|
@@ -138,8 +133,6 @@ function createOrdinalScale(domain, colors) {
|
|
|
138
133
|
* area is computed against).
|
|
139
134
|
* @returns a fresh array of at most `targetSize` rows, or the input by
|
|
140
135
|
* reference when no reduction is needed.
|
|
141
|
-
*
|
|
142
|
-
* @category common/chart/buffer
|
|
143
136
|
*/
|
|
144
137
|
function downsampleLTTB(data, targetSize, xAccessor, yAccessor) {
|
|
145
138
|
const n = data.length;
|
|
@@ -206,6 +199,7 @@ function downsampleLTTB(data, targetSize, xAccessor, yAccessor) {
|
|
|
206
199
|
* Length + `Object.is` per-index equality on a readonly numeric array.
|
|
207
200
|
* Used by `summaryValues` and `summary.thresholds`. Reference-equal
|
|
208
201
|
* arrays short-circuit immediately.
|
|
202
|
+
* @internal
|
|
209
203
|
*/
|
|
210
204
|
function sameNumberArr(a, b) {
|
|
211
205
|
if (a === b) {
|
|
@@ -229,6 +223,7 @@ function sameNumberArr(a, b) {
|
|
|
229
223
|
* `snapshot()` allocates a fresh wrapper each call. Reference equality would
|
|
230
224
|
* never fire here (the wrapper is always new); element-wise is the only
|
|
231
225
|
* guard that dedups the buffer's `points` cascade.
|
|
226
|
+
* @internal
|
|
232
227
|
*/
|
|
233
228
|
function sameItemsArr(a, b) {
|
|
234
229
|
if (a === b) {
|
|
@@ -250,6 +245,7 @@ function sameItemsArr(a, b) {
|
|
|
250
245
|
* produces a fresh literal even when the numeric pair is unchanged, so
|
|
251
246
|
* an `equal` fn on this signal is the foundation of the chart-graph
|
|
252
247
|
* cascade short-circuit.
|
|
248
|
+
* @internal
|
|
253
249
|
*/
|
|
254
250
|
function dimensionsEqual(a, b) {
|
|
255
251
|
return a.width === b.width && a.height === b.height;
|
|
@@ -260,6 +256,7 @@ function dimensionsEqual(a, b) {
|
|
|
260
256
|
* re-emits, so without this guard an unchanged axis set would cascade
|
|
261
257
|
* into the plot area and from there into both scale ranges and every
|
|
262
258
|
* axis geometry on each pass.
|
|
259
|
+
* @internal
|
|
263
260
|
*/
|
|
264
261
|
function insetEqual(a, b) {
|
|
265
262
|
return (a.inlineStart === b.inlineStart &&
|
|
@@ -271,6 +268,7 @@ function insetEqual(a, b) {
|
|
|
271
268
|
* Field-wise equality on the published plot rectangle. Only the four
|
|
272
269
|
* corners are compared - `width`/`height` are derived from them, so an
|
|
273
270
|
* equal pair of corners implies equal extents.
|
|
271
|
+
* @internal
|
|
274
272
|
*/
|
|
275
273
|
function plotAreaEqual(a, b) {
|
|
276
274
|
return a.x0 === b.x0 && a.y0 === b.y0 && a.x1 === b.x1 && a.y1 === b.y1;
|
|
@@ -283,6 +281,7 @@ function plotAreaEqual(a, b) {
|
|
|
283
281
|
* The context is a fresh literal on every read, so without this a
|
|
284
282
|
* resize that lands on the same pixel still re-renders every projected
|
|
285
283
|
* loading / empty / error template.
|
|
284
|
+
* @internal
|
|
286
285
|
*/
|
|
287
286
|
function slotContextEqual(a, b) {
|
|
288
287
|
return a.width === b.width && a.height === b.height && plotAreaEqual(a.plot, b.plot);
|
|
@@ -293,13 +292,15 @@ function slotContextEqual(a, b) {
|
|
|
293
292
|
* is allocated once; no growth, no per-push allocation.
|
|
294
293
|
*
|
|
295
294
|
* @param capacity positive integer maximum element count.
|
|
296
|
-
* @throws when `capacity` is not a positive
|
|
297
|
-
*
|
|
298
|
-
* @
|
|
295
|
+
* @throws `CngxRuntimeError` (`CNGX1050`) when `capacity` is not a positive
|
|
296
|
+
* integer.
|
|
297
|
+
* @internal
|
|
299
298
|
*/
|
|
300
299
|
function createRingBuffer(capacity) {
|
|
301
300
|
if (!Number.isInteger(capacity) || capacity <= 0) {
|
|
302
|
-
throw new
|
|
301
|
+
throw new CngxRuntimeError('CNGX1050', typeof ngDevMode !== 'undefined' &&
|
|
302
|
+
ngDevMode &&
|
|
303
|
+
`createRingBuffer(): capacity must be a positive integer, got ${capacity}`);
|
|
303
304
|
}
|
|
304
305
|
const store = new Array(capacity);
|
|
305
306
|
let head = 0; // next write slot
|
|
@@ -363,8 +364,6 @@ function createRingBuffer(capacity) {
|
|
|
363
364
|
* }
|
|
364
365
|
* }
|
|
365
366
|
* ```
|
|
366
|
-
*
|
|
367
|
-
* @category common/chart/buffer
|
|
368
367
|
*/
|
|
369
368
|
function injectChartBuffer(opts) {
|
|
370
369
|
const destroyRef = inject(DestroyRef);
|
|
@@ -438,9 +437,8 @@ function injectChartBuffer(opts) {
|
|
|
438
437
|
* so a consumer-authored axis participates in scale building and plot
|
|
439
438
|
* insetting on equal terms with the ones the library ships.
|
|
440
439
|
*
|
|
441
|
-
* @category common/chart/axis
|
|
442
440
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/chart-axis.ts
|
|
443
|
-
* @since 0.
|
|
441
|
+
* @since 0.3.0
|
|
444
442
|
* @relatedTo CngxChartAxis, CngxAxis, CngxAxisDomain
|
|
445
443
|
*/
|
|
446
444
|
const CNGX_CHART_AXIS = new InjectionToken('CNGX_CHART_AXIS');
|
|
@@ -451,30 +449,30 @@ const CNGX_CHART_AXIS = new InjectionToken('CNGX_CHART_AXIS');
|
|
|
451
449
|
* via `useExisting`; child queries narrow the generic on the consumer
|
|
452
450
|
* side.
|
|
453
451
|
*
|
|
454
|
-
* @category common/chart
|
|
455
452
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
|
|
456
|
-
* @since 0.
|
|
453
|
+
* @since 0.3.0
|
|
457
454
|
*/
|
|
458
455
|
const CNGX_CHART_CONTEXT = new InjectionToken('CngxChartContext');
|
|
459
456
|
/**
|
|
460
|
-
* Inject the parent chart's reactive context. Throws a
|
|
461
|
-
* error when the consumer is not mounted as a content child
|
|
462
|
-
* `<cngx-chart
|
|
463
|
-
*
|
|
464
|
-
*
|
|
457
|
+
* Inject the parent chart's reactive context. Throws a `CngxRuntimeError`
|
|
458
|
+
* with code [`CNGX1048`](/error-codes/cngx1048.md) when the consumer is not mounted as a content child
|
|
459
|
+
* of `<cngx-chart>`, in development and production alike. The `selector`
|
|
460
|
+
* argument is the consumer's public selector without brackets (`'cngxLine'`)
|
|
461
|
+
* and names it in the development message.
|
|
465
462
|
*
|
|
466
463
|
* Use it from custom layer directives mounted on `<svg:g>` hosts to
|
|
467
464
|
* read `plot`, the scales and `renderSvg` the same way the built-in
|
|
468
465
|
* layer atoms do.
|
|
469
466
|
*
|
|
470
|
-
* @category common/chart
|
|
471
467
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
|
|
472
|
-
* @since 0.
|
|
468
|
+
* @since 0.3.0
|
|
473
469
|
*/
|
|
474
|
-
function injectChartContext(
|
|
470
|
+
function injectChartContext(selector) {
|
|
475
471
|
const ctx = inject(CNGX_CHART_CONTEXT, { optional: true });
|
|
476
472
|
if (!ctx) {
|
|
477
|
-
throw new
|
|
473
|
+
throw new CngxRuntimeError('CNGX1048', typeof ngDevMode !== 'undefined' &&
|
|
474
|
+
ngDevMode &&
|
|
475
|
+
`[${selector}] must be placed inside <cngx-chart>.`);
|
|
478
476
|
}
|
|
479
477
|
return ctx;
|
|
480
478
|
}
|
|
@@ -485,9 +483,8 @@ function injectChartContext(consumerName) {
|
|
|
485
483
|
* `contentChildren(CNGX_CHART_LAYER, { descendants: true })` query on the
|
|
486
484
|
* chart shell collects every mounted layer's geometry through DI.
|
|
487
485
|
*
|
|
488
|
-
* @category common/chart/layers
|
|
489
486
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/chart-layer.ts
|
|
490
|
-
* @since 0.
|
|
487
|
+
* @since 0.3.0
|
|
491
488
|
* @relatedTo CngxLine, CngxArea, CngxBar, CngxScatter, CngxThreshold, CngxBand
|
|
492
489
|
*/
|
|
493
490
|
const CNGX_CHART_LAYER = new InjectionToken('CngxChartLayer');
|
|
@@ -503,26 +500,40 @@ const CNGX_CHART_LAYER = new InjectionToken('CngxChartLayer');
|
|
|
503
500
|
*
|
|
504
501
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
505
502
|
*
|
|
506
|
-
* @category common/chart/layers
|
|
507
|
-
* @docsKind primary
|
|
508
503
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/threshold.component.ts
|
|
509
|
-
* @since 0.
|
|
504
|
+
* @since 0.3.0
|
|
510
505
|
* @relatedTo CngxBand, CngxChart, CngxLine
|
|
511
506
|
*
|
|
512
|
-
* <example-url
|
|
513
|
-
* <example-url
|
|
514
|
-
* <example-url
|
|
515
|
-
* <example-url
|
|
516
|
-
* <example-url
|
|
517
|
-
* <example-url
|
|
518
|
-
* <example-url
|
|
507
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
508
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
509
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
510
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
511
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
512
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
513
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
519
514
|
*/
|
|
520
515
|
class CngxThreshold {
|
|
516
|
+
/**
|
|
517
|
+
* Required y value of the horizontal reference line, projected through the chart's y scale. The
|
|
518
|
+
* line spans the plot width.
|
|
519
|
+
*/
|
|
521
520
|
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
521
|
+
/**
|
|
522
|
+
* Optional text drawn just above the line near the plot's right edge, anchored at its end. Unset
|
|
523
|
+
* draws no text.
|
|
524
|
+
*/
|
|
522
525
|
label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
526
|
+
/**
|
|
527
|
+
* Draws the line with a `4 3` dash pattern instead of solid, in both the SVG and the canvas
|
|
528
|
+
* renderer. Default `false`.
|
|
529
|
+
*/
|
|
523
530
|
dashed = input(false, ...(ngDevMode ? [{ debugName: "dashed" }] : /* istanbul ignore next */ []));
|
|
531
|
+
/**
|
|
532
|
+
* CSS colour of the line, applied as an inline style and read by the canvas renderer. Unset falls
|
|
533
|
+
* back to `--cngx-threshold-color`, then `--cngx-chart-danger`.
|
|
534
|
+
*/
|
|
524
535
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
525
|
-
ctx = injectChartContext('
|
|
536
|
+
ctx = injectChartContext('cngxThreshold');
|
|
526
537
|
bounds = computed(() => {
|
|
527
538
|
// Spans the plot, not the box - a threshold line running under
|
|
528
539
|
// the left axis's tick labels reads as a stray rule through the
|
|
@@ -668,8 +679,7 @@ function formatChartNumber(v, locale) {
|
|
|
668
679
|
* The English chart section: the single source of the chart's English copy.
|
|
669
680
|
* `CNGX_CHART_I18N` defaults to it.
|
|
670
681
|
*
|
|
671
|
-
* @
|
|
672
|
-
* @since 0.1.0
|
|
682
|
+
* @since 0.3.0
|
|
673
683
|
* @relatedTo CNGX_CHART_I18N
|
|
674
684
|
*/
|
|
675
685
|
const CNGX_CHART_LANGUAGE_EN = {
|
|
@@ -773,28 +783,21 @@ const chartBundle = createSectionBundle({
|
|
|
773
783
|
* at its default still follows the app locale at the use site, including a
|
|
774
784
|
* runtime `CNGX_LOCALE` flip.
|
|
775
785
|
*
|
|
776
|
-
* @category common/chart/i18n
|
|
777
786
|
* @wcag AA
|
|
778
787
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/i18n/chart-i18n.ts
|
|
779
|
-
* @since 0.
|
|
788
|
+
* @since 0.3.0
|
|
780
789
|
*/
|
|
781
790
|
const CNGX_CHART_I18N = new InjectionToken('CngxChartI18n', {
|
|
782
791
|
providedIn: 'root',
|
|
783
792
|
factory: () => chartBundle.build(),
|
|
784
793
|
});
|
|
785
|
-
/** @internal */
|
|
786
|
-
function defineChartI18nFeature(fn) {
|
|
787
|
-
return Object.assign(fn, { _target: 'i18n' });
|
|
788
|
-
}
|
|
789
794
|
/**
|
|
790
795
|
* Override chart copy via a partial bundle - unset keys keep the language
|
|
791
796
|
* pack's copy, or the English default, and keep following the app locale.
|
|
792
797
|
* Pass a `Signal` to switch the language at runtime.
|
|
793
|
-
*
|
|
794
|
-
* @category common/chart/i18n
|
|
795
798
|
*/
|
|
796
799
|
function withChartI18nLabels(overrides) {
|
|
797
|
-
return
|
|
800
|
+
return (bundle) => createOverrideMerge(bundle, overrides);
|
|
798
801
|
}
|
|
799
802
|
/**
|
|
800
803
|
* Provider for the chart i18n bundle. The features apply on top of the
|
|
@@ -810,8 +813,6 @@ function withChartI18nLabels(overrides) {
|
|
|
810
813
|
* ),
|
|
811
814
|
* ]
|
|
812
815
|
* ```
|
|
813
|
-
*
|
|
814
|
-
* @category common/chart/i18n
|
|
815
816
|
*/
|
|
816
817
|
function provideChartI18n(...features) {
|
|
817
818
|
return {
|
|
@@ -959,8 +960,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
959
960
|
/**
|
|
960
961
|
* Threshold (px) below which `CngxChartSlotContext.small` is true.
|
|
961
962
|
* Hardcoded for v1; later releases may make this a config token.
|
|
962
|
-
*
|
|
963
|
-
* @category common/chart
|
|
964
963
|
*/
|
|
965
964
|
const CHART_SMALL_BREAKPOINT_PX = 400;
|
|
966
965
|
/**
|
|
@@ -979,9 +978,8 @@ const CHART_SMALL_BREAKPOINT_PX = 400;
|
|
|
979
978
|
* </cngx-chart>
|
|
980
979
|
* ```
|
|
981
980
|
*
|
|
982
|
-
* @category common/chart
|
|
983
981
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
984
|
-
* @since 0.
|
|
982
|
+
* @since 0.3.0
|
|
985
983
|
* @relatedTo CngxChartSlotContext, CngxChartEmpty, CngxChartError, CngxChart
|
|
986
984
|
*/
|
|
987
985
|
class CngxChartLoading {
|
|
@@ -1011,9 +1009,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1011
1009
|
* </cngx-chart>
|
|
1012
1010
|
* ```
|
|
1013
1011
|
*
|
|
1014
|
-
* @category common/chart
|
|
1015
1012
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1016
|
-
* @since 0.
|
|
1013
|
+
* @since 0.3.0
|
|
1017
1014
|
* @relatedTo CngxChartSlotContext, CngxChartLoading, CngxChartError, CngxChart
|
|
1018
1015
|
*/
|
|
1019
1016
|
class CngxChartEmpty {
|
|
@@ -1040,9 +1037,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1040
1037
|
* </cngx-chart>
|
|
1041
1038
|
* ```
|
|
1042
1039
|
*
|
|
1043
|
-
* @category common/chart
|
|
1044
1040
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1045
|
-
* @since 0.
|
|
1041
|
+
* @since 0.3.0
|
|
1046
1042
|
* @relatedTo CngxChartErrorContext, CngxChartLoading, CngxChartEmpty, CngxChart
|
|
1047
1043
|
*/
|
|
1048
1044
|
class CngxChartError {
|
|
@@ -1071,9 +1067,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1071
1067
|
* </cngx-chart>
|
|
1072
1068
|
* ```
|
|
1073
1069
|
*
|
|
1074
|
-
* @category common/chart
|
|
1075
1070
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1076
|
-
* @since 0.
|
|
1071
|
+
* @since 0.3.0
|
|
1077
1072
|
* @relatedTo CngxChartConnectionContext, CngxChartReconnecting, CngxChart
|
|
1078
1073
|
*/
|
|
1079
1074
|
class CngxChartConnectionError {
|
|
@@ -1102,9 +1097,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1102
1097
|
* </cngx-chart>
|
|
1103
1098
|
* ```
|
|
1104
1099
|
*
|
|
1105
|
-
* @category common/chart
|
|
1106
1100
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1107
|
-
* @since 0.
|
|
1101
|
+
* @since 0.3.0
|
|
1108
1102
|
* @relatedTo CngxChartConnectionContext, CngxChartConnectionError, CngxChart
|
|
1109
1103
|
*/
|
|
1110
1104
|
class CngxChartReconnecting {
|
|
@@ -1161,9 +1155,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1161
1155
|
* SR data-table (the `aria-describedby` channel the chart already owns),
|
|
1162
1156
|
* not on an element projected here.
|
|
1163
1157
|
*
|
|
1164
|
-
* @category common/chart
|
|
1165
1158
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1166
|
-
* @since 0.
|
|
1159
|
+
* @since 0.3.0
|
|
1167
1160
|
* @relatedTo CngxChartSlotContext, CngxChartLoading, CngxChartEmpty, CngxChartError, CngxChart
|
|
1168
1161
|
*/
|
|
1169
1162
|
class CngxChartOverlay {
|
|
@@ -1333,9 +1326,8 @@ function significantChangeEqual(a, b) {
|
|
|
1333
1326
|
*
|
|
1334
1327
|
* @param summary the chart's `CngxChartSummary` signal.
|
|
1335
1328
|
*
|
|
1336
|
-
* @category common/chart
|
|
1337
1329
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/significant-change.ts
|
|
1338
|
-
* @since 0.
|
|
1330
|
+
* @since 0.3.0
|
|
1339
1331
|
*/
|
|
1340
1332
|
function createSignificantChangeTracker(summary) {
|
|
1341
1333
|
const pair = linkedSignal({ ...(ngDevMode ? { debugName: "pair" } : /* istanbul ignore next */ {}), source: summary,
|
|
@@ -1385,9 +1377,8 @@ function createSignificantChangeTracker(summary) {
|
|
|
1385
1377
|
* calls directly - no DI token, since the only second consumer today is a
|
|
1386
1378
|
* test double, which injects a fake `factory` through the deps.
|
|
1387
1379
|
*
|
|
1388
|
-
* @category common/chart/renderer
|
|
1389
1380
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/chart-renderer-controller.ts
|
|
1390
|
-
* @since 0.
|
|
1381
|
+
* @since 0.3.0
|
|
1391
1382
|
*/
|
|
1392
1383
|
function createChartRendererController(deps) {
|
|
1393
1384
|
let current = null;
|
|
@@ -1414,7 +1405,7 @@ function createChartRendererController(deps) {
|
|
|
1414
1405
|
forcedColors: forced,
|
|
1415
1406
|
});
|
|
1416
1407
|
current.mount(deps.host, deps.ctx);
|
|
1417
|
-
current.paint(deps.geometries());
|
|
1408
|
+
current.paint(deps.geometries(), deps.layerElements?.());
|
|
1418
1409
|
});
|
|
1419
1410
|
});
|
|
1420
1411
|
// Paint effect: repaint on geometry change; invalidate the color cache
|
|
@@ -1433,7 +1424,7 @@ function createChartRendererController(deps) {
|
|
|
1433
1424
|
lastDark = nextDark;
|
|
1434
1425
|
current?.invalidateColorCache?.();
|
|
1435
1426
|
}
|
|
1436
|
-
current?.paint(geometries);
|
|
1427
|
+
current?.paint(geometries, deps.layerElements?.());
|
|
1437
1428
|
});
|
|
1438
1429
|
});
|
|
1439
1430
|
deps.destroyRef.onDestroy(() => current?.destroy());
|
|
@@ -1487,8 +1478,8 @@ const stepMemo = new WeakMap();
|
|
|
1487
1478
|
/**
|
|
1488
1479
|
* @internal The forced-colors step of every geometry, `null` for the kinds
|
|
1489
1480
|
* outside the cycle. Line, bar and scatter count, area, threshold and band
|
|
1490
|
-
* do not
|
|
1491
|
-
*
|
|
1481
|
+
* do not. The SVG layers take the same steps
|
|
1482
|
+
* through `data-cngx-series-step`, so both backends count alike. Memoised by the
|
|
1492
1483
|
* array reference: the chart keeps the same geometries array while no
|
|
1493
1484
|
* layer emits a new geometry, so repaints without data (resize, DPR or
|
|
1494
1485
|
* palette flip) reuse the steps. A streaming chart gets a new array on
|
|
@@ -1580,8 +1571,13 @@ const SOLID_DASH = [];
|
|
|
1580
1571
|
* its 2D context: `Path2D` stroke/fill for line/area, per-mark loops for
|
|
1581
1572
|
* bar/scatter, `moveTo`/`lineTo` for threshold, `fillRect` for band.
|
|
1582
1573
|
*
|
|
1583
|
-
* Colors
|
|
1584
|
-
*
|
|
1574
|
+
* Colors and the numeric tokens (stroke width, opacities, point radius)
|
|
1575
|
+
* resolve through a closure-local cache keyed by layer element: the first
|
|
1576
|
+
* `paint()` reads each CSS custom property once per layer via
|
|
1577
|
+
* `getComputedStyle(layerHost)`, so a per-layer override (`style` on the
|
|
1578
|
+
* `<svg:g cngxLine>`) reaches the canvas exactly as it reaches the SVG marks,
|
|
1579
|
+
* and custom properties inherit, so a layer that sets nothing reads the chart
|
|
1580
|
+
* host's value. Without layer elements the chart host is read. Subsequent
|
|
1585
1581
|
* paints hit the cache, so the paint hot path performs zero synchronous
|
|
1586
1582
|
* DOM reads. {@link CngxChartRenderer.invalidateColorCache} clears it -
|
|
1587
1583
|
* the renderer controller calls it on a `dimensions()` change (a proxy
|
|
@@ -1615,13 +1611,10 @@ const SOLID_DASH = [];
|
|
|
1615
1611
|
* other engines are unverified, so the backend paints the probed values.
|
|
1616
1612
|
* The renderer controller watches `(forced-colors: active)` and
|
|
1617
1613
|
* `(prefers-color-scheme: dark)` and invalidates the colour cache before
|
|
1618
|
-
* repainting on a flip, so a contrast-theme switch repaints at once.
|
|
1619
|
-
* difference from SVG: a layer wrapped in an extra `<svg:g>` still counts
|
|
1620
|
-
* here, since the backend only sees the layer order.
|
|
1614
|
+
* repainting on a flip, so a contrast-theme switch repaints at once.
|
|
1621
1615
|
*
|
|
1622
|
-
* @category common/chart/renderer
|
|
1623
1616
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/canvas-renderer.ts
|
|
1624
|
-
* @since 0.
|
|
1617
|
+
* @since 0.3.0
|
|
1625
1618
|
*/
|
|
1626
1619
|
function createCanvasRenderer(deps) {
|
|
1627
1620
|
let canvas = null;
|
|
@@ -1630,9 +1623,13 @@ function createCanvasRenderer(deps) {
|
|
|
1630
1623
|
let lastW = -1;
|
|
1631
1624
|
let lastH = -1;
|
|
1632
1625
|
let lastGeometries = [];
|
|
1626
|
+
let lastElements;
|
|
1633
1627
|
let dprCleanup = null;
|
|
1634
|
-
|
|
1635
|
-
|
|
1628
|
+
// Keyed by the element the vars were read from (layer host, or the chart
|
|
1629
|
+
// host as fallback); replaced wholesale on invalidation.
|
|
1630
|
+
let colorCache = new WeakMap();
|
|
1631
|
+
let numberCache = new WeakMap();
|
|
1632
|
+
let styleCache = new WeakMap();
|
|
1636
1633
|
// Snapshot of deps.forcedColors, taken once per paint() so the per-mark
|
|
1637
1634
|
// colour lookups do not re-read the signal.
|
|
1638
1635
|
let forcedNow = false;
|
|
@@ -1642,23 +1639,43 @@ function createCanvasRenderer(deps) {
|
|
|
1642
1639
|
// Hatch patterns for the forced cycle, per palette and DPR.
|
|
1643
1640
|
let hatches = null;
|
|
1644
1641
|
let hatchDpr = -1;
|
|
1645
|
-
function readVar(name) {
|
|
1646
|
-
|
|
1642
|
+
function readVar(name, el) {
|
|
1643
|
+
if (!el) {
|
|
1644
|
+
return '';
|
|
1645
|
+
}
|
|
1646
|
+
let style = styleCache.get(el);
|
|
1647
|
+
if (!style) {
|
|
1648
|
+
style = getComputedStyle(el);
|
|
1649
|
+
styleCache.set(el, style);
|
|
1650
|
+
}
|
|
1651
|
+
return style.getPropertyValue(name).trim();
|
|
1652
|
+
}
|
|
1653
|
+
function cacheOf(cache, el) {
|
|
1654
|
+
let entries = cache.get(el);
|
|
1655
|
+
if (!entries) {
|
|
1656
|
+
entries = new Map();
|
|
1657
|
+
cache.set(el, entries);
|
|
1658
|
+
}
|
|
1659
|
+
return entries;
|
|
1647
1660
|
}
|
|
1648
1661
|
/**
|
|
1649
1662
|
* Read a numeric CSS custom property (e.g. `--cngx-area-opacity`,
|
|
1650
1663
|
* `--cngx-line-stroke-width`), cached like colors so the paint hot path
|
|
1651
1664
|
* stays free of synchronous DOM reads. Falls back when unset / unparseable.
|
|
1652
1665
|
*/
|
|
1653
|
-
function resolveNumberVar(name, fallback) {
|
|
1654
|
-
|
|
1666
|
+
function resolveNumberVar(name, fallback, el) {
|
|
1667
|
+
if (!el) {
|
|
1668
|
+
return fallback;
|
|
1669
|
+
}
|
|
1670
|
+
const entries = cacheOf(numberCache, el);
|
|
1671
|
+
const cached = entries.get(name);
|
|
1655
1672
|
if (cached !== undefined) {
|
|
1656
1673
|
return cached;
|
|
1657
1674
|
}
|
|
1658
|
-
const raw = readVar(name);
|
|
1675
|
+
const raw = readVar(name, el);
|
|
1659
1676
|
const parsed = raw ? parseFloat(raw) : NaN;
|
|
1660
1677
|
const value = Number.isFinite(parsed) ? parsed : fallback;
|
|
1661
|
-
|
|
1678
|
+
entries.set(name, value);
|
|
1662
1679
|
return value;
|
|
1663
1680
|
}
|
|
1664
1681
|
/**
|
|
@@ -1702,7 +1719,7 @@ function createCanvasRenderer(deps) {
|
|
|
1702
1719
|
return 0;
|
|
1703
1720
|
}
|
|
1704
1721
|
}
|
|
1705
|
-
function colorOf(color, kind) {
|
|
1722
|
+
function colorOf(color, kind, el) {
|
|
1706
1723
|
// Forced colors: every mark paints CanvasText, ignoring the [color]
|
|
1707
1724
|
// literal and the var chain (parity with the layers' !important rules).
|
|
1708
1725
|
if (forcedNow) {
|
|
@@ -1713,33 +1730,37 @@ function createCanvasRenderer(deps) {
|
|
|
1713
1730
|
if (color !== null && !color.startsWith('--')) {
|
|
1714
1731
|
return color;
|
|
1715
1732
|
}
|
|
1733
|
+
if (!el) {
|
|
1734
|
+
return 'currentColor';
|
|
1735
|
+
}
|
|
1736
|
+
const entries = cacheOf(colorCache, el);
|
|
1716
1737
|
const key = color ?? `@${kind}`;
|
|
1717
|
-
const cached =
|
|
1738
|
+
const cached = entries.get(key);
|
|
1718
1739
|
if (cached !== undefined) {
|
|
1719
1740
|
return cached;
|
|
1720
1741
|
}
|
|
1721
1742
|
let resolved = 'currentColor';
|
|
1722
1743
|
if (color !== null) {
|
|
1723
|
-
resolved = readVar(color) || 'currentColor';
|
|
1744
|
+
resolved = readVar(color, el) || 'currentColor';
|
|
1724
1745
|
}
|
|
1725
1746
|
else {
|
|
1726
1747
|
// Walk the per-atom -> family fallback chain, first hit wins.
|
|
1727
1748
|
for (const name of KIND_VARS[kind]) {
|
|
1728
|
-
const value = readVar(name);
|
|
1749
|
+
const value = readVar(name, el);
|
|
1729
1750
|
if (value) {
|
|
1730
1751
|
resolved = value;
|
|
1731
1752
|
break;
|
|
1732
1753
|
}
|
|
1733
1754
|
}
|
|
1734
1755
|
}
|
|
1735
|
-
|
|
1756
|
+
entries.set(key, resolved);
|
|
1736
1757
|
return resolved;
|
|
1737
1758
|
}
|
|
1738
|
-
function strokeWidthOf(sw) {
|
|
1759
|
+
function strokeWidthOf(sw, el) {
|
|
1739
1760
|
// Unset -> the same `--cngx-line-stroke-width` var the SVG line reads,
|
|
1740
1761
|
// so per-atom stroke width survives the SVG->Canvas crossover.
|
|
1741
1762
|
if (sw === null) {
|
|
1742
|
-
return resolveNumberVar('--cngx-line-stroke-width', DEFAULT_STROKE_WIDTH);
|
|
1763
|
+
return resolveNumberVar('--cngx-line-stroke-width', DEFAULT_STROKE_WIDTH, el);
|
|
1743
1764
|
}
|
|
1744
1765
|
const n = typeof sw === 'number' ? sw : parseFloat(sw);
|
|
1745
1766
|
return Number.isFinite(n) ? n : DEFAULT_STROKE_WIDTH;
|
|
@@ -1749,12 +1770,12 @@ function createCanvasRenderer(deps) {
|
|
|
1749
1770
|
* as filled arcs in the layer's resolved colour. Same colour path as
|
|
1750
1771
|
* the stroke / fill so no second colour resolution is introduced.
|
|
1751
1772
|
*/
|
|
1752
|
-
function drawPointMarks(c, points, color, kind, radiusVar) {
|
|
1773
|
+
function drawPointMarks(c, points, color, kind, radiusVar, el) {
|
|
1753
1774
|
if (!points || points.length === 0) {
|
|
1754
1775
|
return;
|
|
1755
1776
|
}
|
|
1756
|
-
const r = resolveNumberVar(radiusVar, DEFAULT_POINT_RADIUS);
|
|
1757
|
-
c.fillStyle = colorOf(color, kind);
|
|
1777
|
+
const r = resolveNumberVar(radiusVar, DEFAULT_POINT_RADIUS, el);
|
|
1778
|
+
c.fillStyle = colorOf(color, kind, el);
|
|
1758
1779
|
for (const p of points) {
|
|
1759
1780
|
c.beginPath();
|
|
1760
1781
|
c.arc(p.cx, p.cy, r, 0, Math.PI * 2);
|
|
@@ -1799,7 +1820,7 @@ function createCanvasRenderer(deps) {
|
|
|
1799
1820
|
const onChange = () => {
|
|
1800
1821
|
dprCleanup?.();
|
|
1801
1822
|
dprCleanup = null;
|
|
1802
|
-
paint(lastGeometries);
|
|
1823
|
+
paint(lastGeometries, lastElements);
|
|
1803
1824
|
watchDpr();
|
|
1804
1825
|
};
|
|
1805
1826
|
mql.addEventListener('change', onChange, { once: true });
|
|
@@ -1823,8 +1844,9 @@ function createCanvasRenderer(deps) {
|
|
|
1823
1844
|
// flip and on the chart's DestroyRef). Self-registering here would
|
|
1824
1845
|
// pile up one never-unregistered closure per svg<->canvas flip.
|
|
1825
1846
|
}
|
|
1826
|
-
function paint(geometries) {
|
|
1847
|
+
function paint(geometries, elements) {
|
|
1827
1848
|
lastGeometries = geometries;
|
|
1849
|
+
lastElements = elements;
|
|
1828
1850
|
const c = ctx2d;
|
|
1829
1851
|
if (!canvas || !c) {
|
|
1830
1852
|
return;
|
|
@@ -1835,14 +1857,14 @@ function createCanvasRenderer(deps) {
|
|
|
1835
1857
|
c.clearRect(0, 0, width, height);
|
|
1836
1858
|
const steps = forcedNow ? forcedSeriesSteps(geometries) : null;
|
|
1837
1859
|
for (let i = 0; i < geometries.length; i++) {
|
|
1838
|
-
paintOne(c, geometries[i], steps?.[i] ?? null);
|
|
1860
|
+
paintOne(c, geometries[i], steps?.[i] ?? null, elements?.[i] ?? hostEl);
|
|
1839
1861
|
}
|
|
1840
1862
|
}
|
|
1841
|
-
function paintOne(c, g, step) {
|
|
1863
|
+
function paintOne(c, g, step, el) {
|
|
1842
1864
|
switch (g.kind) {
|
|
1843
1865
|
case 'line': {
|
|
1844
|
-
c.strokeStyle = colorOf(g.color, 'line');
|
|
1845
|
-
c.lineWidth = strokeWidthOf(g.strokeWidth);
|
|
1866
|
+
c.strokeStyle = colorOf(g.color, 'line', el);
|
|
1867
|
+
c.lineWidth = strokeWidthOf(g.strokeWidth, el);
|
|
1846
1868
|
c.lineJoin = 'round';
|
|
1847
1869
|
c.lineCap = 'round';
|
|
1848
1870
|
// Forced colors: the legend's dash for this series step (round caps
|
|
@@ -1854,15 +1876,16 @@ function createCanvasRenderer(deps) {
|
|
|
1854
1876
|
if (step !== null) {
|
|
1855
1877
|
c.setLineDash(SOLID_DASH);
|
|
1856
1878
|
}
|
|
1857
|
-
drawPointMarks(c, g.points, g.color, 'line', '--cngx-line-point-radius');
|
|
1879
|
+
drawPointMarks(c, g.points, g.color, 'line', '--cngx-line-point-radius', el);
|
|
1858
1880
|
break;
|
|
1859
1881
|
}
|
|
1860
1882
|
case 'area': {
|
|
1861
|
-
c.fillStyle = colorOf(g.color, 'area');
|
|
1862
|
-
c.globalAlpha =
|
|
1883
|
+
c.fillStyle = colorOf(g.color, 'area', el);
|
|
1884
|
+
c.globalAlpha =
|
|
1885
|
+
g.opacity ?? resolveNumberVar('--cngx-area-opacity', DEFAULT_AREA_OPACITY, el);
|
|
1863
1886
|
c.fill(new Path2D(g.d));
|
|
1864
1887
|
c.globalAlpha = 1;
|
|
1865
|
-
drawPointMarks(c, g.points, g.color, 'area', '--cngx-area-point-radius');
|
|
1888
|
+
drawPointMarks(c, g.points, g.color, 'area', '--cngx-area-point-radius', el);
|
|
1866
1889
|
break;
|
|
1867
1890
|
}
|
|
1868
1891
|
case 'bar': {
|
|
@@ -1873,7 +1896,7 @@ function createCanvasRenderer(deps) {
|
|
|
1873
1896
|
}
|
|
1874
1897
|
for (const r of g.rects) {
|
|
1875
1898
|
if (step === null) {
|
|
1876
|
-
c.fillStyle = colorOf(r.color, 'bar');
|
|
1899
|
+
c.fillStyle = colorOf(r.color, 'bar', el);
|
|
1877
1900
|
}
|
|
1878
1901
|
c.fillRect(r.x, r.y, r.w, r.h);
|
|
1879
1902
|
if (ring > 0) {
|
|
@@ -1890,7 +1913,7 @@ function createCanvasRenderer(deps) {
|
|
|
1890
1913
|
}
|
|
1891
1914
|
for (const m of g.marks) {
|
|
1892
1915
|
if (step === null) {
|
|
1893
|
-
c.fillStyle = colorOf(m.color, 'scatter');
|
|
1916
|
+
c.fillStyle = colorOf(m.color, 'scatter', el);
|
|
1894
1917
|
}
|
|
1895
1918
|
c.beginPath();
|
|
1896
1919
|
c.arc(m.cx, m.cy, m.r, 0, Math.PI * 2);
|
|
@@ -1902,7 +1925,7 @@ function createCanvasRenderer(deps) {
|
|
|
1902
1925
|
break;
|
|
1903
1926
|
}
|
|
1904
1927
|
case 'threshold': {
|
|
1905
|
-
c.strokeStyle = colorOf(g.color, 'threshold');
|
|
1928
|
+
c.strokeStyle = colorOf(g.color, 'threshold', el);
|
|
1906
1929
|
c.lineWidth = 1;
|
|
1907
1930
|
c.setLineDash(g.dashed ? [4, 3] : []);
|
|
1908
1931
|
c.beginPath();
|
|
@@ -1913,8 +1936,9 @@ function createCanvasRenderer(deps) {
|
|
|
1913
1936
|
break;
|
|
1914
1937
|
}
|
|
1915
1938
|
case 'band': {
|
|
1916
|
-
c.fillStyle = colorOf(g.color, 'band');
|
|
1917
|
-
c.globalAlpha =
|
|
1939
|
+
c.fillStyle = colorOf(g.color, 'band', el);
|
|
1940
|
+
c.globalAlpha =
|
|
1941
|
+
g.opacity ?? resolveNumberVar('--cngx-band-opacity', DEFAULT_BAND_OPACITY, el);
|
|
1918
1942
|
c.fillRect(g.x, g.y, g.w, g.h);
|
|
1919
1943
|
c.globalAlpha = 1;
|
|
1920
1944
|
break;
|
|
@@ -1922,8 +1946,9 @@ function createCanvasRenderer(deps) {
|
|
|
1922
1946
|
}
|
|
1923
1947
|
}
|
|
1924
1948
|
function invalidateColorCache() {
|
|
1925
|
-
colorCache
|
|
1926
|
-
numberCache
|
|
1949
|
+
colorCache = new WeakMap();
|
|
1950
|
+
numberCache = new WeakMap();
|
|
1951
|
+
styleCache = new WeakMap();
|
|
1927
1952
|
sysColors = null;
|
|
1928
1953
|
hatches = null;
|
|
1929
1954
|
}
|
|
@@ -1931,6 +1956,7 @@ function createCanvasRenderer(deps) {
|
|
|
1931
1956
|
dprCleanup?.();
|
|
1932
1957
|
dprCleanup = null;
|
|
1933
1958
|
lastGeometries = [];
|
|
1959
|
+
lastElements = undefined;
|
|
1934
1960
|
canvas?.remove();
|
|
1935
1961
|
canvas = null;
|
|
1936
1962
|
probe?.remove();
|
|
@@ -1939,8 +1965,9 @@ function createCanvasRenderer(deps) {
|
|
|
1939
1965
|
hostEl = null;
|
|
1940
1966
|
lastW = -1;
|
|
1941
1967
|
lastH = -1;
|
|
1942
|
-
colorCache
|
|
1943
|
-
numberCache
|
|
1968
|
+
colorCache = new WeakMap();
|
|
1969
|
+
numberCache = new WeakMap();
|
|
1970
|
+
styleCache = new WeakMap();
|
|
1944
1971
|
sysColors = null;
|
|
1945
1972
|
hatches = null;
|
|
1946
1973
|
}
|
|
@@ -1963,9 +1990,8 @@ function createCanvasRenderer(deps) {
|
|
|
1963
1990
|
* @param _deps unused; kept for factory signature symmetry with
|
|
1964
1991
|
* {@link createCanvasRenderer}.
|
|
1965
1992
|
*
|
|
1966
|
-
* @category common/chart/renderer
|
|
1967
1993
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/svg-renderer.ts
|
|
1968
|
-
* @since 0.
|
|
1994
|
+
* @since 0.3.0
|
|
1969
1995
|
*/
|
|
1970
1996
|
function createSvgRenderer(_deps) {
|
|
1971
1997
|
const noop = () => undefined;
|
|
@@ -1987,9 +2013,8 @@ function createSvgRenderer(_deps) {
|
|
|
1987
2013
|
* bare provider) to tune the SVG/Canvas crossover for a given app's
|
|
1988
2014
|
* hardware profile.
|
|
1989
2015
|
*
|
|
1990
|
-
* @category common/chart/renderer
|
|
1991
2016
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-threshold.ts
|
|
1992
|
-
* @since 0.
|
|
2017
|
+
* @since 0.3.0
|
|
1993
2018
|
* @relatedTo provideChartRenderer, withChartRendererThreshold
|
|
1994
2019
|
*/
|
|
1995
2020
|
const CNGX_CHART_RENDERER_THRESHOLD = new InjectionToken('CngxChartRendererThreshold', { providedIn: 'root', factory: () => 500 });
|
|
@@ -2001,9 +2026,8 @@ const CNGX_CHART_RENDERER_THRESHOLD = new InjectionToken('CngxChartRendererThres
|
|
|
2001
2026
|
* (WebGL, ...) supplies a whole replacement via
|
|
2002
2027
|
* {@link withChartRendererFactory}.
|
|
2003
2028
|
*
|
|
2004
|
-
* @category common/chart/renderer
|
|
2005
2029
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2006
|
-
* @since 0.
|
|
2030
|
+
* @since 0.3.0
|
|
2007
2031
|
*/
|
|
2008
2032
|
const createDefaultChartRenderer = (mode, deps) => mode === 'svg' ? createSvgRenderer(deps) : createCanvasRenderer(deps);
|
|
2009
2033
|
/**
|
|
@@ -2012,18 +2036,16 @@ const createDefaultChartRenderer = (mode, deps) => mode === 'svg' ? createSvgRen
|
|
|
2012
2036
|
* {@link withChartRendererFactory} to add a backend without touching layer
|
|
2013
2037
|
* atoms.
|
|
2014
2038
|
*
|
|
2015
|
-
* @category common/chart/renderer
|
|
2016
2039
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2017
|
-
* @since 0.
|
|
2040
|
+
* @since 0.3.0
|
|
2018
2041
|
* @relatedTo provideChartRenderer, withChartRendererFactory
|
|
2019
2042
|
*/
|
|
2020
2043
|
const CNGX_CHART_RENDERER_FACTORY = new InjectionToken('CngxChartRendererFactory', { providedIn: 'root', factory: () => createDefaultChartRenderer });
|
|
2021
2044
|
/**
|
|
2022
2045
|
* Override the SVG->Canvas auto-switch cutoff (default `500`).
|
|
2023
2046
|
*
|
|
2024
|
-
* @category common/chart/renderer
|
|
2025
2047
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2026
|
-
* @since 0.
|
|
2048
|
+
* @since 0.3.0
|
|
2027
2049
|
*/
|
|
2028
2050
|
function withChartRendererThreshold(n) {
|
|
2029
2051
|
return { providers: [{ provide: CNGX_CHART_RENDERER_THRESHOLD, useValue: n }] };
|
|
@@ -2033,9 +2055,8 @@ function withChartRendererThreshold(n) {
|
|
|
2033
2055
|
* third. Consumers wanting a heuristic swap supply a custom factory here
|
|
2034
2056
|
* (the heuristic-swap axis ships no dedicated token at v2).
|
|
2035
2057
|
*
|
|
2036
|
-
* @category common/chart/renderer
|
|
2037
2058
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2038
|
-
* @since 0.
|
|
2059
|
+
* @since 0.3.0
|
|
2039
2060
|
*/
|
|
2040
2061
|
function withChartRendererFactory(fn) {
|
|
2041
2062
|
return { providers: [{ provide: CNGX_CHART_RENDERER_FACTORY, useValue: fn }] };
|
|
@@ -2049,15 +2070,16 @@ function withChartRendererFactory(fn) {
|
|
|
2049
2070
|
* provideChartRenderer(withChartRendererThreshold(2000))
|
|
2050
2071
|
* ```
|
|
2051
2072
|
*
|
|
2052
|
-
* @category common/chart/renderer
|
|
2053
2073
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2054
|
-
* @since 0.
|
|
2074
|
+
* @since 0.3.0
|
|
2055
2075
|
* @relatedTo withChartRendererThreshold, withChartRendererFactory
|
|
2056
2076
|
*/
|
|
2057
2077
|
function provideChartRenderer(...features) {
|
|
2058
2078
|
return features.flatMap((f) => f.providers);
|
|
2059
2079
|
}
|
|
2060
2080
|
|
|
2081
|
+
/** @internal `Node.ELEMENT_NODE`, without reaching for the DOM global on the server. */
|
|
2082
|
+
const ELEMENT_NODE = 1;
|
|
2061
2083
|
/** @internal */
|
|
2062
2084
|
const NOOP_SCALE = () => 0;
|
|
2063
2085
|
/** @internal */
|
|
@@ -2136,40 +2158,50 @@ const DEFAULT_SUMMARY_ACCESSOR = (d) => Number(d);
|
|
|
2136
2158
|
* consumer restyling `--cngx-axis-font-size` gets labels at their own
|
|
2137
2159
|
* size inside a gutter sized for the default.
|
|
2138
2160
|
*
|
|
2139
|
-
* @category common/chart
|
|
2140
|
-
* @docsKind primary
|
|
2141
2161
|
* @wcag AA
|
|
2142
2162
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart.component.ts
|
|
2143
|
-
* @since 0.
|
|
2163
|
+
* @since 0.3.0
|
|
2144
2164
|
* @relatedTo CngxAxis, CngxLine, CngxArea, CngxBar, CngxChartLegend
|
|
2145
2165
|
*
|
|
2146
|
-
* <example-url
|
|
2147
|
-
* <example-url
|
|
2148
|
-
* <example-url
|
|
2149
|
-
* <example-url
|
|
2150
|
-
* <example-url
|
|
2151
|
-
* <example-url
|
|
2152
|
-
* <example-url
|
|
2153
|
-
* <example-url
|
|
2166
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
2167
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
2168
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
2169
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
2170
|
+
* <example-url>/#/common/chart/primitives/overlay-aligned-to-the-plot</example-url>
|
|
2171
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
2172
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
2173
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
2154
2174
|
* @slot cngxChartLoading Replaces the centred spinner shown during the first load.
|
|
2155
2175
|
* @slot cngxChartEmpty Rendered when the data resolves to nothing.
|
|
2156
2176
|
* @slot cngxChartError Rendered when the load fails; gets the error.
|
|
2157
2177
|
* @slot cngxChartConnectionError Rendered over the chart when the live connection drops.
|
|
2158
2178
|
* @slot cngxChartReconnecting Rendered over the chart while the connection retries.
|
|
2159
2179
|
* @slot cngxChartOverlay HTML layered over the marks in the content view; the chart insets it to the plot area, pointer-events off by default.
|
|
2180
|
+
* @axis level organism
|
|
2160
2181
|
*/
|
|
2161
2182
|
class CngxChart {
|
|
2162
2183
|
/**
|
|
2163
|
-
*
|
|
2164
|
-
*
|
|
2165
|
-
*
|
|
2166
|
-
* call `this.ctx.data<T>()` to narrow without per-site casts.
|
|
2167
|
-
*
|
|
2168
|
-
* @internal - alias for the public `data<U>()` method
|
|
2184
|
+
* The rows the chart plots, bound as `[data]`; required. Layer atoms read them through the
|
|
2185
|
+
* `data<U>()` method below, which narrows the row type without per-site casts, so consumer markup
|
|
2186
|
+
* stays `<cngx-chart [data]="rows">`.
|
|
2169
2187
|
*/
|
|
2170
2188
|
dataInput = input.required({ ...(ngDevMode ? { debugName: "dataInput" } : /* istanbul ignore next */ {}), alias: 'data' });
|
|
2189
|
+
/**
|
|
2190
|
+
* Fixed width of the chart in px, applied as the host's inline width and as the SVG viewBox width.
|
|
2191
|
+
* Unset, the width is measured from the host; with `[height]` unset too the chart runs in
|
|
2192
|
+
* responsive mode and fills its parent.
|
|
2193
|
+
*/
|
|
2171
2194
|
width = input(undefined, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2195
|
+
/**
|
|
2196
|
+
* Fixed height of the chart in px, used as the SVG viewBox height. Unset, the height is measured
|
|
2197
|
+
* from the host; with both `[width]` and `[height]` bound the host also gets `aspect-ratio: width
|
|
2198
|
+
* / height`.
|
|
2199
|
+
*/
|
|
2172
2200
|
height = input(undefined, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2201
|
+
/**
|
|
2202
|
+
* Value of the SVG `preserveAspectRatio` attribute, which decides how the viewBox is fitted when
|
|
2203
|
+
* the host box has a different aspect ratio. Default `'xMidYMid meet'`.
|
|
2204
|
+
*/
|
|
2173
2205
|
preserveAspectRatio = input('xMidYMid meet', ...(ngDevMode ? [{ debugName: "preserveAspectRatio" }] : /* istanbul ignore next */ []));
|
|
2174
2206
|
/**
|
|
2175
2207
|
* Optional explicit `aria-label` override. When set, supersedes the
|
|
@@ -2226,6 +2258,16 @@ class CngxChart {
|
|
|
2226
2258
|
axes = contentChildren(CNGX_CHART_AXIS, { ...(ngDevMode ? { debugName: "axes" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2227
2259
|
thresholds = contentChildren(CngxThreshold, { ...(ngDevMode ? { debugName: "thresholds" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2228
2260
|
layers = contentChildren(CNGX_CHART_LAYER, { ...(ngDevMode ? { debugName: "layers" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2261
|
+
// Same predicate and order as `layers`: node i hosts layer i. The
|
|
2262
|
+
// Canvas backend resolves per-layer tokens against these elements. A
|
|
2263
|
+
// custom layer on an `<ng-container>` has a comment node as its host,
|
|
2264
|
+
// which has no computed style, so it reads the chart host instead.
|
|
2265
|
+
layerHosts = contentChildren(CNGX_CHART_LAYER, { ...(ngDevMode ? { debugName: "layerHosts" } : /* istanbul ignore next */ {}), descendants: true,
|
|
2266
|
+
read: ElementRef });
|
|
2267
|
+
layerElements = computed(() => this.layerHosts().map((r) => {
|
|
2268
|
+
const node = r.nativeElement;
|
|
2269
|
+
return node.nodeType === ELEMENT_NODE ? node : this.hostEl.nativeElement;
|
|
2270
|
+
}), { ...(ngDevMode ? { debugName: "layerElements" } : /* istanbul ignore next */ {}), equal: sameItemsArr });
|
|
2229
2271
|
i18n = injectChartI18n();
|
|
2230
2272
|
dataTableId = nextUid('cngx-chart-data-table');
|
|
2231
2273
|
hatchId = nextUid('cngx-chart-hatch');
|
|
@@ -2241,8 +2283,9 @@ class CngxChart {
|
|
|
2241
2283
|
overlaySlot = contentChild(CngxChartOverlay, ...(ngDevMode ? [{ debugName: "overlaySlot" }] : /* istanbul ignore next */ []));
|
|
2242
2284
|
// Only the first overlay renders (contentChild above). This parallel
|
|
2243
2285
|
// query exists solely to warn in dev when a consumer projects more
|
|
2244
|
-
// than one, since the extra templates drop silently otherwise.
|
|
2245
|
-
|
|
2286
|
+
// than one, since the extra templates drop silently otherwise. Descendants,
|
|
2287
|
+
// like the contentChild above, so a nested second overlay is counted too.
|
|
2288
|
+
overlaySlots = contentChildren(CngxChartOverlay, { ...(ngDevMode ? { debugName: "overlaySlots" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2246
2289
|
/** Resolved consumer-projected loading template (null when no slot bound). */
|
|
2247
2290
|
loadingTpl = computed(() => this.loadingSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "loadingTpl" }] : /* istanbul ignore next */ []));
|
|
2248
2291
|
/** Resolved consumer-projected empty template (null when no slot bound). */
|
|
@@ -2373,10 +2416,11 @@ class CngxChart {
|
|
|
2373
2416
|
ctx: this,
|
|
2374
2417
|
mode: this.renderMode,
|
|
2375
2418
|
geometries: this.geometries,
|
|
2419
|
+
layerElements: this.layerElements,
|
|
2376
2420
|
factory: this.rendererFactory,
|
|
2377
2421
|
destroyRef: this.destroyRef,
|
|
2378
2422
|
});
|
|
2379
|
-
if (
|
|
2423
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
2380
2424
|
afterNextRender(() => {
|
|
2381
2425
|
if (this.summaryAccessor() !== DEFAULT_SUMMARY_ACCESSOR) {
|
|
2382
2426
|
return;
|
|
@@ -2389,13 +2433,14 @@ class CngxChart {
|
|
|
2389
2433
|
if (Number.isFinite(projected)) {
|
|
2390
2434
|
return;
|
|
2391
2435
|
}
|
|
2392
|
-
|
|
2436
|
+
cngxDevWarn('CNGX1007', '[cngx-chart] data is non-numeric and no [summaryAccessor] is bound. ' +
|
|
2393
2437
|
'Auto-Summary and the SR data-table will silently fall back to NaN. ' +
|
|
2394
|
-
'Bind [summaryAccessor]=
|
|
2438
|
+
'Bind [summaryAccessor] to a stable component field (summaryAccessor = (d: Row) => d.value) ' +
|
|
2439
|
+
'or pass a numeric data array.');
|
|
2395
2440
|
});
|
|
2396
2441
|
afterNextRender(() => {
|
|
2397
2442
|
if (this.overlaySlots().length > 1) {
|
|
2398
|
-
|
|
2443
|
+
cngxDevWarn('CNGX1008', '[cngx-chart] more than one *cngxChartOverlay projected; only the first renders. ' +
|
|
2399
2444
|
'Compose multiple overlays inside a single overlay template.');
|
|
2400
2445
|
}
|
|
2401
2446
|
});
|
|
@@ -2404,7 +2449,7 @@ class CngxChart {
|
|
|
2404
2449
|
const horizontal = axes.filter((a) => isHorizontalPosition(a.position()));
|
|
2405
2450
|
const vertical = axes.filter((a) => isVerticalPosition(a.position()));
|
|
2406
2451
|
if (horizontal.length > 1 || vertical.length > 1) {
|
|
2407
|
-
|
|
2452
|
+
cngxDevWarn('CNGX1009', '[cngx-chart] multiple axes share one orientation; only the first drives ' +
|
|
2408
2453
|
'the scale, the rest render their line and ticks but their [domain] ' +
|
|
2409
2454
|
'is silently ignored. Mount one X and one Y axis per chart.');
|
|
2410
2455
|
}
|
|
@@ -2569,6 +2614,17 @@ class CngxChart {
|
|
|
2569
2614
|
* element-wise-equal and the paint cascade short-circuits.
|
|
2570
2615
|
*/
|
|
2571
2616
|
geometries = computed(() => this.layers().map((l) => l.geometry()), { ...(ngDevMode ? { debugName: "geometries" } : /* istanbul ignore next */ {}), equal: sameItemsArr });
|
|
2617
|
+
/**
|
|
2618
|
+
* Forced-colors series step per layer, the rule the Canvas backend
|
|
2619
|
+
* paints by. Element-wise guarded: a data tick re-emits the same steps,
|
|
2620
|
+
* so the layers' `data-cngx-series-step` bindings stay untouched.
|
|
2621
|
+
*/
|
|
2622
|
+
seriesSteps = computed(() => forcedSeriesSteps(this.geometries()), { ...(ngDevMode ? { debugName: "seriesSteps" } : /* istanbul ignore next */ {}), equal: sameItemsArr });
|
|
2623
|
+
/** See {@link CngxChartContext.seriesStepOf}. */
|
|
2624
|
+
seriesStepOf(layer) {
|
|
2625
|
+
const index = this.layers().indexOf(layer);
|
|
2626
|
+
return index < 0 ? null : (this.seriesSteps()[index] ?? null);
|
|
2627
|
+
}
|
|
2572
2628
|
viewBox = computed(() => {
|
|
2573
2629
|
const { width, height } = this.dimensions();
|
|
2574
2630
|
return `0 0 ${width || 0} ${height || 0}`;
|
|
@@ -2735,7 +2791,7 @@ class CngxChart {
|
|
|
2735
2791
|
return this.dataInput().length > 1;
|
|
2736
2792
|
}, ...(ngDevMode ? [{ debugName: "tableActive" }] : /* istanbul ignore next */ []));
|
|
2737
2793
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2738
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxChart, isStandalone: true, selector: "cngx-chart", inputs: { dataInput: { classPropertyName: "dataInput", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, preserveAspectRatio: { classPropertyName: "preserveAspectRatio", publicName: "preserveAspectRatio", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, summaryAccessor: { classPropertyName: "summaryAccessor", publicName: "summaryAccessor", isSignal: true, isRequired: false, transformFunction: null }, accessibleTable: { classPropertyName: "accessibleTable", publicName: "accessibleTable", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, connectionState: { classPropertyName: "connectionState", publicName: "connectionState", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "attr.aria-label": "ariaLabelText()", "attr.aria-describedby": "dataTableId", "attr.aria-busy": "busy() ? \"true\" : null", "class.cngx-chart--responsive": "isResponsive()", "class.cngx-chart--content-hidden": "contentHidden()", "style.width.px": "width() ?? null", "style.aspect-ratio": "explicitAspectRatio()", "style.--cngx-chart-plot-block-start": "plotVars().blockStart", "style.--cngx-chart-plot-block-end": "plotVars().blockEnd", "style.--cngx-chart-plot-inline-start": "plotVars().inlineStart", "style.--cngx-chart-plot-inline-end": "plotVars().inlineEnd", "style.--_cngx-chart-hatch-diagonal": "hatchFill.diagonal", "style.--_cngx-chart-hatch-horizontal": "hatchFill.horizontal" } }, providers: [{ provide: CNGX_CHART_CONTEXT, useExisting: CngxChart }], queries: [{ propertyName: "axes", predicate: CNGX_CHART_AXIS, descendants: true, isSignal: true }, { propertyName: "thresholds", predicate: CngxThreshold, descendants: true, isSignal: true }, { propertyName: "layers", predicate: CNGX_CHART_LAYER, descendants: true, isSignal: true }, { propertyName: "loadingSlot", first: true, predicate: CngxChartLoading, descendants: true, isSignal: true }, { propertyName: "emptySlot", first: true, predicate: CngxChartEmpty, descendants: true, isSignal: true }, { propertyName: "errorSlot", first: true, predicate: CngxChartError, descendants: true, isSignal: true }, { propertyName: "connectionErrorSlot", first: true, predicate: CngxChartConnectionError, descendants: true, isSignal: true }, { propertyName: "reconnectingSlot", first: true, predicate: CngxChartReconnecting, descendants: true, isSignal: true }, { propertyName: "overlaySlot", first: true, predicate: CngxChartOverlay, descendants: true, isSignal: true }, { propertyName: "overlaySlots", predicate: CngxChartOverlay, isSignal: true }], exportAs: ["cngxChart"], hostDirectives: [{ directive: i1.CngxResizeObserver }], ngImport: i0, template: `
|
|
2794
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxChart, isStandalone: true, selector: "cngx-chart", inputs: { dataInput: { classPropertyName: "dataInput", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, preserveAspectRatio: { classPropertyName: "preserveAspectRatio", publicName: "preserveAspectRatio", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, summaryAccessor: { classPropertyName: "summaryAccessor", publicName: "summaryAccessor", isSignal: true, isRequired: false, transformFunction: null }, accessibleTable: { classPropertyName: "accessibleTable", publicName: "accessibleTable", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, connectionState: { classPropertyName: "connectionState", publicName: "connectionState", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "attr.aria-label": "ariaLabelText()", "attr.aria-describedby": "dataTableId", "attr.aria-busy": "busy() ? \"true\" : null", "class.cngx-chart--responsive": "isResponsive()", "class.cngx-chart--content-hidden": "contentHidden()", "style.width.px": "width() ?? null", "style.aspect-ratio": "explicitAspectRatio()", "style.--cngx-chart-plot-block-start": "plotVars().blockStart", "style.--cngx-chart-plot-block-end": "plotVars().blockEnd", "style.--cngx-chart-plot-inline-start": "plotVars().inlineStart", "style.--cngx-chart-plot-inline-end": "plotVars().inlineEnd", "style.--_cngx-chart-hatch-diagonal": "hatchFill.diagonal", "style.--_cngx-chart-hatch-horizontal": "hatchFill.horizontal" } }, providers: [{ provide: CNGX_CHART_CONTEXT, useExisting: CngxChart }], queries: [{ propertyName: "axes", predicate: CNGX_CHART_AXIS, descendants: true, isSignal: true }, { propertyName: "thresholds", predicate: CngxThreshold, descendants: true, isSignal: true }, { propertyName: "layers", predicate: CNGX_CHART_LAYER, descendants: true, isSignal: true }, { propertyName: "layerHosts", predicate: CNGX_CHART_LAYER, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "loadingSlot", first: true, predicate: CngxChartLoading, descendants: true, isSignal: true }, { propertyName: "emptySlot", first: true, predicate: CngxChartEmpty, descendants: true, isSignal: true }, { propertyName: "errorSlot", first: true, predicate: CngxChartError, descendants: true, isSignal: true }, { propertyName: "connectionErrorSlot", first: true, predicate: CngxChartConnectionError, descendants: true, isSignal: true }, { propertyName: "reconnectingSlot", first: true, predicate: CngxChartReconnecting, descendants: true, isSignal: true }, { propertyName: "overlaySlot", first: true, predicate: CngxChartOverlay, descendants: true, isSignal: true }, { propertyName: "overlaySlots", predicate: CngxChartOverlay, descendants: true, isSignal: true }], exportAs: ["cngxChart"], hostDirectives: [{ directive: i1.CngxResizeObserver }], ngImport: i0, template: `
|
|
2739
2795
|
@switch (activeView()) {
|
|
2740
2796
|
@case ('skeleton') {
|
|
2741
2797
|
@if (loadingTpl(); as tpl) {
|
|
@@ -2964,7 +3020,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2964
3020
|
[hidden]="!tableActive() || activeView() !== 'content'"
|
|
2965
3021
|
/>
|
|
2966
3022
|
`, styles: ["@layer cngx.tokens{@property --cngx-chart-primary{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}@property --cngx-chart-secondary{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .02 250);}@property --cngx-chart-danger{syntax: \"<color>\"; inherits: true; initial-value: oklch(.55 .18 25);}@property --cngx-chart-success{syntax: \"<color>\"; inherits: true; initial-value: oklch(.55 .15 145);}@property --cngx-chart-grid-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.92 .005 250);}@property --cngx-chart-axis-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .015 250);}@property --cngx-chart-text-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.25 .015 250);}@property --cngx-chart-aspect-ratio{syntax: \"*\"; inherits: true; initial-value: 5 / 2;}}:root{--cngx-chart-primary: var(--accent, var(--cngx-color-primary, oklch(.66 .19 50)));--cngx-chart-secondary: var( --accent-secondary, var(--cngx-color-text-muted, oklch(.65 .02 250)) );--cngx-chart-danger: var(--danger, var(--cngx-color-danger, oklch(.55 .18 25)));--cngx-chart-success: var(--success, var(--cngx-color-success, oklch(.55 .15 145)));--cngx-chart-grid-color: color-mix(in oklch, currentColor 14%, transparent);--cngx-chart-axis-color: var( --text-secondary, var(--cngx-color-text-muted, oklch(.5 .015 250)) );--cngx-chart-text-color: var(--text-primary, var(--cngx-color-text, oklch(.25 .015 250)));--cngx-skeleton-bg: color-mix(in oklch, currentColor 14%, transparent);--cngx-chart-numeric-bidi: isolate}@media(forced-colors:active){cngx-mini-bar.cngx-mini-bar .cngx-mini-bar__track,cngx-bullet.cngx-bullet .cngx-bullet__track,cngx-deviation-bar.cngx-deviation-bar .cngx-deviation-bar__track,cngx-stacked-bar.cngx-stacked-bar .cngx-stacked-bar__track{background:Canvas}cngx-mini-bar.cngx-mini-bar .cngx-mini-bar__track:after,cngx-bullet.cngx-bullet .cngx-bullet__track:after,cngx-deviation-bar.cngx-deviation-bar .cngx-deviation-bar__track:after,cngx-stacked-bar.cngx-stacked-bar .cngx-stacked-bar__track:after{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none;forced-color-adjust:none;box-shadow:inset 0 0 0 1px CanvasText}cngx-mini-bar.cngx-mini-bar .cngx-mini-bar__fill,cngx-bullet.cngx-bullet .cngx-bullet__actual,cngx-bullet.cngx-bullet .cngx-bullet__target,cngx-deviation-bar.cngx-deviation-bar .cngx-deviation-bar__fill,cngx-deviation-bar.cngx-deviation-bar .cngx-deviation-bar__baseline{background:CanvasText;opacity:1}cngx-bullet.cngx-bullet .cngx-bullet__range{forced-color-adjust:none;background:Canvas!important;box-shadow:inset -1px 0 0 GrayText;opacity:1}cngx-stacked-bar.cngx-stacked-bar .cngx-stacked-bar__segment{forced-color-adjust:none;background:CanvasText!important;box-shadow:inset -2px 0 0 Canvas}cngx-stacked-bar.cngx-stacked-bar .cngx-stacked-bar__segment:nth-child(4n+2){background:repeating-linear-gradient(45deg,CanvasText 0 2px,Canvas 2px 4px)!important}cngx-stacked-bar.cngx-stacked-bar .cngx-stacked-bar__segment:nth-child(4n+3){background:Canvas!important;box-shadow:inset -2px 0 0 Canvas,inset -3px 0 0 CanvasText,inset 0 0 0 1px CanvasText}cngx-stacked-bar.cngx-stacked-bar .cngx-stacked-bar__segment:nth-child(4n+4){background:repeating-linear-gradient(0deg,CanvasText 0 2px,Canvas 2px 4px)!important}cngx-donut.cngx-donut .cngx-donut__fill{stroke:CanvasText}cngx-donut.cngx-donut .cngx-donut__track{stroke:CanvasText;stroke-opacity:.6;stroke-dasharray:2 3}}\n", "cngx-chart .cngx-chart__hatch-ink{fill:CanvasText}cngx-chart .cngx-chart__hatch-gap{fill:Canvas}cngx-chart{display:inline-block;position:relative;max-width:100%}cngx-chart.cngx-chart--responsive{display:block;width:100%;aspect-ratio:var(--cngx-chart-aspect-ratio, 5 / 2)}cngx-chart>.cngx-chart__canvas{position:absolute;inset:0;width:100%;height:100%;z-index:var(--cngx-chart-canvas-z, 0)}cngx-chart.cngx-chart--content-hidden>.cngx-chart__canvas{display:none}cngx-chart>svg{display:block;width:100%;height:100%}cngx-chart>.cngx-chart__fallback-frame{display:flex;align-items:center;justify-content:center;width:100%;height:100%}cngx-chart>.cngx-chart__overlay-frame{position:absolute;inset-block-start:var(--cngx-chart-plot-block-start, 0px);inset-block-end:var(--cngx-chart-plot-block-end, 0px);inset-inline-start:var(--cngx-chart-plot-inline-start, 0px);inset-inline-end:var(--cngx-chart-plot-inline-end, 0px);z-index:var(--cngx-chart-overlay-z, 1);pointer-events:none}cngx-chart>.cngx-chart__loading{display:flex;align-items:center;justify-content:center;width:100%;height:100%}cngx-chart .cngx-chart__spinner{width:var(--cngx-chart-spinner-size, 32px);height:var(--cngx-chart-spinner-size, 32px);border:var(--cngx-chart-spinner-thickness, 3px) solid var(--cngx-chart-spinner-track, rgb(0 0 0 / .08));border-top-color:var(--cngx-chart-spinner-color, var(--cngx-chart-primary, currentColor));border-radius:50%;animation:cngx-chart-spin .8s linear infinite}cngx-chart>.cngx-chart__fallback{display:flex;align-items:center;justify-content:center;width:100%;height:100%;min-height:var(--cngx-chart-fallback-min-height, 48px);font-size:var(--cngx-chart-fallback-font-size, .875rem);color:var(--cngx-chart-text-color, currentColor);opacity:var(--cngx-chart-fallback-opacity, .7);padding:var(--cngx-chart-fallback-padding, 1rem);text-align:center;box-sizing:border-box}cngx-chart>.cngx-chart__fallback--error{color:var(--cngx-chart-danger, currentColor);opacity:1}cngx-chart>.cngx-chart__connection-overlay{position:absolute;top:calc(var(--cngx-chart-plot-block-start, 0px) + var(--cngx-chart-connection-inset, .5rem));inset-inline-end:calc(var(--cngx-chart-plot-inline-end, 0px) + var(--cngx-chart-connection-inset, .5rem));max-inline-size:calc(100% - var(--cngx-chart-plot-inline-start, 0px) - var(--cngx-chart-plot-inline-end, 0px) - 2 * var(--cngx-chart-connection-inset, .5rem));display:flex;align-items:center;gap:var(--cngx-chart-connection-gap, .375rem);padding:var(--cngx-chart-connection-padding, .25rem .625rem);border-radius:var(--cngx-chart-connection-radius, 999px);font-size:var(--cngx-chart-connection-font-size, .75rem);line-height:1.4;pointer-events:none;box-shadow:var(--cngx-chart-connection-shadow, 0 1px 3px rgb(0 0 0 / .12))}cngx-chart>.cngx-chart__connection-overlay--error{background:var(--cngx-chart-connection-error-bg, var(--cngx-chart-danger, #d32f2f));color:var(--cngx-chart-connection-error-color, #fff)}cngx-chart>.cngx-chart__connection-overlay--reconnecting{background:var(--cngx-chart-connection-reconnecting-bg, rgb(0 0 0 / .72));color:var(--cngx-chart-connection-reconnecting-color, #fff)}cngx-chart>.cngx-chart__sr-status{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@keyframes cngx-chart-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){cngx-chart .cngx-chart__spinner{animation:none}}\n"] }]
|
|
2967
|
-
}], ctorParameters: () => [], propDecorators: { dataInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], preserveAspectRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "preserveAspectRatio", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], summaryAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "summaryAccessor", required: false }] }], accessibleTable: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessibleTable", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], connectionState: [{ type: i0.Input, args: [{ isSignal: true, alias: "connectionState", required: false }] }], axes: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_CHART_AXIS), { ...{ descendants: true }, isSignal: true }] }], thresholds: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxThreshold), { ...{ descendants: true }, isSignal: true }] }], layers: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_CHART_LAYER), { ...{ descendants: true }, isSignal: true }] }],
|
|
3023
|
+
}], ctorParameters: () => [], propDecorators: { dataInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], preserveAspectRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "preserveAspectRatio", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], summaryAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "summaryAccessor", required: false }] }], accessibleTable: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessibleTable", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], connectionState: [{ type: i0.Input, args: [{ isSignal: true, alias: "connectionState", required: false }] }], axes: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_CHART_AXIS), { ...{ descendants: true }, isSignal: true }] }], thresholds: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxThreshold), { ...{ descendants: true }, isSignal: true }] }], layers: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_CHART_LAYER), { ...{ descendants: true }, isSignal: true }] }], layerHosts: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_CHART_LAYER), { ...{
|
|
3024
|
+
descendants: true,
|
|
3025
|
+
read: ElementRef,
|
|
3026
|
+
}, isSignal: true }] }], loadingSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartLoading), { isSignal: true }] }], emptySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartEmpty), { isSignal: true }] }], errorSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartError), { isSignal: true }] }], connectionErrorSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartConnectionError), { isSignal: true }] }], reconnectingSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartReconnecting), { isSignal: true }] }], overlaySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartOverlay), { isSignal: true }] }], overlaySlots: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxChartOverlay), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
2968
3027
|
/** @internal */
|
|
2969
3028
|
function isHorizontalPosition(p) {
|
|
2970
3029
|
return p === 'top' || p === 'bottom';
|
|
@@ -3078,14 +3137,12 @@ function toMs$1(v) {
|
|
|
3078
3137
|
* <cngx-chart-announcer [cngxChartAnnouncer]="c" />
|
|
3079
3138
|
* ```
|
|
3080
3139
|
*
|
|
3081
|
-
* @category common/chart
|
|
3082
|
-
* @docsKind primary
|
|
3083
3140
|
* @wcag AA
|
|
3084
3141
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-announcer.component.ts
|
|
3085
|
-
* @since 0.
|
|
3142
|
+
* @since 0.3.0
|
|
3086
3143
|
* @relatedTo CngxChart, createSignificantChangeTracker
|
|
3087
3144
|
*
|
|
3088
|
-
* <example-url
|
|
3145
|
+
* <example-url>/#/common/chart/realtime/streaming-telemetry</example-url>
|
|
3089
3146
|
*/
|
|
3090
3147
|
class CngxChartAnnouncer {
|
|
3091
3148
|
/** The chart instance whose `significantChange()` this announcer voices. */
|
|
@@ -3143,19 +3200,17 @@ const AXIS_LABEL_OFFSET_BLOCK = 36;
|
|
|
3143
3200
|
* The declared default of `--cngx-axis-font-size` (see the tick-label
|
|
3144
3201
|
* rule in `styles` below), in viewBox user units.
|
|
3145
3202
|
*
|
|
3146
|
-
*
|
|
3147
|
-
*
|
|
3148
|
-
*
|
|
3149
|
-
*
|
|
3150
|
-
* at their size inside a gutter sized for the default; that is the
|
|
3151
|
-
* single limitation the chart-area debt register covers.
|
|
3203
|
+
* The gutter arithmetic uses it until the rendered tick label's font
|
|
3204
|
+
* size has been read after the first render, and on the server, where
|
|
3205
|
+
* nothing is read. A consumer restyling the property gets a gutter sized
|
|
3206
|
+
* for the default for one frame, then for the size the label renders at.
|
|
3152
3207
|
*
|
|
3153
3208
|
* @internal
|
|
3154
3209
|
*/
|
|
3155
3210
|
const AXIS_FONT_SIZE = 11;
|
|
3156
3211
|
/**
|
|
3157
|
-
* The declared default of `--cngx-axis-axis-label-font-size
|
|
3158
|
-
*
|
|
3212
|
+
* The declared default of `--cngx-axis-axis-label-font-size`, used the
|
|
3213
|
+
* same way as {@link AXIS_FONT_SIZE} until the rendered title is read.
|
|
3159
3214
|
*
|
|
3160
3215
|
* @internal
|
|
3161
3216
|
*/
|
|
@@ -3193,6 +3248,14 @@ const CHAR_ADVANCE_RATIO = 0.65;
|
|
|
3193
3248
|
* @internal
|
|
3194
3249
|
*/
|
|
3195
3250
|
const LINE_BOX_RATIO = 1.5;
|
|
3251
|
+
/** @internal Computed font size of `el` in px, or `null` when absent or unresolved. */
|
|
3252
|
+
function readFontPx(el) {
|
|
3253
|
+
if (!el) {
|
|
3254
|
+
return null;
|
|
3255
|
+
}
|
|
3256
|
+
const px = parseFloat(getComputedStyle(el).fontSize);
|
|
3257
|
+
return Number.isFinite(px) && px > 0 ? px : null;
|
|
3258
|
+
}
|
|
3196
3259
|
/**
|
|
3197
3260
|
* Declarative axis directive. Lives as a content child of
|
|
3198
3261
|
* `<cngx-chart>`; its `position` + `type` + `domain` inputs feed the
|
|
@@ -3210,25 +3273,47 @@ const LINE_BOX_RATIO = 1.5;
|
|
|
3210
3273
|
* semantic data view lives on the parent chart's auto-Summary and
|
|
3211
3274
|
* Data Table.
|
|
3212
3275
|
*
|
|
3213
|
-
* @category common/chart/axis
|
|
3214
|
-
* @docsKind primary
|
|
3215
3276
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/axis.component.ts
|
|
3216
|
-
* @since 0.
|
|
3277
|
+
* @since 0.3.0
|
|
3217
3278
|
* @relatedTo CngxChart, CngxLine, CngxBar, CngxArea
|
|
3218
3279
|
*
|
|
3219
|
-
* <example-url
|
|
3220
|
-
* <example-url
|
|
3221
|
-
* <example-url
|
|
3222
|
-
* <example-url
|
|
3223
|
-
* <example-url
|
|
3224
|
-
* <example-url
|
|
3225
|
-
* <example-url
|
|
3280
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
3281
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
3282
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
3283
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
3284
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
3285
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
3286
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
3226
3287
|
*/
|
|
3227
3288
|
class CngxAxis {
|
|
3289
|
+
/**
|
|
3290
|
+
* Required side of the plot the axis sits on: `'top'`, `'right'`, `'bottom'` or `'left'`. Top and
|
|
3291
|
+
* bottom axes supply the chart's x scale and left and right axes the y scale, and only the first
|
|
3292
|
+
* axis of each orientation drives its scale.
|
|
3293
|
+
*/
|
|
3228
3294
|
position = input.required(...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
3295
|
+
/**
|
|
3296
|
+
* Scale type: `'linear'` for numbers, `'time'` for Dates or timestamps, `'band'` for categories.
|
|
3297
|
+
* Default `'linear'`; it decides how `[domain]` maps to the chart scale and how ticks are
|
|
3298
|
+
* generated.
|
|
3299
|
+
*/
|
|
3229
3300
|
type = input('linear', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
3301
|
+
/**
|
|
3302
|
+
* Values the scale spans. For linear and time axes the first and last entries are the two ends,
|
|
3303
|
+
* for band axes every entry is one category and one tick; fewer than two entries gives the chart
|
|
3304
|
+
* no scale for this axis. Unset draws the axis line without ticks.
|
|
3305
|
+
*/
|
|
3230
3306
|
domain = input(undefined, ...(ngDevMode ? [{ debugName: "domain" }] : /* istanbul ignore next */ []));
|
|
3307
|
+
/**
|
|
3308
|
+
* Number of evenly spaced ticks, bound as `[ticks]`, generated across a linear or time domain with
|
|
3309
|
+
* both ends included. Default `5`; ignored on band axes, which tick every category.
|
|
3310
|
+
*/
|
|
3231
3311
|
tickCount = input(undefined, { ...(ngDevMode ? { debugName: "tickCount" } : /* istanbul ignore next */ {}), alias: 'ticks' });
|
|
3312
|
+
/**
|
|
3313
|
+
* Formats a tick value into its label, `(v: unknown) => string`. The default formats numbers and
|
|
3314
|
+
* dates in the app locale (`CNGX_LOCALE`) and drops floating-point noise; the widest formatted
|
|
3315
|
+
* label also sizes the gutter the chart reserves for the axis.
|
|
3316
|
+
*/
|
|
3232
3317
|
format = input(defaultTickFormat, ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
3233
3318
|
/**
|
|
3234
3319
|
* Render decorative gridlines extending from each tick across the
|
|
@@ -3249,8 +3334,15 @@ class CngxAxis {
|
|
|
3249
3334
|
* `[label]` for terseness.
|
|
3250
3335
|
*/
|
|
3251
3336
|
axisLabel = input(null, { ...(ngDevMode ? { debugName: "axisLabel" } : /* istanbul ignore next */ {}), alias: 'label' });
|
|
3252
|
-
ctx =
|
|
3337
|
+
ctx = injectChartContext('cngxAxis');
|
|
3253
3338
|
locale = injectLocale();
|
|
3339
|
+
host = inject(ElementRef);
|
|
3340
|
+
/** Rendered font size of a tick label, `null` until read (and on the server). */
|
|
3341
|
+
tickFontPx = signal(null, ...(ngDevMode ? [{ debugName: "tickFontPx" }] : /* istanbul ignore next */ []));
|
|
3342
|
+
/** Rendered font size of the axis title, `null` until read. */
|
|
3343
|
+
titleFontPx = signal(null, ...(ngDevMode ? [{ debugName: "titleFontPx" }] : /* istanbul ignore next */ []));
|
|
3344
|
+
fontSize = computed(() => this.tickFontPx() ?? AXIS_FONT_SIZE, ...(ngDevMode ? [{ debugName: "fontSize" }] : /* istanbul ignore next */ []));
|
|
3345
|
+
titleFontSize = computed(() => this.titleFontPx() ?? AXIS_LABEL_FONT_SIZE, ...(ngDevMode ? [{ debugName: "titleFontSize" }] : /* istanbul ignore next */ []));
|
|
3254
3346
|
/**
|
|
3255
3347
|
* The bound `[format]`, or the default tick formatter bound to the app
|
|
3256
3348
|
* locale (`CNGX_LOCALE`), so a locale flip re-formats the default labels.
|
|
@@ -3309,6 +3401,32 @@ class CngxAxis {
|
|
|
3309
3401
|
}
|
|
3310
3402
|
return true;
|
|
3311
3403
|
} });
|
|
3404
|
+
hasTicks = computed(() => this.tickValues().length > 0, ...(ngDevMode ? [{ debugName: "hasTicks" }] : /* istanbul ignore next */ []));
|
|
3405
|
+
constructor() {
|
|
3406
|
+
// Font-size probe for the gutter arithmetic. Reads the computed
|
|
3407
|
+
// `font-size` of the rendered labels, so `rem` / `em` / `calc()` in the
|
|
3408
|
+
// custom properties resolve. Re-runs when labels first appear, a title
|
|
3409
|
+
// is added or removed, or the chart resizes; it never reads the signals
|
|
3410
|
+
// it writes or the reservation they feed, so the extra render a new
|
|
3411
|
+
// size causes ends the cycle. Browser-only (afterRender never runs on
|
|
3412
|
+
// the server); jsdom resolves no `var()`, a NaN read keeps the default.
|
|
3413
|
+
afterRenderEffect({
|
|
3414
|
+
read: () => {
|
|
3415
|
+
this.hasTicks();
|
|
3416
|
+
this.axisLabel();
|
|
3417
|
+
this.ctx.dimensions();
|
|
3418
|
+
const host = this.host.nativeElement;
|
|
3419
|
+
const tick = readFontPx(host.querySelector('.cngx-axis__tick-label'));
|
|
3420
|
+
if (tick !== null) {
|
|
3421
|
+
this.tickFontPx.set(tick);
|
|
3422
|
+
}
|
|
3423
|
+
const title = readFontPx(host.querySelector('.cngx-axis__axis-label'));
|
|
3424
|
+
if (title !== null) {
|
|
3425
|
+
this.titleFontPx.set(title);
|
|
3426
|
+
}
|
|
3427
|
+
},
|
|
3428
|
+
});
|
|
3429
|
+
}
|
|
3312
3430
|
/**
|
|
3313
3431
|
* How far this axis's decoration extends perpendicular to its own
|
|
3314
3432
|
* line, in viewBox user units. The parent chart reads it to size the
|
|
@@ -3328,10 +3446,14 @@ class CngxAxis {
|
|
|
3328
3446
|
*
|
|
3329
3447
|
* Character width is an estimate ({@link CHAR_ADVANCE_RATIO}), which
|
|
3330
3448
|
* is the one value here that is not derived from state the axis
|
|
3331
|
-
* owns.
|
|
3332
|
-
*
|
|
3333
|
-
*
|
|
3334
|
-
*
|
|
3449
|
+
* owns. The font size it multiplies is the size the tick label and the
|
|
3450
|
+
* title render at, read once per axis after render (the declared
|
|
3451
|
+
* defaults until then and on the server, so SSR and the first frame
|
|
3452
|
+
* agree and an override moves the gutter one frame later). Everything
|
|
3453
|
+
* else comes from {@link tickValues} and {@link format}, which the
|
|
3454
|
+
* component already computes to render the labels themselves - so this
|
|
3455
|
+
* measures no text. A font-size custom property changed at runtime with
|
|
3456
|
+
* no resize and no re-render of the axis is not picked up.
|
|
3335
3457
|
*
|
|
3336
3458
|
* Acyclic by construction: {@link tickValues} reads `domain` /
|
|
3337
3459
|
* `ticks` / `type` and never the scale, so
|
|
@@ -3340,11 +3462,11 @@ class CngxAxis {
|
|
|
3340
3462
|
*/
|
|
3341
3463
|
reservation = computed(() => {
|
|
3342
3464
|
const horizontal = this.position() === 'top' || this.position() === 'bottom';
|
|
3343
|
-
const labelExtent = horizontal ?
|
|
3465
|
+
const labelExtent = horizontal ? this.fontSize() * LINE_BOX_RATIO : this.widestTickLabel();
|
|
3344
3466
|
const tickRoom = TICK_LENGTH + LABEL_OFFSET + labelExtent;
|
|
3345
3467
|
const titleRoom = this.axisLabel()
|
|
3346
3468
|
? (horizontal ? AXIS_LABEL_OFFSET_INLINE : AXIS_LABEL_OFFSET_BLOCK) +
|
|
3347
|
-
|
|
3469
|
+
this.titleFontSize() * LINE_BOX_RATIO
|
|
3348
3470
|
: 0;
|
|
3349
3471
|
// Whole user units, rounded up: the estimate is already an
|
|
3350
3472
|
// approximation, so rounding down would trade a clean number for a
|
|
@@ -3373,7 +3495,7 @@ class CngxAxis {
|
|
|
3373
3495
|
*/
|
|
3374
3496
|
crossReservation = computed(() => {
|
|
3375
3497
|
const horizontal = this.position() === 'top' || this.position() === 'bottom';
|
|
3376
|
-
const extent = horizontal ? this.widestTickLabel() :
|
|
3498
|
+
const extent = horizontal ? this.widestTickLabel() : this.fontSize() * LINE_BOX_RATIO;
|
|
3377
3499
|
return Math.ceil(extent / 2);
|
|
3378
3500
|
}, ...(ngDevMode ? [{ debugName: "crossReservation" }] : /* istanbul ignore next */ []));
|
|
3379
3501
|
/**
|
|
@@ -3382,7 +3504,7 @@ class CngxAxis {
|
|
|
3382
3504
|
* width actually matters - its own reservation is a line box, and
|
|
3383
3505
|
* only its cross-axis overhang depends on the strings.
|
|
3384
3506
|
*/
|
|
3385
|
-
widestTickLabel = computed(() => this.longestTickLabel() *
|
|
3507
|
+
widestTickLabel = computed(() => this.longestTickLabel() * this.fontSize() * CHAR_ADVANCE_RATIO, ...(ngDevMode ? [{ debugName: "widestTickLabel" }] : /* istanbul ignore next */ []));
|
|
3386
3508
|
/**
|
|
3387
3509
|
* Character count of the widest formatted tick label. Split out so
|
|
3388
3510
|
* that {@link reservation} on a horizontal axis never reads it - a
|
|
@@ -3599,7 +3721,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3599
3721
|
}
|
|
3600
3722
|
}
|
|
3601
3723
|
`, styles: [".cngx-axis__line,.cngx-axis__tick-line{stroke:var(--cngx-axis-color, var(--cngx-chart-axis-color, currentColor));stroke-width:var(--cngx-axis-stroke-width, 1px);fill:none}.cngx-axis__tick-label{fill:var(--cngx-axis-text-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-axis-font-size, 11px);unicode-bidi:var(--cngx-chart-numeric-bidi, isolate)}.cngx-axis__grid-line{stroke:var(--cngx-axis-grid-color, var(--cngx-chart-grid-color, currentColor));stroke-opacity:var(--cngx-axis-grid-opacity, .6);stroke-width:var(--cngx-axis-grid-stroke-width, 1px);stroke-dasharray:var(--cngx-axis-grid-dasharray, 0);fill:none;pointer-events:none}.cngx-axis__axis-label{fill:var(--cngx-axis-axis-label-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-axis-axis-label-font-size, 12px);font-weight:var(--cngx-axis-axis-label-font-weight, 500)}@media(forced-colors:active){.cngx-axis__line,.cngx-axis__tick-line,.cngx-axis__grid-line{stroke:CanvasText}.cngx-axis__grid-line{stroke-opacity:.35}.cngx-axis__tick-label,.cngx-axis__axis-label{fill:CanvasText}}\n"] }]
|
|
3602
|
-
}], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: true }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], domain: [{ type: i0.Input, args: [{ isSignal: true, alias: "domain", required: false }] }], tickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "ticks", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], showGrid: [{ type: i0.Input, args: [{ isSignal: true, alias: "grid", required: false }] }], axisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
|
|
3724
|
+
}], ctorParameters: () => [], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: true }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], domain: [{ type: i0.Input, args: [{ isSignal: true, alias: "domain", required: false }] }], tickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "ticks", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], showGrid: [{ type: i0.Input, args: [{ isSignal: true, alias: "grid", required: false }] }], axisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
|
|
3603
3725
|
/** @internal */
|
|
3604
3726
|
function spread(start, end, count) {
|
|
3605
3727
|
if (count <= 1) {
|
|
@@ -3845,13 +3967,12 @@ const NO_RESERVATION = signal(0).asReadonly();
|
|
|
3845
3967
|
* namespace. Nothing renders either way, but the host stays a legal SVG
|
|
3846
3968
|
* child.
|
|
3847
3969
|
*
|
|
3848
|
-
* @category common/chart/axis
|
|
3849
3970
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/axis-domain.ts
|
|
3850
|
-
* @since 0.
|
|
3971
|
+
* @since 0.3.0
|
|
3851
3972
|
* @relatedTo CngxAxis, CngxChart, CngxChartAxis
|
|
3852
3973
|
*
|
|
3853
|
-
* <example-url
|
|
3854
|
-
* <example-url
|
|
3974
|
+
* <example-url>/#/ui/chart-panel/basic/titled-panel-with-legend</example-url>
|
|
3975
|
+
* <example-url>/#/ui/chart-panel/slots/actions-and-footer</example-url>
|
|
3855
3976
|
*/
|
|
3856
3977
|
class CngxAxisDomain {
|
|
3857
3978
|
/** Which edge the scale this publishes belongs to. */
|
|
@@ -3921,16 +4042,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3921
4042
|
* (areas, thresholds, bands and axes do not count), so list the entries
|
|
3922
4043
|
* in the order of those layers.
|
|
3923
4044
|
*
|
|
3924
|
-
* @category common/chart/legend
|
|
3925
|
-
* @docsKind primary
|
|
3926
4045
|
* @wcag AA
|
|
3927
4046
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/legend/legend.component.ts
|
|
3928
|
-
* @since 0.
|
|
4047
|
+
* @since 0.3.0
|
|
3929
4048
|
* @relatedTo CngxChart, CngxLine, CngxBar
|
|
4049
|
+
* @axis level atom
|
|
3930
4050
|
*/
|
|
3931
4051
|
class CngxChartLegend {
|
|
4052
|
+
/**
|
|
4053
|
+
* Required entries to list; each shows a colour swatch, its `label` and, when `value` is not null,
|
|
4054
|
+
* a trailing value (numbers in the app locale). A missing `color` leaves the swatch on the chart
|
|
4055
|
+
* primary token.
|
|
4056
|
+
*/
|
|
3932
4057
|
items = input.required(...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
4058
|
+
/**
|
|
4059
|
+
* Layout of the entries: `'horizontal'` wraps them in a row, `'vertical'` stacks them in a column.
|
|
4060
|
+
* Default `'horizontal'`.
|
|
4061
|
+
*/
|
|
3933
4062
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
4063
|
+
/**
|
|
4064
|
+
* Sets `justify-content` on the host to `flex-start`, `center` or `flex-end` for `'start'`,
|
|
4065
|
+
* `'center'` or `'end'`, along the main axis of the current orientation. Default `'start'`.
|
|
4066
|
+
*/
|
|
3934
4067
|
align = input('start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
3935
4068
|
locale = injectLocale();
|
|
3936
4069
|
/** @internal Each item's value as display text; numbers in the app locale. */
|
|
@@ -4079,8 +4212,6 @@ function pointsEqual(a, b) {
|
|
|
4079
4212
|
* overshoots between data points.
|
|
4080
4213
|
* @returns The full path data starting with `M`. Returns `''` when
|
|
4081
4214
|
* the input is empty; `M x y` when the input has one point.
|
|
4082
|
-
*
|
|
4083
|
-
* @category common/chart/path
|
|
4084
4215
|
*/
|
|
4085
4216
|
function buildCurvePath(points, curve) {
|
|
4086
4217
|
if (points.length === 0) {
|
|
@@ -4164,8 +4295,6 @@ function buildMonotonePath(points) {
|
|
|
4164
4295
|
* when the inputs to the `computed` are unchanged, two consecutive
|
|
4165
4296
|
* cascade ticks with the same `(y, x, curve)` produce the same
|
|
4166
4297
|
* builder instance.
|
|
4167
|
-
*
|
|
4168
|
-
* @category common/chart/path
|
|
4169
4298
|
*/
|
|
4170
4299
|
function createPathBuilder(opts) {
|
|
4171
4300
|
const yAcc = opts.y;
|
|
@@ -4255,26 +4384,47 @@ function projectFiniteRuns(data, xAcc, yAcc, xScale, yScale) {
|
|
|
4255
4384
|
* nothing. `[points]` controls this: `'auto'` (default) marks only the
|
|
4256
4385
|
* one-datum case, `'always'` marks every datum, `'never'` suppresses it.
|
|
4257
4386
|
*
|
|
4258
|
-
* @category common/chart/layers
|
|
4259
|
-
* @docsKind primary
|
|
4260
4387
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/line.component.ts
|
|
4261
|
-
* @since 0.
|
|
4388
|
+
* @since 0.3.0
|
|
4262
4389
|
* @relatedTo CngxArea, CngxScatter, CngxBar, CngxChart
|
|
4263
4390
|
*
|
|
4264
|
-
* <example-url
|
|
4265
|
-
* <example-url
|
|
4266
|
-
* <example-url
|
|
4267
|
-
* <example-url
|
|
4268
|
-
* <example-url
|
|
4269
|
-
* <example-url
|
|
4270
|
-
* <example-url
|
|
4391
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
4392
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
4393
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
4394
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
4395
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
4396
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
4397
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
4271
4398
|
*/
|
|
4272
4399
|
class CngxLine {
|
|
4400
|
+
/**
|
|
4401
|
+
* Reads the y value of each row as `(d, i) => number`, defaulting to `Number(d)`. The values form
|
|
4402
|
+
* the path.
|
|
4403
|
+
*/
|
|
4273
4404
|
accessor = input((d) => Number(d), ...(ngDevMode ? [{ debugName: "accessor" }] : /* istanbul ignore next */ []));
|
|
4405
|
+
/**
|
|
4406
|
+
* Reads the x value of each row as `(d, i) => number | Date | string`. When unset the row index is
|
|
4407
|
+
* used.
|
|
4408
|
+
*/
|
|
4274
4409
|
xAccessor = input(undefined, ...(ngDevMode ? [{ debugName: "xAccessor" }] : /* istanbul ignore next */ []));
|
|
4410
|
+
/**
|
|
4411
|
+
* CSS colour of the line stroke and its point markers, applied as an inline style and read by the
|
|
4412
|
+
* canvas renderer. Unset falls back to `--cngx-line-color`, then `--cngx-chart-primary`.
|
|
4413
|
+
*/
|
|
4275
4414
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4415
|
+
/**
|
|
4416
|
+
* Stroke width of the line. A number is read as px and a string passes through as a CSS length;
|
|
4417
|
+
* unset falls back to `--cngx-line-stroke-width` (default `1.5px`).
|
|
4418
|
+
*/
|
|
4276
4419
|
strokeWidth = input(null, ...(ngDevMode ? [{ debugName: "strokeWidth" }] : /* istanbul ignore next */ []));
|
|
4420
|
+
/**
|
|
4421
|
+
* Interpolation between points: `'linear'` joins them with straight segments, `'monotone'` with a
|
|
4422
|
+
* smooth curve that does not overshoot the data. Default `'linear'`.
|
|
4423
|
+
*/
|
|
4277
4424
|
curve = input('linear', ...(ngDevMode ? [{ debugName: "curve" }] : /* istanbul ignore next */ []));
|
|
4425
|
+
/**
|
|
4426
|
+
* Rows this layer draws. When unset the layer reads the parent chart's `[data]`.
|
|
4427
|
+
*/
|
|
4278
4428
|
data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
4279
4429
|
/**
|
|
4280
4430
|
* Point-marker mode. `'auto'` (default) draws a marker only when the
|
|
@@ -4283,7 +4433,24 @@ class CngxLine {
|
|
|
4283
4433
|
* `'always'` marks every datum; `'never'` suppresses markers.
|
|
4284
4434
|
*/
|
|
4285
4435
|
points = input('auto', ...(ngDevMode ? [{ debugName: "points" }] : /* istanbul ignore next */ []));
|
|
4286
|
-
ctx = injectChartContext('
|
|
4436
|
+
ctx = injectChartContext('cngxLine');
|
|
4437
|
+
/**
|
|
4438
|
+
* Forced-colors series step from the chart's layer order, written to
|
|
4439
|
+
* `data-cngx-series-step` for the dash / hatch cycle in the styles.
|
|
4440
|
+
*/
|
|
4441
|
+
seriesStep = computed(() => this.ctx.seriesStepOf?.(this) ?? null, ...(ngDevMode ? [{ debugName: "seriesStep" }] : /* istanbul ignore next */ []));
|
|
4442
|
+
/**
|
|
4443
|
+
* Inline style, not a presentation attribute: the `.cngx-line` class rule
|
|
4444
|
+
* beats an attribute. A number gets `px`; a string passes through as
|
|
4445
|
+
* written, so it carries its own unit.
|
|
4446
|
+
*/
|
|
4447
|
+
strokeWidthStyle = computed(() => {
|
|
4448
|
+
const sw = this.strokeWidth();
|
|
4449
|
+
if (typeof sw === 'number') {
|
|
4450
|
+
return `${sw}px`;
|
|
4451
|
+
}
|
|
4452
|
+
return sw;
|
|
4453
|
+
}, ...(ngDevMode ? [{ debugName: "strokeWidthStyle" }] : /* istanbul ignore next */ []));
|
|
4287
4454
|
builder = computed(() => createPathBuilder({
|
|
4288
4455
|
y: this.accessor(),
|
|
4289
4456
|
x: this.xAccessor(),
|
|
@@ -4316,41 +4483,54 @@ class CngxLine {
|
|
|
4316
4483
|
return g.kind === 'line' ? (g.points ?? EMPTY_POINTS) : EMPTY_POINTS;
|
|
4317
4484
|
}, ...(ngDevMode ? [{ debugName: "pointMarks" }] : /* istanbul ignore next */ []));
|
|
4318
4485
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLine, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4319
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxLine, isStandalone: true, selector: "[cngxLine]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, xAccessor: { classPropertyName: "xAccessor", publicName: "xAccessor", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, curve: { classPropertyName: "curve", publicName: "curve", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, points: { classPropertyName: "points", publicName: "points", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-chart-series" }, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxLine }], exportAs: ["cngxLine"], ngImport: i0, template: `
|
|
4486
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxLine, isStandalone: true, selector: "[cngxLine]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, xAccessor: { classPropertyName: "xAccessor", publicName: "xAccessor", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, curve: { classPropertyName: "curve", publicName: "curve", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, points: { classPropertyName: "points", publicName: "points", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-cngx-series-step": "seriesStep()" }, classAttribute: "cngx-chart-series" }, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxLine }], exportAs: ["cngxLine"], ngImport: i0, template: `
|
|
4320
4487
|
@if (ctx.renderSvg()) {
|
|
4321
4488
|
<svg:path
|
|
4322
4489
|
class="cngx-line"
|
|
4323
4490
|
[attr.d]="d()"
|
|
4324
4491
|
[attr.fill]="'none'"
|
|
4325
4492
|
[style.stroke]="color()"
|
|
4326
|
-
[
|
|
4493
|
+
[style.stroke-width]="strokeWidthStyle()"
|
|
4327
4494
|
[attr.stroke-linejoin]="'round'"
|
|
4328
4495
|
[attr.stroke-linecap]="'round'"
|
|
4329
4496
|
/>
|
|
4330
4497
|
@for (p of pointMarks(); track $index) {
|
|
4331
|
-
<svg:circle
|
|
4498
|
+
<svg:circle
|
|
4499
|
+
class="cngx-line__point"
|
|
4500
|
+
[attr.cx]="p.cx"
|
|
4501
|
+
[attr.cy]="p.cy"
|
|
4502
|
+
[style.fill]="color()"
|
|
4503
|
+
/>
|
|
4332
4504
|
}
|
|
4333
4505
|
}
|
|
4334
|
-
`, isInline: true, styles: [".cngx-line{stroke:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));stroke-width:var(--cngx-line-stroke-width, 1.5px);animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-line-enter{0%{opacity:0}to{opacity:1}}.cngx-line__point{r:var(--cngx-line-point-radius, 3px);fill:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-line,.cngx-line__point{animation:none}}@media(forced-colors:active){.cngx-line{stroke:CanvasText!important}.cngx-line__point{fill:CanvasText}
|
|
4506
|
+
`, isInline: true, styles: [".cngx-line{stroke:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));stroke-width:var(--cngx-line-stroke-width, 1.5px);animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-line-enter{0%{opacity:0}to{opacity:1}}.cngx-line__point{r:var(--cngx-line-point-radius, 3px);fill:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-line,.cngx-line__point{animation:none}}@media(forced-colors:active){.cngx-line{stroke:CanvasText!important}.cngx-line__point{fill:CanvasText!important}[data-cngx-series-step=\"1\"]>.cngx-line{stroke-dasharray:6 3}[data-cngx-series-step=\"2\"]>.cngx-line{stroke-dasharray:.1 4}[data-cngx-series-step=\"3\"]>.cngx-line{stroke-dasharray:8 3 .1 3}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4335
4507
|
}
|
|
4336
4508
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLine, decorators: [{
|
|
4337
4509
|
type: Component,
|
|
4338
|
-
args: [{ selector: '[cngxLine]', exportAs: 'cngxLine', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxLine }], host: {
|
|
4510
|
+
args: [{ selector: '[cngxLine]', exportAs: 'cngxLine', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxLine }], host: {
|
|
4511
|
+
class: 'cngx-chart-series',
|
|
4512
|
+
'[attr.data-cngx-series-step]': 'seriesStep()',
|
|
4513
|
+
}, template: `
|
|
4339
4514
|
@if (ctx.renderSvg()) {
|
|
4340
4515
|
<svg:path
|
|
4341
4516
|
class="cngx-line"
|
|
4342
4517
|
[attr.d]="d()"
|
|
4343
4518
|
[attr.fill]="'none'"
|
|
4344
4519
|
[style.stroke]="color()"
|
|
4345
|
-
[
|
|
4520
|
+
[style.stroke-width]="strokeWidthStyle()"
|
|
4346
4521
|
[attr.stroke-linejoin]="'round'"
|
|
4347
4522
|
[attr.stroke-linecap]="'round'"
|
|
4348
4523
|
/>
|
|
4349
4524
|
@for (p of pointMarks(); track $index) {
|
|
4350
|
-
<svg:circle
|
|
4525
|
+
<svg:circle
|
|
4526
|
+
class="cngx-line__point"
|
|
4527
|
+
[attr.cx]="p.cx"
|
|
4528
|
+
[attr.cy]="p.cy"
|
|
4529
|
+
[style.fill]="color()"
|
|
4530
|
+
/>
|
|
4351
4531
|
}
|
|
4352
4532
|
}
|
|
4353
|
-
`, styles: [".cngx-line{stroke:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));stroke-width:var(--cngx-line-stroke-width, 1.5px);animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-line-enter{0%{opacity:0}to{opacity:1}}.cngx-line__point{r:var(--cngx-line-point-radius, 3px);fill:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-line,.cngx-line__point{animation:none}}@media(forced-colors:active){.cngx-line{stroke:CanvasText!important}.cngx-line__point{fill:CanvasText}
|
|
4533
|
+
`, styles: [".cngx-line{stroke:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));stroke-width:var(--cngx-line-stroke-width, 1.5px);animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-line-enter{0%{opacity:0}to{opacity:1}}.cngx-line__point{r:var(--cngx-line-point-radius, 3px);fill:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-line,.cngx-line__point{animation:none}}@media(forced-colors:active){.cngx-line{stroke:CanvasText!important}.cngx-line__point{fill:CanvasText!important}[data-cngx-series-step=\"1\"]>.cngx-line{stroke-dasharray:6 3}[data-cngx-series-step=\"2\"]>.cngx-line{stroke-dasharray:.1 4}[data-cngx-series-step=\"3\"]>.cngx-line{stroke-dasharray:8 3 .1 3}}\n"] }]
|
|
4354
4534
|
}], propDecorators: { accessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessor", required: false }] }], xAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "xAccessor", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], strokeWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "strokeWidth", required: false }] }], curve: [{ type: i0.Input, args: [{ isSignal: true, alias: "curve", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], points: [{ type: i0.Input, args: [{ isSignal: true, alias: "points", required: false }] }] } });
|
|
4355
4535
|
|
|
4356
4536
|
/**
|
|
@@ -4368,27 +4548,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4368
4548
|
* nothing. `[points]` mirrors {@link CngxLine}: `'auto'` (default) marks
|
|
4369
4549
|
* only the one-datum case, `'always'` every datum, `'never'` none.
|
|
4370
4550
|
*
|
|
4371
|
-
* @category common/chart/layers
|
|
4372
|
-
* @docsKind primary
|
|
4373
4551
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/area.component.ts
|
|
4374
|
-
* @since 0.
|
|
4552
|
+
* @since 0.3.0
|
|
4375
4553
|
* @relatedTo CngxLine, CngxBand, CngxThreshold, CngxChart
|
|
4376
4554
|
*
|
|
4377
|
-
* <example-url
|
|
4378
|
-
* <example-url
|
|
4379
|
-
* <example-url
|
|
4380
|
-
* <example-url
|
|
4381
|
-
* <example-url
|
|
4382
|
-
* <example-url
|
|
4383
|
-
* <example-url
|
|
4555
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
4556
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
4557
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
4558
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
4559
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
4560
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
4561
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
4384
4562
|
*/
|
|
4385
4563
|
class CngxArea {
|
|
4564
|
+
/**
|
|
4565
|
+
* Reads the y value of each row as `(d, i) => number`, defaulting to `Number(d)`. The values form
|
|
4566
|
+
* the upper edge of the filled area.
|
|
4567
|
+
*/
|
|
4386
4568
|
accessor = input((d) => Number(d), ...(ngDevMode ? [{ debugName: "accessor" }] : /* istanbul ignore next */ []));
|
|
4569
|
+
/**
|
|
4570
|
+
* Reads the x value of each row as `(d, i) => number | Date | string`. When unset the row index is
|
|
4571
|
+
* used.
|
|
4572
|
+
*/
|
|
4387
4573
|
xAccessor = input(undefined, ...(ngDevMode ? [{ debugName: "xAccessor" }] : /* istanbul ignore next */ []));
|
|
4574
|
+
/**
|
|
4575
|
+
* Fill opacity of the area, as a number or numeric string. Unset falls back to
|
|
4576
|
+
* `--cngx-area-opacity` (default `0.18`).
|
|
4577
|
+
*/
|
|
4388
4578
|
opacity = input(null, ...(ngDevMode ? [{ debugName: "opacity" }] : /* istanbul ignore next */ []));
|
|
4579
|
+
/**
|
|
4580
|
+
* CSS colour of the area fill and its point markers, applied as an inline style and read by the
|
|
4581
|
+
* canvas renderer. Unset falls back to `--cngx-area-fill`, then `--cngx-chart-primary`.
|
|
4582
|
+
*/
|
|
4389
4583
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4584
|
+
/**
|
|
4585
|
+
* Interpolation between points: `'linear'` joins them with straight segments, `'monotone'` with a
|
|
4586
|
+
* smooth curve that does not overshoot the data. Default `'linear'`.
|
|
4587
|
+
*/
|
|
4390
4588
|
curve = input('linear', ...(ngDevMode ? [{ debugName: "curve" }] : /* istanbul ignore next */ []));
|
|
4589
|
+
/**
|
|
4590
|
+
* Y value the area is closed down to, projected through the chart's y scale. Default `0`.
|
|
4591
|
+
*/
|
|
4391
4592
|
baseline = input(0, ...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
|
|
4593
|
+
/**
|
|
4594
|
+
* Rows this layer draws. When unset the layer reads the parent chart's `[data]`.
|
|
4595
|
+
*/
|
|
4392
4596
|
data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
4393
4597
|
/**
|
|
4394
4598
|
* Point-marker mode, mirroring {@link CngxLine}. `'auto'` (default)
|
|
@@ -4397,7 +4601,7 @@ class CngxArea {
|
|
|
4397
4601
|
* `'always'` marks every datum; `'never'` suppresses markers.
|
|
4398
4602
|
*/
|
|
4399
4603
|
points = input('auto', ...(ngDevMode ? [{ debugName: "points" }] : /* istanbul ignore next */ []));
|
|
4400
|
-
ctx = injectChartContext('
|
|
4604
|
+
ctx = injectChartContext('cngxArea');
|
|
4401
4605
|
builder = computed(() => createPathBuilder({
|
|
4402
4606
|
y: this.accessor(),
|
|
4403
4607
|
x: this.xAccessor(),
|
|
@@ -4457,10 +4661,15 @@ class CngxArea {
|
|
|
4457
4661
|
[style.fill-opacity]="opacity()"
|
|
4458
4662
|
/>
|
|
4459
4663
|
@for (p of pointMarks(); track $index) {
|
|
4460
|
-
<svg:circle
|
|
4664
|
+
<svg:circle
|
|
4665
|
+
class="cngx-area__point"
|
|
4666
|
+
[attr.cx]="p.cx"
|
|
4667
|
+
[attr.cy]="p.cy"
|
|
4668
|
+
[style.fill]="color()"
|
|
4669
|
+
/>
|
|
4461
4670
|
}
|
|
4462
4671
|
}
|
|
4463
|
-
`, isInline: true, styles: [".cngx-area{fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));fill-opacity:var(--cngx-area-opacity, .18);stroke:none;animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-area-enter{0%{opacity:0}to{opacity:1}}.cngx-area__point{r:var(--cngx-area-point-radius, 3px);fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-area,.cngx-area__point{animation:none}}@media(forced-colors:active){.cngx-area
|
|
4672
|
+
`, isInline: true, styles: [".cngx-area{fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));fill-opacity:var(--cngx-area-opacity, .18);stroke:none;animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-area-enter{0%{opacity:0}to{opacity:1}}.cngx-area__point{r:var(--cngx-area-point-radius, 3px);fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-area,.cngx-area__point{animation:none}}@media(forced-colors:active){.cngx-area,.cngx-area__point{fill:CanvasText!important}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4464
4673
|
}
|
|
4465
4674
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxArea, decorators: [{
|
|
4466
4675
|
type: Component,
|
|
@@ -4473,10 +4682,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4473
4682
|
[style.fill-opacity]="opacity()"
|
|
4474
4683
|
/>
|
|
4475
4684
|
@for (p of pointMarks(); track $index) {
|
|
4476
|
-
<svg:circle
|
|
4685
|
+
<svg:circle
|
|
4686
|
+
class="cngx-area__point"
|
|
4687
|
+
[attr.cx]="p.cx"
|
|
4688
|
+
[attr.cy]="p.cy"
|
|
4689
|
+
[style.fill]="color()"
|
|
4690
|
+
/>
|
|
4477
4691
|
}
|
|
4478
4692
|
}
|
|
4479
|
-
`, styles: [".cngx-area{fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));fill-opacity:var(--cngx-area-opacity, .18);stroke:none;animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-area-enter{0%{opacity:0}to{opacity:1}}.cngx-area__point{r:var(--cngx-area-point-radius, 3px);fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-area,.cngx-area__point{animation:none}}@media(forced-colors:active){.cngx-area
|
|
4693
|
+
`, styles: [".cngx-area{fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));fill-opacity:var(--cngx-area-opacity, .18);stroke:none;animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-area-enter{0%{opacity:0}to{opacity:1}}.cngx-area__point{r:var(--cngx-area-point-radius, 3px);fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@media(prefers-reduced-motion:reduce){.cngx-area,.cngx-area__point{animation:none}}@media(forced-colors:active){.cngx-area,.cngx-area__point{fill:CanvasText!important}}\n"] }]
|
|
4480
4694
|
}], propDecorators: { accessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessor", required: false }] }], xAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "xAccessor", required: false }] }], opacity: [{ type: i0.Input, args: [{ isSignal: true, alias: "opacity", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], curve: [{ type: i0.Input, args: [{ isSignal: true, alias: "curve", required: false }] }], baseline: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseline", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], points: [{ type: i0.Input, args: [{ isSignal: true, alias: "points", required: false }] }] } });
|
|
4481
4695
|
|
|
4482
4696
|
/** @internal */
|
|
@@ -4493,27 +4707,49 @@ const FALLBACK_BASELINE = 0;
|
|
|
4493
4707
|
*
|
|
4494
4708
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
4495
4709
|
*
|
|
4496
|
-
* @category common/chart/layers
|
|
4497
|
-
* @docsKind primary
|
|
4498
4710
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/bar.component.ts
|
|
4499
|
-
* @since 0.
|
|
4711
|
+
* @since 0.3.0
|
|
4500
4712
|
* @relatedTo CngxLine, CngxArea, CngxStackedBar, CngxChart
|
|
4501
4713
|
*
|
|
4502
|
-
* <example-url
|
|
4503
|
-
* <example-url
|
|
4504
|
-
* <example-url
|
|
4505
|
-
* <example-url
|
|
4506
|
-
* <example-url
|
|
4507
|
-
* <example-url
|
|
4508
|
-
* <example-url
|
|
4714
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
4715
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
4716
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
4717
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
4718
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
4719
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
4720
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
4509
4721
|
*/
|
|
4510
4722
|
class CngxBar {
|
|
4723
|
+
/**
|
|
4724
|
+
* Reads the y value of each row as `(d, i) => number`, defaulting to `Number(d)`. Each bar spans
|
|
4725
|
+
* from this value to `[baseline]`.
|
|
4726
|
+
*/
|
|
4511
4727
|
accessor = input(((d) => Number(d)), ...(ngDevMode ? [{ debugName: "accessor" }] : /* istanbul ignore next */ []));
|
|
4728
|
+
/**
|
|
4729
|
+
* Fraction of each bar's slot left empty, clamped to 0-1 and split evenly on both sides of the
|
|
4730
|
+
* bar; a slot is the plot width divided by the row count. Default `0.1`.
|
|
4731
|
+
*/
|
|
4512
4732
|
gap = input(0.1, ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
|
|
4733
|
+
/**
|
|
4734
|
+
* Y value the bars are anchored to, projected through the chart's y scale; values below it hang
|
|
4735
|
+
* downward from it. Default `0`.
|
|
4736
|
+
*/
|
|
4513
4737
|
baseline = input(FALLBACK_BASELINE, ...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
|
|
4738
|
+
/**
|
|
4739
|
+
* Rows this layer draws. When unset the layer reads the parent chart's `[data]`.
|
|
4740
|
+
*/
|
|
4514
4741
|
data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
4742
|
+
/**
|
|
4743
|
+
* CSS colour of the bars, applied as an inline style and read by the canvas renderer. Unset falls
|
|
4744
|
+
* back to `--cngx-bar-color`, then `--cngx-chart-primary`.
|
|
4745
|
+
*/
|
|
4515
4746
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4516
|
-
ctx = injectChartContext('
|
|
4747
|
+
ctx = injectChartContext('cngxBar');
|
|
4748
|
+
/**
|
|
4749
|
+
* Forced-colors series step from the chart's layer order, written to
|
|
4750
|
+
* `data-cngx-series-step` for the dash / hatch cycle in the styles.
|
|
4751
|
+
*/
|
|
4752
|
+
seriesStep = computed(() => this.ctx.seriesStepOf?.(this) ?? null, ...(ngDevMode ? [{ debugName: "seriesStep" }] : /* istanbul ignore next */ []));
|
|
4517
4753
|
resolvedData = computed(() => {
|
|
4518
4754
|
const local = this.data();
|
|
4519
4755
|
if (local !== undefined) {
|
|
@@ -4570,7 +4806,7 @@ class CngxBar {
|
|
|
4570
4806
|
})),
|
|
4571
4807
|
}), { ...(ngDevMode ? { debugName: "geometry" } : /* istanbul ignore next */ {}), equal: barGeomEqual });
|
|
4572
4808
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4573
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxBar, isStandalone: true, selector: "[cngxBar]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null }, baseline: { classPropertyName: "baseline", publicName: "baseline", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-chart-series" }, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxBar }], exportAs: ["cngxBar"], ngImport: i0, template: `
|
|
4809
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxBar, isStandalone: true, selector: "[cngxBar]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null }, baseline: { classPropertyName: "baseline", publicName: "baseline", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-cngx-series-step": "seriesStep()" }, classAttribute: "cngx-chart-series" }, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxBar }], exportAs: ["cngxBar"], ngImport: i0, template: `
|
|
4574
4810
|
@if (ctx.renderSvg()) {
|
|
4575
4811
|
@for (rect of rects(); track rect.key) {
|
|
4576
4812
|
<svg:rect
|
|
@@ -4583,11 +4819,14 @@ class CngxBar {
|
|
|
4583
4819
|
/>
|
|
4584
4820
|
}
|
|
4585
4821
|
}
|
|
4586
|
-
`, isInline: true, styles: [".cngx-bar{fill:var(--cngx-bar-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 100%;transform-box:fill-box;animation:cngx-bar-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.2, .64, 1))}@keyframes cngx-bar-enter{0%{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-bar{animation:none}}@media(forced-colors:active){.cngx-bar{fill:CanvasText!important}
|
|
4822
|
+
`, isInline: true, styles: [".cngx-bar{fill:var(--cngx-bar-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 100%;transform-box:fill-box;animation:cngx-bar-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.2, .64, 1))}@keyframes cngx-bar-enter{0%{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-bar{animation:none}}@media(forced-colors:active){.cngx-bar{fill:CanvasText!important}[data-cngx-series-step=\"1\"]>.cngx-bar{fill:var(--_cngx-chart-hatch-diagonal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}[data-cngx-series-step=\"2\"]>.cngx-bar{fill:Canvas!important;stroke:CanvasText;stroke-width:1.5px}[data-cngx-series-step=\"3\"]>.cngx-bar{fill:var(--_cngx-chart-hatch-horizontal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4587
4823
|
}
|
|
4588
4824
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBar, decorators: [{
|
|
4589
4825
|
type: Component,
|
|
4590
|
-
args: [{ selector: '[cngxBar]', exportAs: 'cngxBar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxBar }], host: {
|
|
4826
|
+
args: [{ selector: '[cngxBar]', exportAs: 'cngxBar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxBar }], host: {
|
|
4827
|
+
class: 'cngx-chart-series',
|
|
4828
|
+
'[attr.data-cngx-series-step]': 'seriesStep()',
|
|
4829
|
+
}, template: `
|
|
4591
4830
|
@if (ctx.renderSvg()) {
|
|
4592
4831
|
@for (rect of rects(); track rect.key) {
|
|
4593
4832
|
<svg:rect
|
|
@@ -4600,7 +4839,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4600
4839
|
/>
|
|
4601
4840
|
}
|
|
4602
4841
|
}
|
|
4603
|
-
`, styles: [".cngx-bar{fill:var(--cngx-bar-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 100%;transform-box:fill-box;animation:cngx-bar-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.2, .64, 1))}@keyframes cngx-bar-enter{0%{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-bar{animation:none}}@media(forced-colors:active){.cngx-bar{fill:CanvasText!important}
|
|
4842
|
+
`, styles: [".cngx-bar{fill:var(--cngx-bar-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 100%;transform-box:fill-box;animation:cngx-bar-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.2, .64, 1))}@keyframes cngx-bar-enter{0%{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-bar{animation:none}}@media(forced-colors:active){.cngx-bar{fill:CanvasText!important}[data-cngx-series-step=\"1\"]>.cngx-bar{fill:var(--_cngx-chart-hatch-diagonal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}[data-cngx-series-step=\"2\"]>.cngx-bar{fill:Canvas!important;stroke:CanvasText;stroke-width:1.5px}[data-cngx-series-step=\"3\"]>.cngx-bar{fill:var(--_cngx-chart-hatch-horizontal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}}\n"] }]
|
|
4604
4843
|
}], propDecorators: { accessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessor", required: false }] }], gap: [{ type: i0.Input, args: [{ isSignal: true, alias: "gap", required: false }] }], baseline: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseline", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }] } });
|
|
4605
4844
|
/** @internal */
|
|
4606
4845
|
function barGeomEqual(a, b) {
|
|
@@ -4657,27 +4896,47 @@ function rectsEqual(a, b) {
|
|
|
4657
4896
|
*
|
|
4658
4897
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
4659
4898
|
*
|
|
4660
|
-
* @category common/chart/layers
|
|
4661
|
-
* @docsKind primary
|
|
4662
4899
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/scatter.component.ts
|
|
4663
|
-
* @since 0.
|
|
4900
|
+
* @since 0.3.0
|
|
4664
4901
|
* @relatedTo CngxLine, CngxBar, CngxArea, CngxChart
|
|
4665
4902
|
*
|
|
4666
|
-
* <example-url
|
|
4667
|
-
* <example-url
|
|
4668
|
-
* <example-url
|
|
4669
|
-
* <example-url
|
|
4670
|
-
* <example-url
|
|
4671
|
-
* <example-url
|
|
4672
|
-
* <example-url
|
|
4903
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
4904
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
4905
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
4906
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
4907
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
4908
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
4909
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
4673
4910
|
*/
|
|
4674
4911
|
class CngxScatter {
|
|
4912
|
+
/**
|
|
4913
|
+
* Required reader of the x value of each row, `(d, i) => number | Date | string`; scatter has no
|
|
4914
|
+
* index default.
|
|
4915
|
+
*/
|
|
4675
4916
|
x = input.required(...(ngDevMode ? [{ debugName: "x" }] : /* istanbul ignore next */ []));
|
|
4917
|
+
/**
|
|
4918
|
+
* Required reader of the y value of each row, `(d, i) => number`.
|
|
4919
|
+
*/
|
|
4676
4920
|
y = input.required(...(ngDevMode ? [{ debugName: "y" }] : /* istanbul ignore next */ []));
|
|
4921
|
+
/**
|
|
4922
|
+
* Radius of every circle in chart units (px when the chart is not scaled down). Default `3`.
|
|
4923
|
+
*/
|
|
4677
4924
|
radius = input(3, ...(ngDevMode ? [{ debugName: "radius" }] : /* istanbul ignore next */ []));
|
|
4925
|
+
/**
|
|
4926
|
+
* Rows this layer draws. When unset the layer reads the parent chart's `[data]`.
|
|
4927
|
+
*/
|
|
4678
4928
|
data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
4929
|
+
/**
|
|
4930
|
+
* CSS colour of the circles, applied as an inline style and read by the canvas renderer. Unset
|
|
4931
|
+
* falls back to `--cngx-scatter-color`, then `--cngx-chart-primary`.
|
|
4932
|
+
*/
|
|
4679
4933
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4680
|
-
ctx = injectChartContext('
|
|
4934
|
+
ctx = injectChartContext('cngxScatter');
|
|
4935
|
+
/**
|
|
4936
|
+
* Forced-colors series step from the chart's layer order, written to
|
|
4937
|
+
* `data-cngx-series-step` for the dash / hatch cycle in the styles.
|
|
4938
|
+
*/
|
|
4939
|
+
seriesStep = computed(() => this.ctx.seriesStepOf?.(this) ?? null, ...(ngDevMode ? [{ debugName: "seriesStep" }] : /* istanbul ignore next */ []));
|
|
4681
4940
|
resolvedData = computed(() => {
|
|
4682
4941
|
const local = this.data();
|
|
4683
4942
|
if (local !== undefined) {
|
|
@@ -4709,7 +4968,7 @@ class CngxScatter {
|
|
|
4709
4968
|
};
|
|
4710
4969
|
}, { ...(ngDevMode ? { debugName: "geometry" } : /* istanbul ignore next */ {}), equal: scatterGeomEqual });
|
|
4711
4970
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScatter, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4712
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxScatter, isStandalone: true, selector: "[cngxScatter]", inputs: { x: { classPropertyName: "x", publicName: "x", isSignal: true, isRequired: true, transformFunction: null }, y: { classPropertyName: "y", publicName: "y", isSignal: true, isRequired: true, transformFunction: null }, radius: { classPropertyName: "radius", publicName: "radius", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-chart-series" }, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxScatter }], exportAs: ["cngxScatter"], ngImport: i0, template: `
|
|
4971
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxScatter, isStandalone: true, selector: "[cngxScatter]", inputs: { x: { classPropertyName: "x", publicName: "x", isSignal: true, isRequired: true, transformFunction: null }, y: { classPropertyName: "y", publicName: "y", isSignal: true, isRequired: true, transformFunction: null }, radius: { classPropertyName: "radius", publicName: "radius", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-cngx-series-step": "seriesStep()" }, classAttribute: "cngx-chart-series" }, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxScatter }], exportAs: ["cngxScatter"], ngImport: i0, template: `
|
|
4713
4972
|
@if (ctx.renderSvg()) {
|
|
4714
4973
|
@for (c of circles(); track c.key) {
|
|
4715
4974
|
<svg:circle
|
|
@@ -4721,11 +4980,14 @@ class CngxScatter {
|
|
|
4721
4980
|
/>
|
|
4722
4981
|
}
|
|
4723
4982
|
}
|
|
4724
|
-
`, isInline: true, styles: [".cngx-scatter{fill:var(--cngx-scatter-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 50%;transform-box:fill-box;animation:cngx-scatter-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.56, .64, 1)) backwards}@keyframes cngx-scatter-enter{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-scatter{animation:none}}@media(forced-colors:active){.cngx-scatter{fill:CanvasText!important}
|
|
4983
|
+
`, isInline: true, styles: [".cngx-scatter{fill:var(--cngx-scatter-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 50%;transform-box:fill-box;animation:cngx-scatter-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.56, .64, 1)) backwards}@keyframes cngx-scatter-enter{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-scatter{animation:none}}@media(forced-colors:active){.cngx-scatter{fill:CanvasText!important}[data-cngx-series-step=\"1\"]>.cngx-scatter{fill:var(--_cngx-chart-hatch-diagonal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}[data-cngx-series-step=\"2\"]>.cngx-scatter{fill:Canvas!important;stroke:CanvasText;stroke-width:1.5px}[data-cngx-series-step=\"3\"]>.cngx-scatter{fill:var(--_cngx-chart-hatch-horizontal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4725
4984
|
}
|
|
4726
4985
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScatter, decorators: [{
|
|
4727
4986
|
type: Component,
|
|
4728
|
-
args: [{ selector: '[cngxScatter]', exportAs: 'cngxScatter', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxScatter }], host: {
|
|
4987
|
+
args: [{ selector: '[cngxScatter]', exportAs: 'cngxScatter', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: CNGX_CHART_LAYER, useExisting: CngxScatter }], host: {
|
|
4988
|
+
class: 'cngx-chart-series',
|
|
4989
|
+
'[attr.data-cngx-series-step]': 'seriesStep()',
|
|
4990
|
+
}, template: `
|
|
4729
4991
|
@if (ctx.renderSvg()) {
|
|
4730
4992
|
@for (c of circles(); track c.key) {
|
|
4731
4993
|
<svg:circle
|
|
@@ -4737,7 +4999,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4737
4999
|
/>
|
|
4738
5000
|
}
|
|
4739
5001
|
}
|
|
4740
|
-
`, styles: [".cngx-scatter{fill:var(--cngx-scatter-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 50%;transform-box:fill-box;animation:cngx-scatter-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.56, .64, 1)) backwards}@keyframes cngx-scatter-enter{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-scatter{animation:none}}@media(forced-colors:active){.cngx-scatter{fill:CanvasText!important}
|
|
5002
|
+
`, styles: [".cngx-scatter{fill:var(--cngx-scatter-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 50%;transform-box:fill-box;animation:cngx-scatter-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.56, .64, 1)) backwards}@keyframes cngx-scatter-enter{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-scatter{animation:none}}@media(forced-colors:active){.cngx-scatter{fill:CanvasText!important}[data-cngx-series-step=\"1\"]>.cngx-scatter{fill:var(--_cngx-chart-hatch-diagonal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}[data-cngx-series-step=\"2\"]>.cngx-scatter{fill:Canvas!important;stroke:CanvasText;stroke-width:1.5px}[data-cngx-series-step=\"3\"]>.cngx-scatter{fill:var(--_cngx-chart-hatch-horizontal, CanvasText)!important;stroke:CanvasText;stroke-width:1px}}\n"] }]
|
|
4741
5003
|
}], propDecorators: { x: [{ type: i0.Input, args: [{ isSignal: true, alias: "x", required: true }] }], y: [{ type: i0.Input, args: [{ isSignal: true, alias: "y", required: true }] }], radius: [{ type: i0.Input, args: [{ isSignal: true, alias: "radius", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }] } });
|
|
4742
5004
|
/** @internal */
|
|
4743
5005
|
function scatterGeomEqual(a, b) {
|
|
@@ -4785,27 +5047,44 @@ function circlesEqual(a, b) {
|
|
|
4785
5047
|
*
|
|
4786
5048
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
4787
5049
|
*
|
|
4788
|
-
* @category common/chart/layers
|
|
4789
|
-
* @docsKind primary
|
|
4790
5050
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/band.component.ts
|
|
4791
|
-
* @since 0.
|
|
5051
|
+
* @since 0.3.0
|
|
4792
5052
|
* @relatedTo CngxThreshold, CngxArea, CngxChart
|
|
4793
5053
|
*
|
|
4794
|
-
* <example-url
|
|
4795
|
-
* <example-url
|
|
4796
|
-
* <example-url
|
|
4797
|
-
* <example-url
|
|
4798
|
-
* <example-url
|
|
4799
|
-
* <example-url
|
|
4800
|
-
* <example-url
|
|
5054
|
+
* <example-url>/#/common/chart/primitives/async-state-machine-on-the-primitive</example-url>
|
|
5055
|
+
* <example-url>/#/common/chart/primitives/combo-bars-moving-average-line</example-url>
|
|
5056
|
+
* <example-url>/#/common/chart/primitives/line-area-threshold-band</example-url>
|
|
5057
|
+
* <example-url>/#/common/chart/primitives/multi-series-line-axis-labels-legend</example-url>
|
|
5058
|
+
* <example-url>/#/common/chart/primitives/responsive-fills-parent-width</example-url>
|
|
5059
|
+
* <example-url>/#/common/chart/primitives/scatter-with-performance-zones</example-url>
|
|
5060
|
+
* <example-url>/#/common/chart/primitives/time-series-with-threshold-zones</example-url>
|
|
4801
5061
|
*/
|
|
4802
5062
|
class CngxBand {
|
|
5063
|
+
/**
|
|
5064
|
+
* Required y value of one edge of the band, projected through the chart's y scale. The rectangle
|
|
5065
|
+
* spans the plot width between `[from]` and `[to]`, given in either order.
|
|
5066
|
+
*/
|
|
4803
5067
|
from = input.required(...(ngDevMode ? [{ debugName: "from" }] : /* istanbul ignore next */ []));
|
|
5068
|
+
/**
|
|
5069
|
+
* Required y value of the other edge of the band; see `[from]`.
|
|
5070
|
+
*/
|
|
4804
5071
|
to = input.required(...(ngDevMode ? [{ debugName: "to" }] : /* istanbul ignore next */ []));
|
|
5072
|
+
/**
|
|
5073
|
+
* Optional text drawn inside the band, vertically centred and 4 units in from the plot's left
|
|
5074
|
+
* edge. Unset draws no text.
|
|
5075
|
+
*/
|
|
4805
5076
|
label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
5077
|
+
/**
|
|
5078
|
+
* Fill opacity of the band, as a number or numeric string. Unset falls back to
|
|
5079
|
+
* `--cngx-band-opacity` (default `0.12`).
|
|
5080
|
+
*/
|
|
4806
5081
|
opacity = input(null, ...(ngDevMode ? [{ debugName: "opacity" }] : /* istanbul ignore next */ []));
|
|
5082
|
+
/**
|
|
5083
|
+
* CSS colour of the band fill, applied as an inline style and read by the canvas renderer. Unset
|
|
5084
|
+
* falls back to `--cngx-band-color`, then `--cngx-chart-secondary`.
|
|
5085
|
+
*/
|
|
4807
5086
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4808
|
-
ctx = injectChartContext('
|
|
5087
|
+
ctx = injectChartContext('cngxBand');
|
|
4809
5088
|
rect = computed(() => {
|
|
4810
5089
|
// The plot, not the box: the band spans the area the marks live
|
|
4811
5090
|
// in, so it stops at the axis gutter instead of painting over
|
|
@@ -4955,12 +5234,13 @@ function injectPresetState(state) {
|
|
|
4955
5234
|
* with no accessible name - an unnamed meter reads to AT as a bare
|
|
4956
5235
|
* number with no subject. Same shape as the `cngx-status` warning.
|
|
4957
5236
|
* Call from the preset's constructor (needs the injection context for
|
|
4958
|
-
* `ElementRef` and `afterNextRender`)
|
|
5237
|
+
* `ElementRef` and `afterNextRender`) inside a dev-mode guard, so the
|
|
5238
|
+
* call and its hint strings strip from production builds.
|
|
4959
5239
|
*
|
|
4960
5240
|
* @internal
|
|
4961
5241
|
*/
|
|
4962
5242
|
function warnIfUnnamedPreset(selector, hint, hasName) {
|
|
4963
|
-
if (!
|
|
5243
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
4964
5244
|
return;
|
|
4965
5245
|
}
|
|
4966
5246
|
const el = inject(ElementRef).nativeElement;
|
|
@@ -4973,7 +5253,7 @@ function warnIfUnnamedPreset(selector, hint, hasName) {
|
|
|
4973
5253
|
if (el.getAttribute('aria-label') || el.getAttribute('aria-labelledby')) {
|
|
4974
5254
|
return;
|
|
4975
5255
|
}
|
|
4976
|
-
|
|
5256
|
+
cngxDevWarn('CNGX1010', `[${selector}] role="${el.getAttribute('role') ?? 'meter'}" has no accessible name - ` +
|
|
4977
5257
|
`AT announces the value with no subject. ${hint}`);
|
|
4978
5258
|
});
|
|
4979
5259
|
}
|
|
@@ -4992,24 +5272,53 @@ function warnIfUnnamedPreset(selector, hint, hasName) {
|
|
|
4992
5272
|
* from the chart's auto-Summary; consumers can override via
|
|
4993
5273
|
* `[ariaLabel]`.
|
|
4994
5274
|
*
|
|
4995
|
-
* @category common/chart/presets
|
|
4996
|
-
* @docsKind primary
|
|
4997
5275
|
* @wcag AA
|
|
4998
5276
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/sparkline.component.ts
|
|
4999
|
-
* @since 0.
|
|
5277
|
+
* @since 0.3.0
|
|
5000
5278
|
* @relatedTo CngxMiniArea, CngxMiniBar, CngxChart
|
|
5001
5279
|
*
|
|
5002
|
-
* <example-url
|
|
5003
|
-
* <example-url
|
|
5004
|
-
* <example-url
|
|
5280
|
+
* <example-url>/#/common/chart/sparkline/async-state-machine</example-url>
|
|
5281
|
+
* <example-url>/#/common/chart/sparkline/basic-sparklines</example-url>
|
|
5282
|
+
* <example-url>/#/common/chart/sparkline/with-area-fill</example-url>
|
|
5283
|
+
* @axis level atom
|
|
5005
5284
|
*/
|
|
5006
5285
|
class CngxSparkline {
|
|
5286
|
+
/**
|
|
5287
|
+
* Required series of y values, drawn left to right at evenly spaced index positions. The vertical
|
|
5288
|
+
* scale spans the data minimum to maximum, padded by one unit either side when every value is
|
|
5289
|
+
* equal.
|
|
5290
|
+
*/
|
|
5007
5291
|
data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
5292
|
+
/**
|
|
5293
|
+
* Width of the chart in px, also the width of the loading skeleton. Default `80`.
|
|
5294
|
+
*/
|
|
5008
5295
|
width = input(80, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
5296
|
+
/**
|
|
5297
|
+
* Height of the chart in px, also the height of the loading skeleton. Default `24`.
|
|
5298
|
+
*/
|
|
5009
5299
|
height = input(24, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
5300
|
+
/**
|
|
5301
|
+
* Stroke width of the line. A number is read as px and a string passes through as a CSS length;
|
|
5302
|
+
* unset falls back to `--cngx-line-stroke-width` (default `1.5px`).
|
|
5303
|
+
*/
|
|
5010
5304
|
strokeWidth = input(null, ...(ngDevMode ? [{ debugName: "strokeWidth" }] : /* istanbul ignore next */ []));
|
|
5305
|
+
/**
|
|
5306
|
+
* Fills the area under the line, down to the lowest value of `[data]`, with the same colour as the
|
|
5307
|
+
* line. Default `false`.
|
|
5308
|
+
*/
|
|
5011
5309
|
showArea = input(false, ...(ngDevMode ? [{ debugName: "showArea" }] : /* istanbul ignore next */ []));
|
|
5310
|
+
/**
|
|
5311
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
5312
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
5313
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
5314
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
5315
|
+
* always draws.
|
|
5316
|
+
*/
|
|
5012
5317
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
5318
|
+
/**
|
|
5319
|
+
* Accessible name of the chart, bound as `[aria-label]`; replaces the summary the chart generates
|
|
5320
|
+
* from the data. Unset or empty keeps that generated summary.
|
|
5321
|
+
*/
|
|
5013
5322
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5014
5323
|
preset = injectPresetState(() => this.state());
|
|
5015
5324
|
i18n = this.preset.i18n;
|
|
@@ -5108,22 +5417,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5108
5417
|
* `role="meter"`. A bound `[aria-label]` always wins and overrides the
|
|
5109
5418
|
* visible caption.
|
|
5110
5419
|
*
|
|
5111
|
-
* @category common/chart/presets
|
|
5112
|
-
* @docsKind primary
|
|
5113
5420
|
* @wcag AA
|
|
5114
5421
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/mini-bar.component.ts
|
|
5115
|
-
* @since 0.
|
|
5422
|
+
* @since 0.3.0
|
|
5116
5423
|
* @relatedTo CngxMiniArea, CngxSparkline, CngxDonut, CngxBullet
|
|
5117
5424
|
*
|
|
5118
|
-
* <example-url
|
|
5119
|
-
* <example-url
|
|
5425
|
+
* <example-url>/#/common/chart/mini-bar/async-state-machine</example-url>
|
|
5426
|
+
* <example-url>/#/common/chart/mini-bar/basic-readings</example-url>
|
|
5427
|
+
* @axis level atom
|
|
5120
5428
|
*/
|
|
5121
5429
|
class CngxMiniBar {
|
|
5430
|
+
/**
|
|
5431
|
+
* Required current reading. The fill width is its position between `[min]` and `[max]`, clamped to
|
|
5432
|
+
* 0-100%, and the value is exposed as `aria-valuenow`.
|
|
5433
|
+
*/
|
|
5122
5434
|
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
5435
|
+
/**
|
|
5436
|
+
* Upper end of the track, exposed as `aria-valuemax`. Default `100`; a value not above `[min]`
|
|
5437
|
+
* draws an empty fill.
|
|
5438
|
+
*/
|
|
5123
5439
|
max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
5440
|
+
/**
|
|
5441
|
+
* Lower end of the track, exposed as `aria-valuemin`. Default `0`.
|
|
5442
|
+
*/
|
|
5124
5443
|
min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
5444
|
+
/**
|
|
5445
|
+
* Visible caption above the track, which also names the host (`aria-label`) when `[aria-label]` is
|
|
5446
|
+
* unbound. Unset shows no caption.
|
|
5447
|
+
*/
|
|
5125
5448
|
label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
5449
|
+
/**
|
|
5450
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
5451
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
5452
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
5453
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
5454
|
+
* always draws. `aria-valuenow`, `aria-valuemin` and `aria-valuemax` are set only while the
|
|
5455
|
+
* drawing shows.
|
|
5456
|
+
*/
|
|
5126
5457
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
5458
|
+
/**
|
|
5459
|
+
* Accessible name of the meter, bound as `[aria-label]` and set on the host. Unset falls back to
|
|
5460
|
+
* `[label]`; with neither the meter is unnamed and logs a dev-mode warning.
|
|
5461
|
+
*/
|
|
5127
5462
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5128
5463
|
preset = injectPresetState(() => this.state());
|
|
5129
5464
|
i18n = this.preset.i18n;
|
|
@@ -5137,7 +5472,9 @@ class CngxMiniBar {
|
|
|
5137
5472
|
*/
|
|
5138
5473
|
showsMeterValue = computed(() => this.activeView() === 'content', ...(ngDevMode ? [{ debugName: "showsMeterValue" }] : /* istanbul ignore next */ []));
|
|
5139
5474
|
constructor() {
|
|
5140
|
-
|
|
5475
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
5476
|
+
warnIfUnnamedPreset('cngx-mini-bar', 'Bind [label] or [aria-label].', () => !!(this.ariaLabel() ?? this.label()));
|
|
5477
|
+
}
|
|
5141
5478
|
}
|
|
5142
5479
|
percent = computed(() => clampedRatio(this.value(), this.min(), this.max()) * 100, ...(ngDevMode ? [{ debugName: "percent" }] : /* istanbul ignore next */ []));
|
|
5143
5480
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMiniBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -5207,21 +5544,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5207
5544
|
* Use cases: budget variance ("$+45k over"), score deltas ("−12%
|
|
5208
5545
|
* vs target"), KPI swing visualisations.
|
|
5209
5546
|
*
|
|
5210
|
-
* @category common/chart/presets
|
|
5211
|
-
* @docsKind primary
|
|
5212
5547
|
* @wcag AA
|
|
5213
5548
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/deviation-bar.component.ts
|
|
5214
|
-
* @since 0.
|
|
5549
|
+
* @since 0.3.0
|
|
5215
5550
|
* @relatedTo CngxMiniBar, CngxBullet, CngxStackedBar
|
|
5216
5551
|
*
|
|
5217
|
-
* <example-url
|
|
5218
|
-
* <example-url
|
|
5552
|
+
* <example-url>/#/common/chart/deviation-bar/async-state-machine</example-url>
|
|
5553
|
+
* <example-url>/#/common/chart/deviation-bar/variance-readings</example-url>
|
|
5554
|
+
* @axis level atom
|
|
5219
5555
|
*/
|
|
5220
5556
|
class CngxDeviationBar {
|
|
5557
|
+
/**
|
|
5558
|
+
* Required current reading. The fill grows from the centre mark to the right when the value is
|
|
5559
|
+
* above `[baseline]` and to the left when below, and the value is exposed as `aria-valuenow`.
|
|
5560
|
+
*/
|
|
5221
5561
|
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
5562
|
+
/**
|
|
5563
|
+
* Reference value shown at the centre mark of the track. Default `0`; the meter range exposed to
|
|
5564
|
+
* assistive technology is `baseline - magnitude` to `baseline + magnitude`.
|
|
5565
|
+
*/
|
|
5222
5566
|
baseline = input(0, ...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
|
|
5567
|
+
/**
|
|
5568
|
+
* Distance from `[baseline]` to either end of the track, so a deviation of this size fills one
|
|
5569
|
+
* half and larger ones are clamped. Default `100`; 0 or less draws no fill.
|
|
5570
|
+
*/
|
|
5223
5571
|
magnitude = input(100, ...(ngDevMode ? [{ debugName: "magnitude" }] : /* istanbul ignore next */ []));
|
|
5572
|
+
/**
|
|
5573
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
5574
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
5575
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
5576
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
5577
|
+
* always draws. `aria-valuenow`, `aria-valuemin` and `aria-valuemax` are set only while the
|
|
5578
|
+
* drawing shows.
|
|
5579
|
+
*/
|
|
5224
5580
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
5581
|
+
/**
|
|
5582
|
+
* Accessible name of the meter, bound as `[aria-label]` and set on the host. Unset leaves the
|
|
5583
|
+
* meter unnamed, which logs a dev-mode warning.
|
|
5584
|
+
*/
|
|
5225
5585
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5226
5586
|
preset = injectPresetState(() => this.state());
|
|
5227
5587
|
i18n = this.preset.i18n;
|
|
@@ -5235,7 +5595,9 @@ class CngxDeviationBar {
|
|
|
5235
5595
|
*/
|
|
5236
5596
|
showsMeterValue = computed(() => this.activeView() === 'content', ...(ngDevMode ? [{ debugName: "showsMeterValue" }] : /* istanbul ignore next */ []));
|
|
5237
5597
|
constructor() {
|
|
5238
|
-
|
|
5598
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
5599
|
+
warnIfUnnamedPreset('cngx-deviation-bar', 'Bind [aria-label].', () => !!this.ariaLabel());
|
|
5600
|
+
}
|
|
5239
5601
|
}
|
|
5240
5602
|
/**
|
|
5241
5603
|
* The meter's valid range is centred on the baseline, not on zero:
|
|
@@ -5345,22 +5707,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5345
5707
|
* Default viewBox 80×24. Theming via `--cngx-mini-area-color`
|
|
5346
5708
|
* (atom-local) → `--cngx-chart-primary` (chart-level) cascade.
|
|
5347
5709
|
*
|
|
5348
|
-
* @category common/chart/presets
|
|
5349
|
-
* @docsKind primary
|
|
5350
5710
|
* @wcag AA
|
|
5351
5711
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/mini-area.component.ts
|
|
5352
|
-
* @since 0.
|
|
5712
|
+
* @since 0.3.0
|
|
5353
5713
|
* @relatedTo CngxSparkline, CngxMiniBar, CngxChart
|
|
5354
5714
|
*
|
|
5355
|
-
* <example-url
|
|
5356
|
-
* <example-url
|
|
5715
|
+
* <example-url>/#/common/chart/mini-area/async-state-machine</example-url>
|
|
5716
|
+
* <example-url>/#/common/chart/mini-area/inline-area-trends</example-url>
|
|
5717
|
+
* @axis level atom
|
|
5357
5718
|
*/
|
|
5358
5719
|
class CngxMiniArea {
|
|
5720
|
+
/**
|
|
5721
|
+
* Required series of y values, drawn left to right at evenly spaced index positions. The vertical
|
|
5722
|
+
* scale spans the data minimum to maximum, padded by one unit either side when every value is
|
|
5723
|
+
* equal.
|
|
5724
|
+
*/
|
|
5359
5725
|
data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
5726
|
+
/**
|
|
5727
|
+
* Width of the chart in px, also the width of the loading skeleton. Default `80`.
|
|
5728
|
+
*/
|
|
5360
5729
|
width = input(80, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
5730
|
+
/**
|
|
5731
|
+
* Height of the chart in px, also the height of the loading skeleton. Default `24`.
|
|
5732
|
+
*/
|
|
5361
5733
|
height = input(24, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
5734
|
+
/**
|
|
5735
|
+
* Fill opacity of the area, as a number or numeric string. Unset falls back to
|
|
5736
|
+
* `--cngx-area-opacity` (default `0.18`).
|
|
5737
|
+
*/
|
|
5362
5738
|
opacity = input(null, ...(ngDevMode ? [{ debugName: "opacity" }] : /* istanbul ignore next */ []));
|
|
5739
|
+
/**
|
|
5740
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
5741
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
5742
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
5743
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
5744
|
+
* always draws.
|
|
5745
|
+
*/
|
|
5363
5746
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
5747
|
+
/**
|
|
5748
|
+
* Accessible name of the chart, bound as `[aria-label]`; replaces the summary the chart generates
|
|
5749
|
+
* from the data. Unset or empty keeps that generated summary.
|
|
5750
|
+
*/
|
|
5364
5751
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5365
5752
|
preset = injectPresetState(() => this.state());
|
|
5366
5753
|
i18n = this.preset.i18n;
|
|
@@ -5451,23 +5838,54 @@ const TWO_PI = Math.PI * 2;
|
|
|
5451
5838
|
* same fallback `CngxMiniBar` uses. A bound `[aria-label]` always
|
|
5452
5839
|
* wins.
|
|
5453
5840
|
*
|
|
5454
|
-
* @category common/chart/presets
|
|
5455
|
-
* @docsKind primary
|
|
5456
5841
|
* @wcag AA
|
|
5457
5842
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/donut.component.ts
|
|
5458
|
-
* @since 0.
|
|
5843
|
+
* @since 0.3.0
|
|
5459
5844
|
* @relatedTo CngxBullet, CngxMiniBar, CngxDeviationBar
|
|
5460
5845
|
*
|
|
5461
|
-
* <example-url
|
|
5462
|
-
* <example-url
|
|
5846
|
+
* <example-url>/#/common/chart/donut/async-state-machine</example-url>
|
|
5847
|
+
* <example-url>/#/common/chart/donut/score-gauges</example-url>
|
|
5848
|
+
* @axis level atom
|
|
5463
5849
|
*/
|
|
5464
5850
|
class CngxDonut {
|
|
5851
|
+
/**
|
|
5852
|
+
* Required current reading. The foreground arc covers `value / max` of the ring, clamped to
|
|
5853
|
+
* 0-100%, running clockwise from 12 o'clock, and the value is exposed as `aria-valuenow`.
|
|
5854
|
+
*/
|
|
5465
5855
|
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
5856
|
+
/**
|
|
5857
|
+
* Value at which the ring is full, exposed as `aria-valuemax` (the minimum is fixed at 0). Default
|
|
5858
|
+
* `100`; 0 or less draws an empty ring.
|
|
5859
|
+
*/
|
|
5466
5860
|
max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
5861
|
+
/**
|
|
5862
|
+
* Outer diameter of the ring in px; sets the SVG width, height and viewBox and the size of the
|
|
5863
|
+
* loading skeleton. Default `48`.
|
|
5864
|
+
*/
|
|
5467
5865
|
size = input(48, ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
5866
|
+
/**
|
|
5867
|
+
* Stroke width of the ring and the arc in px; the radius is `(size - thickness) / 2`, so the
|
|
5868
|
+
* stroke stays inside `[size]`. Default `6`.
|
|
5869
|
+
*/
|
|
5468
5870
|
thickness = input(6, ...(ngDevMode ? [{ debugName: "thickness" }] : /* istanbul ignore next */ []));
|
|
5871
|
+
/**
|
|
5872
|
+
* Visible text centred inside the ring, which also names the host (`aria-label`) when
|
|
5873
|
+
* `[aria-label]` is unbound. Unset shows no text.
|
|
5874
|
+
*/
|
|
5469
5875
|
label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
5876
|
+
/**
|
|
5877
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
5878
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
5879
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
5880
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
5881
|
+
* always draws. `aria-valuenow`, `aria-valuemin` and `aria-valuemax` are set only while the
|
|
5882
|
+
* drawing shows.
|
|
5883
|
+
*/
|
|
5470
5884
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
5885
|
+
/**
|
|
5886
|
+
* Accessible name of the meter, bound as `[aria-label]` and set on the host. Unset falls back to
|
|
5887
|
+
* `[label]`; with neither the meter is unnamed and logs a dev-mode warning.
|
|
5888
|
+
*/
|
|
5471
5889
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5472
5890
|
preset = injectPresetState(() => this.state());
|
|
5473
5891
|
i18n = this.preset.i18n;
|
|
@@ -5481,7 +5899,9 @@ class CngxDonut {
|
|
|
5481
5899
|
*/
|
|
5482
5900
|
showsMeterValue = computed(() => this.activeView() === 'content', ...(ngDevMode ? [{ debugName: "showsMeterValue" }] : /* istanbul ignore next */ []));
|
|
5483
5901
|
constructor() {
|
|
5484
|
-
|
|
5902
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
5903
|
+
warnIfUnnamedPreset('cngx-donut', 'Bind [label] or [aria-label].', () => !!(this.ariaLabel() ?? this.label()));
|
|
5904
|
+
}
|
|
5485
5905
|
}
|
|
5486
5906
|
center = computed(() => this.size() / 2, ...(ngDevMode ? [{ debugName: "center" }] : /* istanbul ignore next */ []));
|
|
5487
5907
|
radius = computed(() => (this.size() - this.thickness()) / 2, ...(ngDevMode ? [{ debugName: "radius" }] : /* istanbul ignore next */ []));
|
|
@@ -5616,22 +6036,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5616
6036
|
* `[actual]` filled bar, and a `[target]` vertical marker. Pure DOM,
|
|
5617
6037
|
* no SVG. Host carries `role="meter"`.
|
|
5618
6038
|
*
|
|
5619
|
-
* @category common/chart/presets
|
|
5620
|
-
* @docsKind primary
|
|
5621
6039
|
* @wcag AA
|
|
5622
6040
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/bullet.component.ts
|
|
5623
|
-
* @since 0.
|
|
6041
|
+
* @since 0.3.0
|
|
5624
6042
|
* @relatedTo CngxDonut, CngxMiniBar, CngxDeviationBar
|
|
5625
6043
|
*
|
|
5626
|
-
* <example-url
|
|
5627
|
-
* <example-url
|
|
6044
|
+
* <example-url>/#/common/chart/bullet/async-state-machine</example-url>
|
|
6045
|
+
* <example-url>/#/common/chart/bullet/performance-vs-target</example-url>
|
|
6046
|
+
* @axis level atom
|
|
5628
6047
|
*/
|
|
5629
6048
|
class CngxBullet {
|
|
6049
|
+
/**
|
|
6050
|
+
* Required current reading. The filled bar runs from 0 to this value, clamped to the scale
|
|
6051
|
+
* maximum, and the value is exposed as `aria-valuenow`.
|
|
6052
|
+
*/
|
|
5630
6053
|
actual = input.required(...(ngDevMode ? [{ debugName: "actual" }] : /* istanbul ignore next */ []));
|
|
6054
|
+
/**
|
|
6055
|
+
* Value of the vertical target marker, on the same 0 to maximum scale as the bar. Default `null`,
|
|
6056
|
+
* which does not hide the marker: it stays at the start of the track (0%).
|
|
6057
|
+
*/
|
|
5631
6058
|
target = input(null, ...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
6059
|
+
/**
|
|
6060
|
+
* Scale maximum, exposed as `aria-valuemax` (the minimum is fixed at 0). Default `null`, and a
|
|
6061
|
+
* value of 0 or less counts as unset: the maximum is then the largest of `[actual]`, `[target]`
|
|
6062
|
+
* and every range's `to`, or 1 when none is above 0.
|
|
6063
|
+
*/
|
|
5632
6064
|
max = input(null, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
6065
|
+
/**
|
|
6066
|
+
* Background bands behind the bar, each `{ from, to, color?, label? }` on the same scale with
|
|
6067
|
+
* `from` and `to` in either order. Default empty; a band without `color` paints nothing, and
|
|
6068
|
+
* `label` is not drawn.
|
|
6069
|
+
*/
|
|
5633
6070
|
ranges = input([], ...(ngDevMode ? [{ debugName: "ranges" }] : /* istanbul ignore next */ []));
|
|
6071
|
+
/**
|
|
6072
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
6073
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
6074
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
6075
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
6076
|
+
* always draws. `aria-valuenow`, `aria-valuemin` and `aria-valuemax` are set only while the
|
|
6077
|
+
* drawing shows.
|
|
6078
|
+
*/
|
|
5634
6079
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
6080
|
+
/**
|
|
6081
|
+
* Accessible name of the meter, bound as `[aria-label]` and set on the host. Unset leaves the
|
|
6082
|
+
* meter unnamed, which logs a dev-mode warning.
|
|
6083
|
+
*/
|
|
5635
6084
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5636
6085
|
preset = injectPresetState(() => this.state());
|
|
5637
6086
|
i18n = this.preset.i18n;
|
|
@@ -5645,7 +6094,9 @@ class CngxBullet {
|
|
|
5645
6094
|
*/
|
|
5646
6095
|
showsMeterValue = computed(() => this.activeView() === 'content', ...(ngDevMode ? [{ debugName: "showsMeterValue" }] : /* istanbul ignore next */ []));
|
|
5647
6096
|
constructor() {
|
|
5648
|
-
|
|
6097
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
6098
|
+
warnIfUnnamedPreset('cngx-bullet', 'Bind [aria-label].', () => !!this.ariaLabel());
|
|
6099
|
+
}
|
|
5649
6100
|
}
|
|
5650
6101
|
maxValue = computed(() => {
|
|
5651
6102
|
const explicit = this.max();
|
|
@@ -5794,20 +6245,41 @@ function rangeRenderingsEqual(a, b) {
|
|
|
5794
6245
|
* bounded reading; the SR description enumerates segments via the
|
|
5795
6246
|
* auto-generated `aria-label` (or the `[ariaLabel]` override).
|
|
5796
6247
|
*
|
|
5797
|
-
* @category common/chart/presets
|
|
5798
|
-
* @docsKind primary
|
|
5799
6248
|
* @wcag AA
|
|
5800
6249
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/stacked-bar.component.ts
|
|
5801
|
-
* @since 0.
|
|
6250
|
+
* @since 0.3.0
|
|
5802
6251
|
* @relatedTo CngxBar, CngxDeviationBar, CngxBullet
|
|
5803
6252
|
*
|
|
5804
|
-
* <example-url
|
|
5805
|
-
* <example-url
|
|
6253
|
+
* <example-url>/#/common/chart/stacked-bar/async-state-machine</example-url>
|
|
6254
|
+
* <example-url>/#/common/chart/stacked-bar/proportional-share-strips</example-url>
|
|
6255
|
+
* @axis level atom
|
|
5806
6256
|
*/
|
|
5807
6257
|
class CngxStackedBar {
|
|
6258
|
+
/**
|
|
6259
|
+
* Required segments drawn left to right in order, each `{ value, label, color? }` and sized as
|
|
6260
|
+
* `value / total` of the track. The label and value also feed each segment's `title` tooltip and
|
|
6261
|
+
* the generated `aria-label`; a segment without `color` uses `--cngx-stacked-bar-segment-color`.
|
|
6262
|
+
*/
|
|
5808
6263
|
segments = input.required(...(ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []));
|
|
6264
|
+
/**
|
|
6265
|
+
* Value that fills the whole track. Default `null`, and a value of 0 or less counts as unset: the
|
|
6266
|
+
* total is then the sum of the segment values (1 when that is not above 0), and segments beyond a
|
|
6267
|
+
* smaller total are clipped by the track.
|
|
6268
|
+
*/
|
|
5809
6269
|
total = input(null, ...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
6270
|
+
/**
|
|
6271
|
+
* Optional async state that picks the view: a skeleton with `aria-busy` on the host during the
|
|
6272
|
+
* first load, the built-in empty or error text after an empty or failed first load (copy from
|
|
6273
|
+
* `CNGX_CHART_I18N`), nothing while idle, the drawing otherwise. Only its status, first-load and
|
|
6274
|
+
* empty flags are read; the drawn values come from the preset's own inputs, and an unbound state
|
|
6275
|
+
* always draws. The host `aria-label` switches to the built-in loading, empty or error text while
|
|
6276
|
+
* the bar is loading, empty or failed.
|
|
6277
|
+
*/
|
|
5810
6278
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
6279
|
+
/**
|
|
6280
|
+
* Accessible name of the host (`role="img"`), bound as `[aria-label]`; replaces the generated
|
|
6281
|
+
* segment summary while the bar draws. Unset or empty keeps that summary.
|
|
6282
|
+
*/
|
|
5811
6283
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5812
6284
|
preset = injectPresetState(() => this.state());
|
|
5813
6285
|
i18n = this.preset.i18n;
|
|
@@ -5959,7 +6431,7 @@ function segmentRenderingsEqual(a, b) {
|
|
|
5959
6431
|
}
|
|
5960
6432
|
|
|
5961
6433
|
/**
|
|
5962
|
-
* @module
|
|
6434
|
+
* @module `@cngx/common/chart`
|
|
5963
6435
|
*
|
|
5964
6436
|
* Declarative, Signal-first chart system. Two-level architecture:
|
|
5965
6437
|
* composable atoms (`<cngx-chart>` element + `[cngxAxis]` and layer
|