@cngx/common 0.1.0-rc.9 → 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 +19 -8
- package/data/README.md +10 -10
- package/fesm2022/cngx-common-a11y.mjs +701 -263
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +83 -64
- 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 +135 -76
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +749 -296
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +51 -29
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +695 -405
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +112 -112
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +668 -308
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7066 -2739
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2121 -492
- 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 +1207 -569
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +256 -261
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +202 -262
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +28 -61
- 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 +1 -1
- package/menu-button/README.md +234 -0
- package/package.json +14 -4
- package/popover/README.md +42 -5
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/ng-add/index.js +7 -7
- package/schematics/ng-add/schema.json +5 -0
- package/stepper/README.md +0 -1
- 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 +43 -11
- package/theming/components/cngx-popover.css +37 -13
- 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 +343 -120
- 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 +671 -384
- package/types/cngx-common-command.d.ts +44 -47
- package/types/cngx-common-data.d.ts +350 -342
- package/types/cngx-common-dialog.d.ts +91 -120
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4350 -1723
- package/types/cngx-common-layout.d.ts +1365 -286
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +671 -289
- package/types/cngx-common-stepper.d.ts +217 -347
- package/types/cngx-common-tabs.d.ts +173 -386
- package/types/cngx-common-timeline.d.ts +25 -104
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CngxRuntimeError, clamp, cngxDevWarn, arrayEqual } from '@cngx/utils';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, DestroyRef, signal, computed, InjectionToken, input, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, linkedSignal, untracked, effect, ElementRef, contentChildren, contentChild, afterNextRender } from '@angular/core';
|
|
3
|
+
import { inject, DestroyRef, signal, computed, InjectionToken, input, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, linkedSignal, untracked, effect, ElementRef, contentChildren, contentChild, afterNextRender, afterRenderEffect } from '@angular/core';
|
|
4
4
|
import { NgTemplateOutlet } from '@angular/common';
|
|
5
5
|
import * as i1 from '@cngx/common/layout';
|
|
6
6
|
import { CngxResizeObserver } from '@cngx/common/layout';
|
|
@@ -21,8 +21,6 @@ import { formatMessage, createLanguageSection, createSectionBundle } from '@cngx
|
|
|
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,12 +89,10 @@ 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 a `CngxRuntimeError` (`CNGX1049`)
|
|
92
|
+
* an empty palette throws a `CngxRuntimeError` ([`CNGX1049`](/error-codes/cngx1049.md))
|
|
99
93
|
* synchronously at construction time.
|
|
100
94
|
* @returns Callable `(v: T) => string` returning the palette entry for
|
|
101
95
|
* `v`. Lookup of an unknown value returns the palette's first entry.
|
|
102
|
-
*
|
|
103
|
-
* @category common/chart/scales
|
|
104
96
|
*/
|
|
105
97
|
function createOrdinalScale(domain, colors) {
|
|
106
98
|
if (colors.length === 0) {
|
|
@@ -141,8 +133,6 @@ function createOrdinalScale(domain, colors) {
|
|
|
141
133
|
* area is computed against).
|
|
142
134
|
* @returns a fresh array of at most `targetSize` rows, or the input by
|
|
143
135
|
* reference when no reduction is needed.
|
|
144
|
-
*
|
|
145
|
-
* @category common/chart/buffer
|
|
146
136
|
*/
|
|
147
137
|
function downsampleLTTB(data, targetSize, xAccessor, yAccessor) {
|
|
148
138
|
const n = data.length;
|
|
@@ -209,6 +199,7 @@ function downsampleLTTB(data, targetSize, xAccessor, yAccessor) {
|
|
|
209
199
|
* Length + `Object.is` per-index equality on a readonly numeric array.
|
|
210
200
|
* Used by `summaryValues` and `summary.thresholds`. Reference-equal
|
|
211
201
|
* arrays short-circuit immediately.
|
|
202
|
+
* @internal
|
|
212
203
|
*/
|
|
213
204
|
function sameNumberArr(a, b) {
|
|
214
205
|
if (a === b) {
|
|
@@ -232,6 +223,7 @@ function sameNumberArr(a, b) {
|
|
|
232
223
|
* `snapshot()` allocates a fresh wrapper each call. Reference equality would
|
|
233
224
|
* never fire here (the wrapper is always new); element-wise is the only
|
|
234
225
|
* guard that dedups the buffer's `points` cascade.
|
|
226
|
+
* @internal
|
|
235
227
|
*/
|
|
236
228
|
function sameItemsArr(a, b) {
|
|
237
229
|
if (a === b) {
|
|
@@ -253,6 +245,7 @@ function sameItemsArr(a, b) {
|
|
|
253
245
|
* produces a fresh literal even when the numeric pair is unchanged, so
|
|
254
246
|
* an `equal` fn on this signal is the foundation of the chart-graph
|
|
255
247
|
* cascade short-circuit.
|
|
248
|
+
* @internal
|
|
256
249
|
*/
|
|
257
250
|
function dimensionsEqual(a, b) {
|
|
258
251
|
return a.width === b.width && a.height === b.height;
|
|
@@ -263,6 +256,7 @@ function dimensionsEqual(a, b) {
|
|
|
263
256
|
* re-emits, so without this guard an unchanged axis set would cascade
|
|
264
257
|
* into the plot area and from there into both scale ranges and every
|
|
265
258
|
* axis geometry on each pass.
|
|
259
|
+
* @internal
|
|
266
260
|
*/
|
|
267
261
|
function insetEqual(a, b) {
|
|
268
262
|
return (a.inlineStart === b.inlineStart &&
|
|
@@ -274,6 +268,7 @@ function insetEqual(a, b) {
|
|
|
274
268
|
* Field-wise equality on the published plot rectangle. Only the four
|
|
275
269
|
* corners are compared - `width`/`height` are derived from them, so an
|
|
276
270
|
* equal pair of corners implies equal extents.
|
|
271
|
+
* @internal
|
|
277
272
|
*/
|
|
278
273
|
function plotAreaEqual(a, b) {
|
|
279
274
|
return a.x0 === b.x0 && a.y0 === b.y0 && a.x1 === b.x1 && a.y1 === b.y1;
|
|
@@ -286,6 +281,7 @@ function plotAreaEqual(a, b) {
|
|
|
286
281
|
* The context is a fresh literal on every read, so without this a
|
|
287
282
|
* resize that lands on the same pixel still re-renders every projected
|
|
288
283
|
* loading / empty / error template.
|
|
284
|
+
* @internal
|
|
289
285
|
*/
|
|
290
286
|
function slotContextEqual(a, b) {
|
|
291
287
|
return a.width === b.width && a.height === b.height && plotAreaEqual(a.plot, b.plot);
|
|
@@ -298,8 +294,7 @@ function slotContextEqual(a, b) {
|
|
|
298
294
|
* @param capacity positive integer maximum element count.
|
|
299
295
|
* @throws `CngxRuntimeError` (`CNGX1050`) when `capacity` is not a positive
|
|
300
296
|
* integer.
|
|
301
|
-
*
|
|
302
|
-
* @category common/chart/buffer
|
|
297
|
+
* @internal
|
|
303
298
|
*/
|
|
304
299
|
function createRingBuffer(capacity) {
|
|
305
300
|
if (!Number.isInteger(capacity) || capacity <= 0) {
|
|
@@ -369,8 +364,6 @@ function createRingBuffer(capacity) {
|
|
|
369
364
|
* }
|
|
370
365
|
* }
|
|
371
366
|
* ```
|
|
372
|
-
*
|
|
373
|
-
* @category common/chart/buffer
|
|
374
367
|
*/
|
|
375
368
|
function injectChartBuffer(opts) {
|
|
376
369
|
const destroyRef = inject(DestroyRef);
|
|
@@ -444,9 +437,8 @@ function injectChartBuffer(opts) {
|
|
|
444
437
|
* so a consumer-authored axis participates in scale building and plot
|
|
445
438
|
* insetting on equal terms with the ones the library ships.
|
|
446
439
|
*
|
|
447
|
-
* @category common/chart/axis
|
|
448
440
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/chart-axis.ts
|
|
449
|
-
* @since 0.
|
|
441
|
+
* @since 0.3.0
|
|
450
442
|
* @relatedTo CngxChartAxis, CngxAxis, CngxAxisDomain
|
|
451
443
|
*/
|
|
452
444
|
const CNGX_CHART_AXIS = new InjectionToken('CNGX_CHART_AXIS');
|
|
@@ -457,14 +449,13 @@ const CNGX_CHART_AXIS = new InjectionToken('CNGX_CHART_AXIS');
|
|
|
457
449
|
* via `useExisting`; child queries narrow the generic on the consumer
|
|
458
450
|
* side.
|
|
459
451
|
*
|
|
460
|
-
* @category common/chart
|
|
461
452
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
|
|
462
|
-
* @since 0.
|
|
453
|
+
* @since 0.3.0
|
|
463
454
|
*/
|
|
464
455
|
const CNGX_CHART_CONTEXT = new InjectionToken('CngxChartContext');
|
|
465
456
|
/**
|
|
466
457
|
* Inject the parent chart's reactive context. Throws a `CngxRuntimeError`
|
|
467
|
-
* with code `CNGX1048` when the consumer is not mounted as a content child
|
|
458
|
+
* with code [`CNGX1048`](/error-codes/cngx1048.md) when the consumer is not mounted as a content child
|
|
468
459
|
* of `<cngx-chart>`, in development and production alike. The `selector`
|
|
469
460
|
* argument is the consumer's public selector without brackets (`'cngxLine'`)
|
|
470
461
|
* and names it in the development message.
|
|
@@ -473,9 +464,8 @@ const CNGX_CHART_CONTEXT = new InjectionToken('CngxChartContext');
|
|
|
473
464
|
* read `plot`, the scales and `renderSvg` the same way the built-in
|
|
474
465
|
* layer atoms do.
|
|
475
466
|
*
|
|
476
|
-
* @category common/chart
|
|
477
467
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
|
|
478
|
-
* @since 0.
|
|
468
|
+
* @since 0.3.0
|
|
479
469
|
*/
|
|
480
470
|
function injectChartContext(selector) {
|
|
481
471
|
const ctx = inject(CNGX_CHART_CONTEXT, { optional: true });
|
|
@@ -493,9 +483,8 @@ function injectChartContext(selector) {
|
|
|
493
483
|
* `contentChildren(CNGX_CHART_LAYER, { descendants: true })` query on the
|
|
494
484
|
* chart shell collects every mounted layer's geometry through DI.
|
|
495
485
|
*
|
|
496
|
-
* @category common/chart/layers
|
|
497
486
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/chart-layer.ts
|
|
498
|
-
* @since 0.
|
|
487
|
+
* @since 0.3.0
|
|
499
488
|
* @relatedTo CngxLine, CngxArea, CngxBar, CngxScatter, CngxThreshold, CngxBand
|
|
500
489
|
*/
|
|
501
490
|
const CNGX_CHART_LAYER = new InjectionToken('CngxChartLayer');
|
|
@@ -511,24 +500,38 @@ const CNGX_CHART_LAYER = new InjectionToken('CngxChartLayer');
|
|
|
511
500
|
*
|
|
512
501
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
513
502
|
*
|
|
514
|
-
* @category common/chart/layers
|
|
515
|
-
* @docsKind primary
|
|
516
503
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/threshold.component.ts
|
|
517
|
-
* @since 0.
|
|
504
|
+
* @since 0.3.0
|
|
518
505
|
* @relatedTo CngxBand, CngxChart, CngxLine
|
|
519
506
|
*
|
|
520
|
-
* <example-url
|
|
521
|
-
* <example-url
|
|
522
|
-
* <example-url
|
|
523
|
-
* <example-url
|
|
524
|
-
* <example-url
|
|
525
|
-
* <example-url
|
|
526
|
-
* <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>
|
|
527
514
|
*/
|
|
528
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
|
+
*/
|
|
529
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
|
+
*/
|
|
530
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
|
+
*/
|
|
531
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
|
+
*/
|
|
532
535
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
533
536
|
ctx = injectChartContext('cngxThreshold');
|
|
534
537
|
bounds = computed(() => {
|
|
@@ -676,8 +679,7 @@ function formatChartNumber(v, locale) {
|
|
|
676
679
|
* The English chart section: the single source of the chart's English copy.
|
|
677
680
|
* `CNGX_CHART_I18N` defaults to it.
|
|
678
681
|
*
|
|
679
|
-
* @
|
|
680
|
-
* @since 0.1.0
|
|
682
|
+
* @since 0.3.0
|
|
681
683
|
* @relatedTo CNGX_CHART_I18N
|
|
682
684
|
*/
|
|
683
685
|
const CNGX_CHART_LANGUAGE_EN = {
|
|
@@ -781,28 +783,21 @@ const chartBundle = createSectionBundle({
|
|
|
781
783
|
* at its default still follows the app locale at the use site, including a
|
|
782
784
|
* runtime `CNGX_LOCALE` flip.
|
|
783
785
|
*
|
|
784
|
-
* @category common/chart/i18n
|
|
785
786
|
* @wcag AA
|
|
786
787
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/i18n/chart-i18n.ts
|
|
787
|
-
* @since 0.
|
|
788
|
+
* @since 0.3.0
|
|
788
789
|
*/
|
|
789
790
|
const CNGX_CHART_I18N = new InjectionToken('CngxChartI18n', {
|
|
790
791
|
providedIn: 'root',
|
|
791
792
|
factory: () => chartBundle.build(),
|
|
792
793
|
});
|
|
793
|
-
/** @internal */
|
|
794
|
-
function defineChartI18nFeature(fn) {
|
|
795
|
-
return Object.assign(fn, { _target: 'i18n' });
|
|
796
|
-
}
|
|
797
794
|
/**
|
|
798
795
|
* Override chart copy via a partial bundle - unset keys keep the language
|
|
799
796
|
* pack's copy, or the English default, and keep following the app locale.
|
|
800
797
|
* Pass a `Signal` to switch the language at runtime.
|
|
801
|
-
*
|
|
802
|
-
* @category common/chart/i18n
|
|
803
798
|
*/
|
|
804
799
|
function withChartI18nLabels(overrides) {
|
|
805
|
-
return
|
|
800
|
+
return (bundle) => createOverrideMerge(bundle, overrides);
|
|
806
801
|
}
|
|
807
802
|
/**
|
|
808
803
|
* Provider for the chart i18n bundle. The features apply on top of the
|
|
@@ -818,8 +813,6 @@ function withChartI18nLabels(overrides) {
|
|
|
818
813
|
* ),
|
|
819
814
|
* ]
|
|
820
815
|
* ```
|
|
821
|
-
*
|
|
822
|
-
* @category common/chart/i18n
|
|
823
816
|
*/
|
|
824
817
|
function provideChartI18n(...features) {
|
|
825
818
|
return {
|
|
@@ -967,8 +960,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
967
960
|
/**
|
|
968
961
|
* Threshold (px) below which `CngxChartSlotContext.small` is true.
|
|
969
962
|
* Hardcoded for v1; later releases may make this a config token.
|
|
970
|
-
*
|
|
971
|
-
* @category common/chart
|
|
972
963
|
*/
|
|
973
964
|
const CHART_SMALL_BREAKPOINT_PX = 400;
|
|
974
965
|
/**
|
|
@@ -987,9 +978,8 @@ const CHART_SMALL_BREAKPOINT_PX = 400;
|
|
|
987
978
|
* </cngx-chart>
|
|
988
979
|
* ```
|
|
989
980
|
*
|
|
990
|
-
* @category common/chart
|
|
991
981
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
992
|
-
* @since 0.
|
|
982
|
+
* @since 0.3.0
|
|
993
983
|
* @relatedTo CngxChartSlotContext, CngxChartEmpty, CngxChartError, CngxChart
|
|
994
984
|
*/
|
|
995
985
|
class CngxChartLoading {
|
|
@@ -1019,9 +1009,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1019
1009
|
* </cngx-chart>
|
|
1020
1010
|
* ```
|
|
1021
1011
|
*
|
|
1022
|
-
* @category common/chart
|
|
1023
1012
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1024
|
-
* @since 0.
|
|
1013
|
+
* @since 0.3.0
|
|
1025
1014
|
* @relatedTo CngxChartSlotContext, CngxChartLoading, CngxChartError, CngxChart
|
|
1026
1015
|
*/
|
|
1027
1016
|
class CngxChartEmpty {
|
|
@@ -1048,9 +1037,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1048
1037
|
* </cngx-chart>
|
|
1049
1038
|
* ```
|
|
1050
1039
|
*
|
|
1051
|
-
* @category common/chart
|
|
1052
1040
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1053
|
-
* @since 0.
|
|
1041
|
+
* @since 0.3.0
|
|
1054
1042
|
* @relatedTo CngxChartErrorContext, CngxChartLoading, CngxChartEmpty, CngxChart
|
|
1055
1043
|
*/
|
|
1056
1044
|
class CngxChartError {
|
|
@@ -1079,9 +1067,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1079
1067
|
* </cngx-chart>
|
|
1080
1068
|
* ```
|
|
1081
1069
|
*
|
|
1082
|
-
* @category common/chart
|
|
1083
1070
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1084
|
-
* @since 0.
|
|
1071
|
+
* @since 0.3.0
|
|
1085
1072
|
* @relatedTo CngxChartConnectionContext, CngxChartReconnecting, CngxChart
|
|
1086
1073
|
*/
|
|
1087
1074
|
class CngxChartConnectionError {
|
|
@@ -1110,9 +1097,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1110
1097
|
* </cngx-chart>
|
|
1111
1098
|
* ```
|
|
1112
1099
|
*
|
|
1113
|
-
* @category common/chart
|
|
1114
1100
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1115
|
-
* @since 0.
|
|
1101
|
+
* @since 0.3.0
|
|
1116
1102
|
* @relatedTo CngxChartConnectionContext, CngxChartConnectionError, CngxChart
|
|
1117
1103
|
*/
|
|
1118
1104
|
class CngxChartReconnecting {
|
|
@@ -1169,9 +1155,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1169
1155
|
* SR data-table (the `aria-describedby` channel the chart already owns),
|
|
1170
1156
|
* not on an element projected here.
|
|
1171
1157
|
*
|
|
1172
|
-
* @category common/chart
|
|
1173
1158
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/template-slots.ts
|
|
1174
|
-
* @since 0.
|
|
1159
|
+
* @since 0.3.0
|
|
1175
1160
|
* @relatedTo CngxChartSlotContext, CngxChartLoading, CngxChartEmpty, CngxChartError, CngxChart
|
|
1176
1161
|
*/
|
|
1177
1162
|
class CngxChartOverlay {
|
|
@@ -1341,9 +1326,8 @@ function significantChangeEqual(a, b) {
|
|
|
1341
1326
|
*
|
|
1342
1327
|
* @param summary the chart's `CngxChartSummary` signal.
|
|
1343
1328
|
*
|
|
1344
|
-
* @category common/chart
|
|
1345
1329
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/significant-change.ts
|
|
1346
|
-
* @since 0.
|
|
1330
|
+
* @since 0.3.0
|
|
1347
1331
|
*/
|
|
1348
1332
|
function createSignificantChangeTracker(summary) {
|
|
1349
1333
|
const pair = linkedSignal({ ...(ngDevMode ? { debugName: "pair" } : /* istanbul ignore next */ {}), source: summary,
|
|
@@ -1393,9 +1377,8 @@ function createSignificantChangeTracker(summary) {
|
|
|
1393
1377
|
* calls directly - no DI token, since the only second consumer today is a
|
|
1394
1378
|
* test double, which injects a fake `factory` through the deps.
|
|
1395
1379
|
*
|
|
1396
|
-
* @category common/chart/renderer
|
|
1397
1380
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/chart-renderer-controller.ts
|
|
1398
|
-
* @since 0.
|
|
1381
|
+
* @since 0.3.0
|
|
1399
1382
|
*/
|
|
1400
1383
|
function createChartRendererController(deps) {
|
|
1401
1384
|
let current = null;
|
|
@@ -1422,7 +1405,7 @@ function createChartRendererController(deps) {
|
|
|
1422
1405
|
forcedColors: forced,
|
|
1423
1406
|
});
|
|
1424
1407
|
current.mount(deps.host, deps.ctx);
|
|
1425
|
-
current.paint(deps.geometries());
|
|
1408
|
+
current.paint(deps.geometries(), deps.layerElements?.());
|
|
1426
1409
|
});
|
|
1427
1410
|
});
|
|
1428
1411
|
// Paint effect: repaint on geometry change; invalidate the color cache
|
|
@@ -1441,7 +1424,7 @@ function createChartRendererController(deps) {
|
|
|
1441
1424
|
lastDark = nextDark;
|
|
1442
1425
|
current?.invalidateColorCache?.();
|
|
1443
1426
|
}
|
|
1444
|
-
current?.paint(geometries);
|
|
1427
|
+
current?.paint(geometries, deps.layerElements?.());
|
|
1445
1428
|
});
|
|
1446
1429
|
});
|
|
1447
1430
|
deps.destroyRef.onDestroy(() => current?.destroy());
|
|
@@ -1495,8 +1478,8 @@ const stepMemo = new WeakMap();
|
|
|
1495
1478
|
/**
|
|
1496
1479
|
* @internal The forced-colors step of every geometry, `null` for the kinds
|
|
1497
1480
|
* outside the cycle. Line, bar and scatter count, area, threshold and band
|
|
1498
|
-
* do not
|
|
1499
|
-
*
|
|
1481
|
+
* do not. The SVG layers take the same steps
|
|
1482
|
+
* through `data-cngx-series-step`, so both backends count alike. Memoised by the
|
|
1500
1483
|
* array reference: the chart keeps the same geometries array while no
|
|
1501
1484
|
* layer emits a new geometry, so repaints without data (resize, DPR or
|
|
1502
1485
|
* palette flip) reuse the steps. A streaming chart gets a new array on
|
|
@@ -1588,8 +1571,13 @@ const SOLID_DASH = [];
|
|
|
1588
1571
|
* its 2D context: `Path2D` stroke/fill for line/area, per-mark loops for
|
|
1589
1572
|
* bar/scatter, `moveTo`/`lineTo` for threshold, `fillRect` for band.
|
|
1590
1573
|
*
|
|
1591
|
-
* Colors
|
|
1592
|
-
*
|
|
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
|
|
1593
1581
|
* paints hit the cache, so the paint hot path performs zero synchronous
|
|
1594
1582
|
* DOM reads. {@link CngxChartRenderer.invalidateColorCache} clears it -
|
|
1595
1583
|
* the renderer controller calls it on a `dimensions()` change (a proxy
|
|
@@ -1623,13 +1611,10 @@ const SOLID_DASH = [];
|
|
|
1623
1611
|
* other engines are unverified, so the backend paints the probed values.
|
|
1624
1612
|
* The renderer controller watches `(forced-colors: active)` and
|
|
1625
1613
|
* `(prefers-color-scheme: dark)` and invalidates the colour cache before
|
|
1626
|
-
* repainting on a flip, so a contrast-theme switch repaints at once.
|
|
1627
|
-
* difference from SVG: a layer wrapped in an extra `<svg:g>` still counts
|
|
1628
|
-
* here, since the backend only sees the layer order.
|
|
1614
|
+
* repainting on a flip, so a contrast-theme switch repaints at once.
|
|
1629
1615
|
*
|
|
1630
|
-
* @category common/chart/renderer
|
|
1631
1616
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/canvas-renderer.ts
|
|
1632
|
-
* @since 0.
|
|
1617
|
+
* @since 0.3.0
|
|
1633
1618
|
*/
|
|
1634
1619
|
function createCanvasRenderer(deps) {
|
|
1635
1620
|
let canvas = null;
|
|
@@ -1638,9 +1623,13 @@ function createCanvasRenderer(deps) {
|
|
|
1638
1623
|
let lastW = -1;
|
|
1639
1624
|
let lastH = -1;
|
|
1640
1625
|
let lastGeometries = [];
|
|
1626
|
+
let lastElements;
|
|
1641
1627
|
let dprCleanup = null;
|
|
1642
|
-
|
|
1643
|
-
|
|
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();
|
|
1644
1633
|
// Snapshot of deps.forcedColors, taken once per paint() so the per-mark
|
|
1645
1634
|
// colour lookups do not re-read the signal.
|
|
1646
1635
|
let forcedNow = false;
|
|
@@ -1650,23 +1639,43 @@ function createCanvasRenderer(deps) {
|
|
|
1650
1639
|
// Hatch patterns for the forced cycle, per palette and DPR.
|
|
1651
1640
|
let hatches = null;
|
|
1652
1641
|
let hatchDpr = -1;
|
|
1653
|
-
function readVar(name) {
|
|
1654
|
-
|
|
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;
|
|
1655
1660
|
}
|
|
1656
1661
|
/**
|
|
1657
1662
|
* Read a numeric CSS custom property (e.g. `--cngx-area-opacity`,
|
|
1658
1663
|
* `--cngx-line-stroke-width`), cached like colors so the paint hot path
|
|
1659
1664
|
* stays free of synchronous DOM reads. Falls back when unset / unparseable.
|
|
1660
1665
|
*/
|
|
1661
|
-
function resolveNumberVar(name, fallback) {
|
|
1662
|
-
|
|
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);
|
|
1663
1672
|
if (cached !== undefined) {
|
|
1664
1673
|
return cached;
|
|
1665
1674
|
}
|
|
1666
|
-
const raw = readVar(name);
|
|
1675
|
+
const raw = readVar(name, el);
|
|
1667
1676
|
const parsed = raw ? parseFloat(raw) : NaN;
|
|
1668
1677
|
const value = Number.isFinite(parsed) ? parsed : fallback;
|
|
1669
|
-
|
|
1678
|
+
entries.set(name, value);
|
|
1670
1679
|
return value;
|
|
1671
1680
|
}
|
|
1672
1681
|
/**
|
|
@@ -1710,7 +1719,7 @@ function createCanvasRenderer(deps) {
|
|
|
1710
1719
|
return 0;
|
|
1711
1720
|
}
|
|
1712
1721
|
}
|
|
1713
|
-
function colorOf(color, kind) {
|
|
1722
|
+
function colorOf(color, kind, el) {
|
|
1714
1723
|
// Forced colors: every mark paints CanvasText, ignoring the [color]
|
|
1715
1724
|
// literal and the var chain (parity with the layers' !important rules).
|
|
1716
1725
|
if (forcedNow) {
|
|
@@ -1721,33 +1730,37 @@ function createCanvasRenderer(deps) {
|
|
|
1721
1730
|
if (color !== null && !color.startsWith('--')) {
|
|
1722
1731
|
return color;
|
|
1723
1732
|
}
|
|
1733
|
+
if (!el) {
|
|
1734
|
+
return 'currentColor';
|
|
1735
|
+
}
|
|
1736
|
+
const entries = cacheOf(colorCache, el);
|
|
1724
1737
|
const key = color ?? `@${kind}`;
|
|
1725
|
-
const cached =
|
|
1738
|
+
const cached = entries.get(key);
|
|
1726
1739
|
if (cached !== undefined) {
|
|
1727
1740
|
return cached;
|
|
1728
1741
|
}
|
|
1729
1742
|
let resolved = 'currentColor';
|
|
1730
1743
|
if (color !== null) {
|
|
1731
|
-
resolved = readVar(color) || 'currentColor';
|
|
1744
|
+
resolved = readVar(color, el) || 'currentColor';
|
|
1732
1745
|
}
|
|
1733
1746
|
else {
|
|
1734
1747
|
// Walk the per-atom -> family fallback chain, first hit wins.
|
|
1735
1748
|
for (const name of KIND_VARS[kind]) {
|
|
1736
|
-
const value = readVar(name);
|
|
1749
|
+
const value = readVar(name, el);
|
|
1737
1750
|
if (value) {
|
|
1738
1751
|
resolved = value;
|
|
1739
1752
|
break;
|
|
1740
1753
|
}
|
|
1741
1754
|
}
|
|
1742
1755
|
}
|
|
1743
|
-
|
|
1756
|
+
entries.set(key, resolved);
|
|
1744
1757
|
return resolved;
|
|
1745
1758
|
}
|
|
1746
|
-
function strokeWidthOf(sw) {
|
|
1759
|
+
function strokeWidthOf(sw, el) {
|
|
1747
1760
|
// Unset -> the same `--cngx-line-stroke-width` var the SVG line reads,
|
|
1748
1761
|
// so per-atom stroke width survives the SVG->Canvas crossover.
|
|
1749
1762
|
if (sw === null) {
|
|
1750
|
-
return resolveNumberVar('--cngx-line-stroke-width', DEFAULT_STROKE_WIDTH);
|
|
1763
|
+
return resolveNumberVar('--cngx-line-stroke-width', DEFAULT_STROKE_WIDTH, el);
|
|
1751
1764
|
}
|
|
1752
1765
|
const n = typeof sw === 'number' ? sw : parseFloat(sw);
|
|
1753
1766
|
return Number.isFinite(n) ? n : DEFAULT_STROKE_WIDTH;
|
|
@@ -1757,12 +1770,12 @@ function createCanvasRenderer(deps) {
|
|
|
1757
1770
|
* as filled arcs in the layer's resolved colour. Same colour path as
|
|
1758
1771
|
* the stroke / fill so no second colour resolution is introduced.
|
|
1759
1772
|
*/
|
|
1760
|
-
function drawPointMarks(c, points, color, kind, radiusVar) {
|
|
1773
|
+
function drawPointMarks(c, points, color, kind, radiusVar, el) {
|
|
1761
1774
|
if (!points || points.length === 0) {
|
|
1762
1775
|
return;
|
|
1763
1776
|
}
|
|
1764
|
-
const r = resolveNumberVar(radiusVar, DEFAULT_POINT_RADIUS);
|
|
1765
|
-
c.fillStyle = colorOf(color, kind);
|
|
1777
|
+
const r = resolveNumberVar(radiusVar, DEFAULT_POINT_RADIUS, el);
|
|
1778
|
+
c.fillStyle = colorOf(color, kind, el);
|
|
1766
1779
|
for (const p of points) {
|
|
1767
1780
|
c.beginPath();
|
|
1768
1781
|
c.arc(p.cx, p.cy, r, 0, Math.PI * 2);
|
|
@@ -1807,7 +1820,7 @@ function createCanvasRenderer(deps) {
|
|
|
1807
1820
|
const onChange = () => {
|
|
1808
1821
|
dprCleanup?.();
|
|
1809
1822
|
dprCleanup = null;
|
|
1810
|
-
paint(lastGeometries);
|
|
1823
|
+
paint(lastGeometries, lastElements);
|
|
1811
1824
|
watchDpr();
|
|
1812
1825
|
};
|
|
1813
1826
|
mql.addEventListener('change', onChange, { once: true });
|
|
@@ -1831,8 +1844,9 @@ function createCanvasRenderer(deps) {
|
|
|
1831
1844
|
// flip and on the chart's DestroyRef). Self-registering here would
|
|
1832
1845
|
// pile up one never-unregistered closure per svg<->canvas flip.
|
|
1833
1846
|
}
|
|
1834
|
-
function paint(geometries) {
|
|
1847
|
+
function paint(geometries, elements) {
|
|
1835
1848
|
lastGeometries = geometries;
|
|
1849
|
+
lastElements = elements;
|
|
1836
1850
|
const c = ctx2d;
|
|
1837
1851
|
if (!canvas || !c) {
|
|
1838
1852
|
return;
|
|
@@ -1843,14 +1857,14 @@ function createCanvasRenderer(deps) {
|
|
|
1843
1857
|
c.clearRect(0, 0, width, height);
|
|
1844
1858
|
const steps = forcedNow ? forcedSeriesSteps(geometries) : null;
|
|
1845
1859
|
for (let i = 0; i < geometries.length; i++) {
|
|
1846
|
-
paintOne(c, geometries[i], steps?.[i] ?? null);
|
|
1860
|
+
paintOne(c, geometries[i], steps?.[i] ?? null, elements?.[i] ?? hostEl);
|
|
1847
1861
|
}
|
|
1848
1862
|
}
|
|
1849
|
-
function paintOne(c, g, step) {
|
|
1863
|
+
function paintOne(c, g, step, el) {
|
|
1850
1864
|
switch (g.kind) {
|
|
1851
1865
|
case 'line': {
|
|
1852
|
-
c.strokeStyle = colorOf(g.color, 'line');
|
|
1853
|
-
c.lineWidth = strokeWidthOf(g.strokeWidth);
|
|
1866
|
+
c.strokeStyle = colorOf(g.color, 'line', el);
|
|
1867
|
+
c.lineWidth = strokeWidthOf(g.strokeWidth, el);
|
|
1854
1868
|
c.lineJoin = 'round';
|
|
1855
1869
|
c.lineCap = 'round';
|
|
1856
1870
|
// Forced colors: the legend's dash for this series step (round caps
|
|
@@ -1862,15 +1876,16 @@ function createCanvasRenderer(deps) {
|
|
|
1862
1876
|
if (step !== null) {
|
|
1863
1877
|
c.setLineDash(SOLID_DASH);
|
|
1864
1878
|
}
|
|
1865
|
-
drawPointMarks(c, g.points, g.color, 'line', '--cngx-line-point-radius');
|
|
1879
|
+
drawPointMarks(c, g.points, g.color, 'line', '--cngx-line-point-radius', el);
|
|
1866
1880
|
break;
|
|
1867
1881
|
}
|
|
1868
1882
|
case 'area': {
|
|
1869
|
-
c.fillStyle = colorOf(g.color, 'area');
|
|
1870
|
-
c.globalAlpha =
|
|
1883
|
+
c.fillStyle = colorOf(g.color, 'area', el);
|
|
1884
|
+
c.globalAlpha =
|
|
1885
|
+
g.opacity ?? resolveNumberVar('--cngx-area-opacity', DEFAULT_AREA_OPACITY, el);
|
|
1871
1886
|
c.fill(new Path2D(g.d));
|
|
1872
1887
|
c.globalAlpha = 1;
|
|
1873
|
-
drawPointMarks(c, g.points, g.color, 'area', '--cngx-area-point-radius');
|
|
1888
|
+
drawPointMarks(c, g.points, g.color, 'area', '--cngx-area-point-radius', el);
|
|
1874
1889
|
break;
|
|
1875
1890
|
}
|
|
1876
1891
|
case 'bar': {
|
|
@@ -1881,7 +1896,7 @@ function createCanvasRenderer(deps) {
|
|
|
1881
1896
|
}
|
|
1882
1897
|
for (const r of g.rects) {
|
|
1883
1898
|
if (step === null) {
|
|
1884
|
-
c.fillStyle = colorOf(r.color, 'bar');
|
|
1899
|
+
c.fillStyle = colorOf(r.color, 'bar', el);
|
|
1885
1900
|
}
|
|
1886
1901
|
c.fillRect(r.x, r.y, r.w, r.h);
|
|
1887
1902
|
if (ring > 0) {
|
|
@@ -1898,7 +1913,7 @@ function createCanvasRenderer(deps) {
|
|
|
1898
1913
|
}
|
|
1899
1914
|
for (const m of g.marks) {
|
|
1900
1915
|
if (step === null) {
|
|
1901
|
-
c.fillStyle = colorOf(m.color, 'scatter');
|
|
1916
|
+
c.fillStyle = colorOf(m.color, 'scatter', el);
|
|
1902
1917
|
}
|
|
1903
1918
|
c.beginPath();
|
|
1904
1919
|
c.arc(m.cx, m.cy, m.r, 0, Math.PI * 2);
|
|
@@ -1910,7 +1925,7 @@ function createCanvasRenderer(deps) {
|
|
|
1910
1925
|
break;
|
|
1911
1926
|
}
|
|
1912
1927
|
case 'threshold': {
|
|
1913
|
-
c.strokeStyle = colorOf(g.color, 'threshold');
|
|
1928
|
+
c.strokeStyle = colorOf(g.color, 'threshold', el);
|
|
1914
1929
|
c.lineWidth = 1;
|
|
1915
1930
|
c.setLineDash(g.dashed ? [4, 3] : []);
|
|
1916
1931
|
c.beginPath();
|
|
@@ -1921,8 +1936,9 @@ function createCanvasRenderer(deps) {
|
|
|
1921
1936
|
break;
|
|
1922
1937
|
}
|
|
1923
1938
|
case 'band': {
|
|
1924
|
-
c.fillStyle = colorOf(g.color, 'band');
|
|
1925
|
-
c.globalAlpha =
|
|
1939
|
+
c.fillStyle = colorOf(g.color, 'band', el);
|
|
1940
|
+
c.globalAlpha =
|
|
1941
|
+
g.opacity ?? resolveNumberVar('--cngx-band-opacity', DEFAULT_BAND_OPACITY, el);
|
|
1926
1942
|
c.fillRect(g.x, g.y, g.w, g.h);
|
|
1927
1943
|
c.globalAlpha = 1;
|
|
1928
1944
|
break;
|
|
@@ -1930,8 +1946,9 @@ function createCanvasRenderer(deps) {
|
|
|
1930
1946
|
}
|
|
1931
1947
|
}
|
|
1932
1948
|
function invalidateColorCache() {
|
|
1933
|
-
colorCache
|
|
1934
|
-
numberCache
|
|
1949
|
+
colorCache = new WeakMap();
|
|
1950
|
+
numberCache = new WeakMap();
|
|
1951
|
+
styleCache = new WeakMap();
|
|
1935
1952
|
sysColors = null;
|
|
1936
1953
|
hatches = null;
|
|
1937
1954
|
}
|
|
@@ -1939,6 +1956,7 @@ function createCanvasRenderer(deps) {
|
|
|
1939
1956
|
dprCleanup?.();
|
|
1940
1957
|
dprCleanup = null;
|
|
1941
1958
|
lastGeometries = [];
|
|
1959
|
+
lastElements = undefined;
|
|
1942
1960
|
canvas?.remove();
|
|
1943
1961
|
canvas = null;
|
|
1944
1962
|
probe?.remove();
|
|
@@ -1947,8 +1965,9 @@ function createCanvasRenderer(deps) {
|
|
|
1947
1965
|
hostEl = null;
|
|
1948
1966
|
lastW = -1;
|
|
1949
1967
|
lastH = -1;
|
|
1950
|
-
colorCache
|
|
1951
|
-
numberCache
|
|
1968
|
+
colorCache = new WeakMap();
|
|
1969
|
+
numberCache = new WeakMap();
|
|
1970
|
+
styleCache = new WeakMap();
|
|
1952
1971
|
sysColors = null;
|
|
1953
1972
|
hatches = null;
|
|
1954
1973
|
}
|
|
@@ -1971,9 +1990,8 @@ function createCanvasRenderer(deps) {
|
|
|
1971
1990
|
* @param _deps unused; kept for factory signature symmetry with
|
|
1972
1991
|
* {@link createCanvasRenderer}.
|
|
1973
1992
|
*
|
|
1974
|
-
* @category common/chart/renderer
|
|
1975
1993
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/svg-renderer.ts
|
|
1976
|
-
* @since 0.
|
|
1994
|
+
* @since 0.3.0
|
|
1977
1995
|
*/
|
|
1978
1996
|
function createSvgRenderer(_deps) {
|
|
1979
1997
|
const noop = () => undefined;
|
|
@@ -1995,9 +2013,8 @@ function createSvgRenderer(_deps) {
|
|
|
1995
2013
|
* bare provider) to tune the SVG/Canvas crossover for a given app's
|
|
1996
2014
|
* hardware profile.
|
|
1997
2015
|
*
|
|
1998
|
-
* @category common/chart/renderer
|
|
1999
2016
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-threshold.ts
|
|
2000
|
-
* @since 0.
|
|
2017
|
+
* @since 0.3.0
|
|
2001
2018
|
* @relatedTo provideChartRenderer, withChartRendererThreshold
|
|
2002
2019
|
*/
|
|
2003
2020
|
const CNGX_CHART_RENDERER_THRESHOLD = new InjectionToken('CngxChartRendererThreshold', { providedIn: 'root', factory: () => 500 });
|
|
@@ -2009,9 +2026,8 @@ const CNGX_CHART_RENDERER_THRESHOLD = new InjectionToken('CngxChartRendererThres
|
|
|
2009
2026
|
* (WebGL, ...) supplies a whole replacement via
|
|
2010
2027
|
* {@link withChartRendererFactory}.
|
|
2011
2028
|
*
|
|
2012
|
-
* @category common/chart/renderer
|
|
2013
2029
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2014
|
-
* @since 0.
|
|
2030
|
+
* @since 0.3.0
|
|
2015
2031
|
*/
|
|
2016
2032
|
const createDefaultChartRenderer = (mode, deps) => mode === 'svg' ? createSvgRenderer(deps) : createCanvasRenderer(deps);
|
|
2017
2033
|
/**
|
|
@@ -2020,18 +2036,16 @@ const createDefaultChartRenderer = (mode, deps) => mode === 'svg' ? createSvgRen
|
|
|
2020
2036
|
* {@link withChartRendererFactory} to add a backend without touching layer
|
|
2021
2037
|
* atoms.
|
|
2022
2038
|
*
|
|
2023
|
-
* @category common/chart/renderer
|
|
2024
2039
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2025
|
-
* @since 0.
|
|
2040
|
+
* @since 0.3.0
|
|
2026
2041
|
* @relatedTo provideChartRenderer, withChartRendererFactory
|
|
2027
2042
|
*/
|
|
2028
2043
|
const CNGX_CHART_RENDERER_FACTORY = new InjectionToken('CngxChartRendererFactory', { providedIn: 'root', factory: () => createDefaultChartRenderer });
|
|
2029
2044
|
/**
|
|
2030
2045
|
* Override the SVG->Canvas auto-switch cutoff (default `500`).
|
|
2031
2046
|
*
|
|
2032
|
-
* @category common/chart/renderer
|
|
2033
2047
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2034
|
-
* @since 0.
|
|
2048
|
+
* @since 0.3.0
|
|
2035
2049
|
*/
|
|
2036
2050
|
function withChartRendererThreshold(n) {
|
|
2037
2051
|
return { providers: [{ provide: CNGX_CHART_RENDERER_THRESHOLD, useValue: n }] };
|
|
@@ -2041,9 +2055,8 @@ function withChartRendererThreshold(n) {
|
|
|
2041
2055
|
* third. Consumers wanting a heuristic swap supply a custom factory here
|
|
2042
2056
|
* (the heuristic-swap axis ships no dedicated token at v2).
|
|
2043
2057
|
*
|
|
2044
|
-
* @category common/chart/renderer
|
|
2045
2058
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2046
|
-
* @since 0.
|
|
2059
|
+
* @since 0.3.0
|
|
2047
2060
|
*/
|
|
2048
2061
|
function withChartRendererFactory(fn) {
|
|
2049
2062
|
return { providers: [{ provide: CNGX_CHART_RENDERER_FACTORY, useValue: fn }] };
|
|
@@ -2057,15 +2070,16 @@ function withChartRendererFactory(fn) {
|
|
|
2057
2070
|
* provideChartRenderer(withChartRendererThreshold(2000))
|
|
2058
2071
|
* ```
|
|
2059
2072
|
*
|
|
2060
|
-
* @category common/chart/renderer
|
|
2061
2073
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/renderer/renderer-factory.ts
|
|
2062
|
-
* @since 0.
|
|
2074
|
+
* @since 0.3.0
|
|
2063
2075
|
* @relatedTo withChartRendererThreshold, withChartRendererFactory
|
|
2064
2076
|
*/
|
|
2065
2077
|
function provideChartRenderer(...features) {
|
|
2066
2078
|
return features.flatMap((f) => f.providers);
|
|
2067
2079
|
}
|
|
2068
2080
|
|
|
2081
|
+
/** @internal `Node.ELEMENT_NODE`, without reaching for the DOM global on the server. */
|
|
2082
|
+
const ELEMENT_NODE = 1;
|
|
2069
2083
|
/** @internal */
|
|
2070
2084
|
const NOOP_SCALE = () => 0;
|
|
2071
2085
|
/** @internal */
|
|
@@ -2144,40 +2158,50 @@ const DEFAULT_SUMMARY_ACCESSOR = (d) => Number(d);
|
|
|
2144
2158
|
* consumer restyling `--cngx-axis-font-size` gets labels at their own
|
|
2145
2159
|
* size inside a gutter sized for the default.
|
|
2146
2160
|
*
|
|
2147
|
-
* @category common/chart
|
|
2148
|
-
* @docsKind primary
|
|
2149
2161
|
* @wcag AA
|
|
2150
2162
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart.component.ts
|
|
2151
|
-
* @since 0.
|
|
2163
|
+
* @since 0.3.0
|
|
2152
2164
|
* @relatedTo CngxAxis, CngxLine, CngxArea, CngxBar, CngxChartLegend
|
|
2153
2165
|
*
|
|
2154
|
-
* <example-url
|
|
2155
|
-
* <example-url
|
|
2156
|
-
* <example-url
|
|
2157
|
-
* <example-url
|
|
2158
|
-
* <example-url
|
|
2159
|
-
* <example-url
|
|
2160
|
-
* <example-url
|
|
2161
|
-
* <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>
|
|
2162
2174
|
* @slot cngxChartLoading Replaces the centred spinner shown during the first load.
|
|
2163
2175
|
* @slot cngxChartEmpty Rendered when the data resolves to nothing.
|
|
2164
2176
|
* @slot cngxChartError Rendered when the load fails; gets the error.
|
|
2165
2177
|
* @slot cngxChartConnectionError Rendered over the chart when the live connection drops.
|
|
2166
2178
|
* @slot cngxChartReconnecting Rendered over the chart while the connection retries.
|
|
2167
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
|
|
2168
2181
|
*/
|
|
2169
2182
|
class CngxChart {
|
|
2170
2183
|
/**
|
|
2171
|
-
*
|
|
2172
|
-
*
|
|
2173
|
-
*
|
|
2174
|
-
* call `this.ctx.data<T>()` to narrow without per-site casts.
|
|
2175
|
-
*
|
|
2176
|
-
* @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">`.
|
|
2177
2187
|
*/
|
|
2178
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
|
+
*/
|
|
2179
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
|
+
*/
|
|
2180
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
|
+
*/
|
|
2181
2205
|
preserveAspectRatio = input('xMidYMid meet', ...(ngDevMode ? [{ debugName: "preserveAspectRatio" }] : /* istanbul ignore next */ []));
|
|
2182
2206
|
/**
|
|
2183
2207
|
* Optional explicit `aria-label` override. When set, supersedes the
|
|
@@ -2234,6 +2258,16 @@ class CngxChart {
|
|
|
2234
2258
|
axes = contentChildren(CNGX_CHART_AXIS, { ...(ngDevMode ? { debugName: "axes" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2235
2259
|
thresholds = contentChildren(CngxThreshold, { ...(ngDevMode ? { debugName: "thresholds" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2236
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 });
|
|
2237
2271
|
i18n = injectChartI18n();
|
|
2238
2272
|
dataTableId = nextUid('cngx-chart-data-table');
|
|
2239
2273
|
hatchId = nextUid('cngx-chart-hatch');
|
|
@@ -2382,6 +2416,7 @@ class CngxChart {
|
|
|
2382
2416
|
ctx: this,
|
|
2383
2417
|
mode: this.renderMode,
|
|
2384
2418
|
geometries: this.geometries,
|
|
2419
|
+
layerElements: this.layerElements,
|
|
2385
2420
|
factory: this.rendererFactory,
|
|
2386
2421
|
destroyRef: this.destroyRef,
|
|
2387
2422
|
});
|
|
@@ -2579,6 +2614,17 @@ class CngxChart {
|
|
|
2579
2614
|
* element-wise-equal and the paint cascade short-circuits.
|
|
2580
2615
|
*/
|
|
2581
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
|
+
}
|
|
2582
2628
|
viewBox = computed(() => {
|
|
2583
2629
|
const { width, height } = this.dimensions();
|
|
2584
2630
|
return `0 0 ${width || 0} ${height || 0}`;
|
|
@@ -2745,7 +2791,7 @@ class CngxChart {
|
|
|
2745
2791
|
return this.dataInput().length > 1;
|
|
2746
2792
|
}, ...(ngDevMode ? [{ debugName: "tableActive" }] : /* istanbul ignore next */ []));
|
|
2747
2793
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2748
|
-
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, descendants: true, 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: `
|
|
2749
2795
|
@switch (activeView()) {
|
|
2750
2796
|
@case ('skeleton') {
|
|
2751
2797
|
@if (loadingTpl(); as tpl) {
|
|
@@ -2974,7 +3020,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2974
3020
|
[hidden]="!tableActive() || activeView() !== 'content'"
|
|
2975
3021
|
/>
|
|
2976
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"] }]
|
|
2977
|
-
}], 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 }] }] } });
|
|
2978
3027
|
/** @internal */
|
|
2979
3028
|
function isHorizontalPosition(p) {
|
|
2980
3029
|
return p === 'top' || p === 'bottom';
|
|
@@ -3088,14 +3137,12 @@ function toMs$1(v) {
|
|
|
3088
3137
|
* <cngx-chart-announcer [cngxChartAnnouncer]="c" />
|
|
3089
3138
|
* ```
|
|
3090
3139
|
*
|
|
3091
|
-
* @category common/chart
|
|
3092
|
-
* @docsKind primary
|
|
3093
3140
|
* @wcag AA
|
|
3094
3141
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-announcer.component.ts
|
|
3095
|
-
* @since 0.
|
|
3142
|
+
* @since 0.3.0
|
|
3096
3143
|
* @relatedTo CngxChart, createSignificantChangeTracker
|
|
3097
3144
|
*
|
|
3098
|
-
* <example-url
|
|
3145
|
+
* <example-url>/#/common/chart/realtime/streaming-telemetry</example-url>
|
|
3099
3146
|
*/
|
|
3100
3147
|
class CngxChartAnnouncer {
|
|
3101
3148
|
/** The chart instance whose `significantChange()` this announcer voices. */
|
|
@@ -3153,19 +3200,17 @@ const AXIS_LABEL_OFFSET_BLOCK = 36;
|
|
|
3153
3200
|
* The declared default of `--cngx-axis-font-size` (see the tick-label
|
|
3154
3201
|
* rule in `styles` below), in viewBox user units.
|
|
3155
3202
|
*
|
|
3156
|
-
*
|
|
3157
|
-
*
|
|
3158
|
-
*
|
|
3159
|
-
*
|
|
3160
|
-
* at their size inside a gutter sized for the default; that is the
|
|
3161
|
-
* 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.
|
|
3162
3207
|
*
|
|
3163
3208
|
* @internal
|
|
3164
3209
|
*/
|
|
3165
3210
|
const AXIS_FONT_SIZE = 11;
|
|
3166
3211
|
/**
|
|
3167
|
-
* The declared default of `--cngx-axis-axis-label-font-size
|
|
3168
|
-
*
|
|
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.
|
|
3169
3214
|
*
|
|
3170
3215
|
* @internal
|
|
3171
3216
|
*/
|
|
@@ -3203,6 +3248,14 @@ const CHAR_ADVANCE_RATIO = 0.65;
|
|
|
3203
3248
|
* @internal
|
|
3204
3249
|
*/
|
|
3205
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
|
+
}
|
|
3206
3259
|
/**
|
|
3207
3260
|
* Declarative axis directive. Lives as a content child of
|
|
3208
3261
|
* `<cngx-chart>`; its `position` + `type` + `domain` inputs feed the
|
|
@@ -3220,25 +3273,47 @@ const LINE_BOX_RATIO = 1.5;
|
|
|
3220
3273
|
* semantic data view lives on the parent chart's auto-Summary and
|
|
3221
3274
|
* Data Table.
|
|
3222
3275
|
*
|
|
3223
|
-
* @category common/chart/axis
|
|
3224
|
-
* @docsKind primary
|
|
3225
3276
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/axis.component.ts
|
|
3226
|
-
* @since 0.
|
|
3277
|
+
* @since 0.3.0
|
|
3227
3278
|
* @relatedTo CngxChart, CngxLine, CngxBar, CngxArea
|
|
3228
3279
|
*
|
|
3229
|
-
* <example-url
|
|
3230
|
-
* <example-url
|
|
3231
|
-
* <example-url
|
|
3232
|
-
* <example-url
|
|
3233
|
-
* <example-url
|
|
3234
|
-
* <example-url
|
|
3235
|
-
* <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>
|
|
3236
3287
|
*/
|
|
3237
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
|
+
*/
|
|
3238
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
|
+
*/
|
|
3239
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
|
+
*/
|
|
3240
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
|
+
*/
|
|
3241
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
|
+
*/
|
|
3242
3317
|
format = input(defaultTickFormat, ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
3243
3318
|
/**
|
|
3244
3319
|
* Render decorative gridlines extending from each tick across the
|
|
@@ -3261,6 +3336,13 @@ class CngxAxis {
|
|
|
3261
3336
|
axisLabel = input(null, { ...(ngDevMode ? { debugName: "axisLabel" } : /* istanbul ignore next */ {}), alias: 'label' });
|
|
3262
3337
|
ctx = injectChartContext('cngxAxis');
|
|
3263
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 */ []));
|
|
3264
3346
|
/**
|
|
3265
3347
|
* The bound `[format]`, or the default tick formatter bound to the app
|
|
3266
3348
|
* locale (`CNGX_LOCALE`), so a locale flip re-formats the default labels.
|
|
@@ -3319,6 +3401,32 @@ class CngxAxis {
|
|
|
3319
3401
|
}
|
|
3320
3402
|
return true;
|
|
3321
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
|
+
}
|
|
3322
3430
|
/**
|
|
3323
3431
|
* How far this axis's decoration extends perpendicular to its own
|
|
3324
3432
|
* line, in viewBox user units. The parent chart reads it to size the
|
|
@@ -3338,10 +3446,14 @@ class CngxAxis {
|
|
|
3338
3446
|
*
|
|
3339
3447
|
* Character width is an estimate ({@link CHAR_ADVANCE_RATIO}), which
|
|
3340
3448
|
* is the one value here that is not derived from state the axis
|
|
3341
|
-
* owns.
|
|
3342
|
-
*
|
|
3343
|
-
*
|
|
3344
|
-
*
|
|
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.
|
|
3345
3457
|
*
|
|
3346
3458
|
* Acyclic by construction: {@link tickValues} reads `domain` /
|
|
3347
3459
|
* `ticks` / `type` and never the scale, so
|
|
@@ -3350,11 +3462,11 @@ class CngxAxis {
|
|
|
3350
3462
|
*/
|
|
3351
3463
|
reservation = computed(() => {
|
|
3352
3464
|
const horizontal = this.position() === 'top' || this.position() === 'bottom';
|
|
3353
|
-
const labelExtent = horizontal ?
|
|
3465
|
+
const labelExtent = horizontal ? this.fontSize() * LINE_BOX_RATIO : this.widestTickLabel();
|
|
3354
3466
|
const tickRoom = TICK_LENGTH + LABEL_OFFSET + labelExtent;
|
|
3355
3467
|
const titleRoom = this.axisLabel()
|
|
3356
3468
|
? (horizontal ? AXIS_LABEL_OFFSET_INLINE : AXIS_LABEL_OFFSET_BLOCK) +
|
|
3357
|
-
|
|
3469
|
+
this.titleFontSize() * LINE_BOX_RATIO
|
|
3358
3470
|
: 0;
|
|
3359
3471
|
// Whole user units, rounded up: the estimate is already an
|
|
3360
3472
|
// approximation, so rounding down would trade a clean number for a
|
|
@@ -3383,7 +3495,7 @@ class CngxAxis {
|
|
|
3383
3495
|
*/
|
|
3384
3496
|
crossReservation = computed(() => {
|
|
3385
3497
|
const horizontal = this.position() === 'top' || this.position() === 'bottom';
|
|
3386
|
-
const extent = horizontal ? this.widestTickLabel() :
|
|
3498
|
+
const extent = horizontal ? this.widestTickLabel() : this.fontSize() * LINE_BOX_RATIO;
|
|
3387
3499
|
return Math.ceil(extent / 2);
|
|
3388
3500
|
}, ...(ngDevMode ? [{ debugName: "crossReservation" }] : /* istanbul ignore next */ []));
|
|
3389
3501
|
/**
|
|
@@ -3392,7 +3504,7 @@ class CngxAxis {
|
|
|
3392
3504
|
* width actually matters - its own reservation is a line box, and
|
|
3393
3505
|
* only its cross-axis overhang depends on the strings.
|
|
3394
3506
|
*/
|
|
3395
|
-
widestTickLabel = computed(() => this.longestTickLabel() *
|
|
3507
|
+
widestTickLabel = computed(() => this.longestTickLabel() * this.fontSize() * CHAR_ADVANCE_RATIO, ...(ngDevMode ? [{ debugName: "widestTickLabel" }] : /* istanbul ignore next */ []));
|
|
3396
3508
|
/**
|
|
3397
3509
|
* Character count of the widest formatted tick label. Split out so
|
|
3398
3510
|
* that {@link reservation} on a horizontal axis never reads it - a
|
|
@@ -3609,7 +3721,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3609
3721
|
}
|
|
3610
3722
|
}
|
|
3611
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"] }]
|
|
3612
|
-
}], 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 }] }] } });
|
|
3613
3725
|
/** @internal */
|
|
3614
3726
|
function spread(start, end, count) {
|
|
3615
3727
|
if (count <= 1) {
|
|
@@ -3855,13 +3967,12 @@ const NO_RESERVATION = signal(0).asReadonly();
|
|
|
3855
3967
|
* namespace. Nothing renders either way, but the host stays a legal SVG
|
|
3856
3968
|
* child.
|
|
3857
3969
|
*
|
|
3858
|
-
* @category common/chart/axis
|
|
3859
3970
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/axis/axis-domain.ts
|
|
3860
|
-
* @since 0.
|
|
3971
|
+
* @since 0.3.0
|
|
3861
3972
|
* @relatedTo CngxAxis, CngxChart, CngxChartAxis
|
|
3862
3973
|
*
|
|
3863
|
-
* <example-url
|
|
3864
|
-
* <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>
|
|
3865
3976
|
*/
|
|
3866
3977
|
class CngxAxisDomain {
|
|
3867
3978
|
/** Which edge the scale this publishes belongs to. */
|
|
@@ -3931,16 +4042,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3931
4042
|
* (areas, thresholds, bands and axes do not count), so list the entries
|
|
3932
4043
|
* in the order of those layers.
|
|
3933
4044
|
*
|
|
3934
|
-
* @category common/chart/legend
|
|
3935
|
-
* @docsKind primary
|
|
3936
4045
|
* @wcag AA
|
|
3937
4046
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/legend/legend.component.ts
|
|
3938
|
-
* @since 0.
|
|
4047
|
+
* @since 0.3.0
|
|
3939
4048
|
* @relatedTo CngxChart, CngxLine, CngxBar
|
|
4049
|
+
* @axis level atom
|
|
3940
4050
|
*/
|
|
3941
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
|
+
*/
|
|
3942
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
|
+
*/
|
|
3943
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
|
+
*/
|
|
3944
4067
|
align = input('start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
3945
4068
|
locale = injectLocale();
|
|
3946
4069
|
/** @internal Each item's value as display text; numbers in the app locale. */
|
|
@@ -4089,8 +4212,6 @@ function pointsEqual(a, b) {
|
|
|
4089
4212
|
* overshoots between data points.
|
|
4090
4213
|
* @returns The full path data starting with `M`. Returns `''` when
|
|
4091
4214
|
* the input is empty; `M x y` when the input has one point.
|
|
4092
|
-
*
|
|
4093
|
-
* @category common/chart/path
|
|
4094
4215
|
*/
|
|
4095
4216
|
function buildCurvePath(points, curve) {
|
|
4096
4217
|
if (points.length === 0) {
|
|
@@ -4174,8 +4295,6 @@ function buildMonotonePath(points) {
|
|
|
4174
4295
|
* when the inputs to the `computed` are unchanged, two consecutive
|
|
4175
4296
|
* cascade ticks with the same `(y, x, curve)` produce the same
|
|
4176
4297
|
* builder instance.
|
|
4177
|
-
*
|
|
4178
|
-
* @category common/chart/path
|
|
4179
4298
|
*/
|
|
4180
4299
|
function createPathBuilder(opts) {
|
|
4181
4300
|
const yAcc = opts.y;
|
|
@@ -4265,26 +4384,47 @@ function projectFiniteRuns(data, xAcc, yAcc, xScale, yScale) {
|
|
|
4265
4384
|
* nothing. `[points]` controls this: `'auto'` (default) marks only the
|
|
4266
4385
|
* one-datum case, `'always'` marks every datum, `'never'` suppresses it.
|
|
4267
4386
|
*
|
|
4268
|
-
* @category common/chart/layers
|
|
4269
|
-
* @docsKind primary
|
|
4270
4387
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/line.component.ts
|
|
4271
|
-
* @since 0.
|
|
4388
|
+
* @since 0.3.0
|
|
4272
4389
|
* @relatedTo CngxArea, CngxScatter, CngxBar, CngxChart
|
|
4273
4390
|
*
|
|
4274
|
-
* <example-url
|
|
4275
|
-
* <example-url
|
|
4276
|
-
* <example-url
|
|
4277
|
-
* <example-url
|
|
4278
|
-
* <example-url
|
|
4279
|
-
* <example-url
|
|
4280
|
-
* <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>
|
|
4281
4398
|
*/
|
|
4282
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
|
+
*/
|
|
4283
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
|
+
*/
|
|
4284
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
|
+
*/
|
|
4285
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
|
+
*/
|
|
4286
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
|
+
*/
|
|
4287
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
|
+
*/
|
|
4288
4428
|
data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
4289
4429
|
/**
|
|
4290
4430
|
* Point-marker mode. `'auto'` (default) draws a marker only when the
|
|
@@ -4294,6 +4434,23 @@ class CngxLine {
|
|
|
4294
4434
|
*/
|
|
4295
4435
|
points = input('auto', ...(ngDevMode ? [{ debugName: "points" }] : /* istanbul ignore next */ []));
|
|
4296
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 */ []));
|
|
4297
4454
|
builder = computed(() => createPathBuilder({
|
|
4298
4455
|
y: this.accessor(),
|
|
4299
4456
|
x: this.xAccessor(),
|
|
@@ -4326,41 +4483,54 @@ class CngxLine {
|
|
|
4326
4483
|
return g.kind === 'line' ? (g.points ?? EMPTY_POINTS) : EMPTY_POINTS;
|
|
4327
4484
|
}, ...(ngDevMode ? [{ debugName: "pointMarks" }] : /* istanbul ignore next */ []));
|
|
4328
4485
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLine, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4329
|
-
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: `
|
|
4330
4487
|
@if (ctx.renderSvg()) {
|
|
4331
4488
|
<svg:path
|
|
4332
4489
|
class="cngx-line"
|
|
4333
4490
|
[attr.d]="d()"
|
|
4334
4491
|
[attr.fill]="'none'"
|
|
4335
4492
|
[style.stroke]="color()"
|
|
4336
|
-
[
|
|
4493
|
+
[style.stroke-width]="strokeWidthStyle()"
|
|
4337
4494
|
[attr.stroke-linejoin]="'round'"
|
|
4338
4495
|
[attr.stroke-linecap]="'round'"
|
|
4339
4496
|
/>
|
|
4340
4497
|
@for (p of pointMarks(); track $index) {
|
|
4341
|
-
<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
|
+
/>
|
|
4342
4504
|
}
|
|
4343
4505
|
}
|
|
4344
|
-
`, 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 });
|
|
4345
4507
|
}
|
|
4346
4508
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLine, decorators: [{
|
|
4347
4509
|
type: Component,
|
|
4348
|
-
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: `
|
|
4349
4514
|
@if (ctx.renderSvg()) {
|
|
4350
4515
|
<svg:path
|
|
4351
4516
|
class="cngx-line"
|
|
4352
4517
|
[attr.d]="d()"
|
|
4353
4518
|
[attr.fill]="'none'"
|
|
4354
4519
|
[style.stroke]="color()"
|
|
4355
|
-
[
|
|
4520
|
+
[style.stroke-width]="strokeWidthStyle()"
|
|
4356
4521
|
[attr.stroke-linejoin]="'round'"
|
|
4357
4522
|
[attr.stroke-linecap]="'round'"
|
|
4358
4523
|
/>
|
|
4359
4524
|
@for (p of pointMarks(); track $index) {
|
|
4360
|
-
<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
|
+
/>
|
|
4361
4531
|
}
|
|
4362
4532
|
}
|
|
4363
|
-
`, 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"] }]
|
|
4364
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 }] }] } });
|
|
4365
4535
|
|
|
4366
4536
|
/**
|
|
@@ -4378,27 +4548,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4378
4548
|
* nothing. `[points]` mirrors {@link CngxLine}: `'auto'` (default) marks
|
|
4379
4549
|
* only the one-datum case, `'always'` every datum, `'never'` none.
|
|
4380
4550
|
*
|
|
4381
|
-
* @category common/chart/layers
|
|
4382
|
-
* @docsKind primary
|
|
4383
4551
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/area.component.ts
|
|
4384
|
-
* @since 0.
|
|
4552
|
+
* @since 0.3.0
|
|
4385
4553
|
* @relatedTo CngxLine, CngxBand, CngxThreshold, CngxChart
|
|
4386
4554
|
*
|
|
4387
|
-
* <example-url
|
|
4388
|
-
* <example-url
|
|
4389
|
-
* <example-url
|
|
4390
|
-
* <example-url
|
|
4391
|
-
* <example-url
|
|
4392
|
-
* <example-url
|
|
4393
|
-
* <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>
|
|
4394
4562
|
*/
|
|
4395
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
|
+
*/
|
|
4396
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
|
+
*/
|
|
4397
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
|
+
*/
|
|
4398
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
|
+
*/
|
|
4399
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
|
+
*/
|
|
4400
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
|
+
*/
|
|
4401
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
|
+
*/
|
|
4402
4596
|
data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
4403
4597
|
/**
|
|
4404
4598
|
* Point-marker mode, mirroring {@link CngxLine}. `'auto'` (default)
|
|
@@ -4467,10 +4661,15 @@ class CngxArea {
|
|
|
4467
4661
|
[style.fill-opacity]="opacity()"
|
|
4468
4662
|
/>
|
|
4469
4663
|
@for (p of pointMarks(); track $index) {
|
|
4470
|
-
<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
|
+
/>
|
|
4471
4670
|
}
|
|
4472
4671
|
}
|
|
4473
|
-
`, 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 });
|
|
4474
4673
|
}
|
|
4475
4674
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxArea, decorators: [{
|
|
4476
4675
|
type: Component,
|
|
@@ -4483,10 +4682,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4483
4682
|
[style.fill-opacity]="opacity()"
|
|
4484
4683
|
/>
|
|
4485
4684
|
@for (p of pointMarks(); track $index) {
|
|
4486
|
-
<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
|
+
/>
|
|
4487
4691
|
}
|
|
4488
4692
|
}
|
|
4489
|
-
`, 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"] }]
|
|
4490
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 }] }] } });
|
|
4491
4695
|
|
|
4492
4696
|
/** @internal */
|
|
@@ -4503,27 +4707,49 @@ const FALLBACK_BASELINE = 0;
|
|
|
4503
4707
|
*
|
|
4504
4708
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
4505
4709
|
*
|
|
4506
|
-
* @category common/chart/layers
|
|
4507
|
-
* @docsKind primary
|
|
4508
4710
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/bar.component.ts
|
|
4509
|
-
* @since 0.
|
|
4711
|
+
* @since 0.3.0
|
|
4510
4712
|
* @relatedTo CngxLine, CngxArea, CngxStackedBar, CngxChart
|
|
4511
4713
|
*
|
|
4512
|
-
* <example-url
|
|
4513
|
-
* <example-url
|
|
4514
|
-
* <example-url
|
|
4515
|
-
* <example-url
|
|
4516
|
-
* <example-url
|
|
4517
|
-
* <example-url
|
|
4518
|
-
* <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>
|
|
4519
4721
|
*/
|
|
4520
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
|
+
*/
|
|
4521
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
|
+
*/
|
|
4522
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
|
+
*/
|
|
4523
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
|
+
*/
|
|
4524
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
|
+
*/
|
|
4525
4746
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4526
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 */ []));
|
|
4527
4753
|
resolvedData = computed(() => {
|
|
4528
4754
|
const local = this.data();
|
|
4529
4755
|
if (local !== undefined) {
|
|
@@ -4580,7 +4806,7 @@ class CngxBar {
|
|
|
4580
4806
|
})),
|
|
4581
4807
|
}), { ...(ngDevMode ? { debugName: "geometry" } : /* istanbul ignore next */ {}), equal: barGeomEqual });
|
|
4582
4808
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4583
|
-
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: `
|
|
4584
4810
|
@if (ctx.renderSvg()) {
|
|
4585
4811
|
@for (rect of rects(); track rect.key) {
|
|
4586
4812
|
<svg:rect
|
|
@@ -4593,11 +4819,14 @@ class CngxBar {
|
|
|
4593
4819
|
/>
|
|
4594
4820
|
}
|
|
4595
4821
|
}
|
|
4596
|
-
`, 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 });
|
|
4597
4823
|
}
|
|
4598
4824
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBar, decorators: [{
|
|
4599
4825
|
type: Component,
|
|
4600
|
-
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: `
|
|
4601
4830
|
@if (ctx.renderSvg()) {
|
|
4602
4831
|
@for (rect of rects(); track rect.key) {
|
|
4603
4832
|
<svg:rect
|
|
@@ -4610,7 +4839,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4610
4839
|
/>
|
|
4611
4840
|
}
|
|
4612
4841
|
}
|
|
4613
|
-
`, 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"] }]
|
|
4614
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 }] }] } });
|
|
4615
4844
|
/** @internal */
|
|
4616
4845
|
function barGeomEqual(a, b) {
|
|
@@ -4667,27 +4896,47 @@ function rectsEqual(a, b) {
|
|
|
4667
4896
|
*
|
|
4668
4897
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
4669
4898
|
*
|
|
4670
|
-
* @category common/chart/layers
|
|
4671
|
-
* @docsKind primary
|
|
4672
4899
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/scatter.component.ts
|
|
4673
|
-
* @since 0.
|
|
4900
|
+
* @since 0.3.0
|
|
4674
4901
|
* @relatedTo CngxLine, CngxBar, CngxArea, CngxChart
|
|
4675
4902
|
*
|
|
4676
|
-
* <example-url
|
|
4677
|
-
* <example-url
|
|
4678
|
-
* <example-url
|
|
4679
|
-
* <example-url
|
|
4680
|
-
* <example-url
|
|
4681
|
-
* <example-url
|
|
4682
|
-
* <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>
|
|
4683
4910
|
*/
|
|
4684
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
|
+
*/
|
|
4685
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
|
+
*/
|
|
4686
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
|
+
*/
|
|
4687
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
|
+
*/
|
|
4688
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
|
+
*/
|
|
4689
4933
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4690
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 */ []));
|
|
4691
4940
|
resolvedData = computed(() => {
|
|
4692
4941
|
const local = this.data();
|
|
4693
4942
|
if (local !== undefined) {
|
|
@@ -4719,7 +4968,7 @@ class CngxScatter {
|
|
|
4719
4968
|
};
|
|
4720
4969
|
}, { ...(ngDevMode ? { debugName: "geometry" } : /* istanbul ignore next */ {}), equal: scatterGeomEqual });
|
|
4721
4970
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScatter, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4722
|
-
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: `
|
|
4723
4972
|
@if (ctx.renderSvg()) {
|
|
4724
4973
|
@for (c of circles(); track c.key) {
|
|
4725
4974
|
<svg:circle
|
|
@@ -4731,11 +4980,14 @@ class CngxScatter {
|
|
|
4731
4980
|
/>
|
|
4732
4981
|
}
|
|
4733
4982
|
}
|
|
4734
|
-
`, 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 });
|
|
4735
4984
|
}
|
|
4736
4985
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScatter, decorators: [{
|
|
4737
4986
|
type: Component,
|
|
4738
|
-
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: `
|
|
4739
4991
|
@if (ctx.renderSvg()) {
|
|
4740
4992
|
@for (c of circles(); track c.key) {
|
|
4741
4993
|
<svg:circle
|
|
@@ -4747,7 +4999,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4747
4999
|
/>
|
|
4748
5000
|
}
|
|
4749
5001
|
}
|
|
4750
|
-
`, 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"] }]
|
|
4751
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 }] }] } });
|
|
4752
5004
|
/** @internal */
|
|
4753
5005
|
function scatterGeomEqual(a, b) {
|
|
@@ -4795,25 +5047,42 @@ function circlesEqual(a, b) {
|
|
|
4795
5047
|
*
|
|
4796
5048
|
* Attribute-selector on `<svg:g>` - see {@link CngxLine} for why.
|
|
4797
5049
|
*
|
|
4798
|
-
* @category common/chart/layers
|
|
4799
|
-
* @docsKind primary
|
|
4800
5050
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/layers/band.component.ts
|
|
4801
|
-
* @since 0.
|
|
5051
|
+
* @since 0.3.0
|
|
4802
5052
|
* @relatedTo CngxThreshold, CngxArea, CngxChart
|
|
4803
5053
|
*
|
|
4804
|
-
* <example-url
|
|
4805
|
-
* <example-url
|
|
4806
|
-
* <example-url
|
|
4807
|
-
* <example-url
|
|
4808
|
-
* <example-url
|
|
4809
|
-
* <example-url
|
|
4810
|
-
* <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>
|
|
4811
5061
|
*/
|
|
4812
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
|
+
*/
|
|
4813
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
|
+
*/
|
|
4814
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
|
+
*/
|
|
4815
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
|
+
*/
|
|
4816
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
|
+
*/
|
|
4817
5086
|
color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
4818
5087
|
ctx = injectChartContext('cngxBand');
|
|
4819
5088
|
rect = computed(() => {
|
|
@@ -5003,24 +5272,53 @@ function warnIfUnnamedPreset(selector, hint, hasName) {
|
|
|
5003
5272
|
* from the chart's auto-Summary; consumers can override via
|
|
5004
5273
|
* `[ariaLabel]`.
|
|
5005
5274
|
*
|
|
5006
|
-
* @category common/chart/presets
|
|
5007
|
-
* @docsKind primary
|
|
5008
5275
|
* @wcag AA
|
|
5009
5276
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/sparkline.component.ts
|
|
5010
|
-
* @since 0.
|
|
5277
|
+
* @since 0.3.0
|
|
5011
5278
|
* @relatedTo CngxMiniArea, CngxMiniBar, CngxChart
|
|
5012
5279
|
*
|
|
5013
|
-
* <example-url
|
|
5014
|
-
* <example-url
|
|
5015
|
-
* <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
|
|
5016
5284
|
*/
|
|
5017
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
|
+
*/
|
|
5018
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
|
+
*/
|
|
5019
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
|
+
*/
|
|
5020
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
|
+
*/
|
|
5021
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
|
+
*/
|
|
5022
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
|
+
*/
|
|
5023
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
|
+
*/
|
|
5024
5322
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5025
5323
|
preset = injectPresetState(() => this.state());
|
|
5026
5324
|
i18n = this.preset.i18n;
|
|
@@ -5119,22 +5417,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5119
5417
|
* `role="meter"`. A bound `[aria-label]` always wins and overrides the
|
|
5120
5418
|
* visible caption.
|
|
5121
5419
|
*
|
|
5122
|
-
* @category common/chart/presets
|
|
5123
|
-
* @docsKind primary
|
|
5124
5420
|
* @wcag AA
|
|
5125
5421
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/mini-bar.component.ts
|
|
5126
|
-
* @since 0.
|
|
5422
|
+
* @since 0.3.0
|
|
5127
5423
|
* @relatedTo CngxMiniArea, CngxSparkline, CngxDonut, CngxBullet
|
|
5128
5424
|
*
|
|
5129
|
-
* <example-url
|
|
5130
|
-
* <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
|
|
5131
5428
|
*/
|
|
5132
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
|
+
*/
|
|
5133
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
|
+
*/
|
|
5134
5439
|
max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
5440
|
+
/**
|
|
5441
|
+
* Lower end of the track, exposed as `aria-valuemin`. Default `0`.
|
|
5442
|
+
*/
|
|
5135
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
|
+
*/
|
|
5136
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
|
+
*/
|
|
5137
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
|
+
*/
|
|
5138
5462
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5139
5463
|
preset = injectPresetState(() => this.state());
|
|
5140
5464
|
i18n = this.preset.i18n;
|
|
@@ -5220,21 +5544,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5220
5544
|
* Use cases: budget variance ("$+45k over"), score deltas ("−12%
|
|
5221
5545
|
* vs target"), KPI swing visualisations.
|
|
5222
5546
|
*
|
|
5223
|
-
* @category common/chart/presets
|
|
5224
|
-
* @docsKind primary
|
|
5225
5547
|
* @wcag AA
|
|
5226
5548
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/deviation-bar.component.ts
|
|
5227
|
-
* @since 0.
|
|
5549
|
+
* @since 0.3.0
|
|
5228
5550
|
* @relatedTo CngxMiniBar, CngxBullet, CngxStackedBar
|
|
5229
5551
|
*
|
|
5230
|
-
* <example-url
|
|
5231
|
-
* <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
|
|
5232
5555
|
*/
|
|
5233
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
|
+
*/
|
|
5234
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
|
+
*/
|
|
5235
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
|
+
*/
|
|
5236
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
|
+
*/
|
|
5237
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
|
+
*/
|
|
5238
5585
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5239
5586
|
preset = injectPresetState(() => this.state());
|
|
5240
5587
|
i18n = this.preset.i18n;
|
|
@@ -5360,22 +5707,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5360
5707
|
* Default viewBox 80×24. Theming via `--cngx-mini-area-color`
|
|
5361
5708
|
* (atom-local) → `--cngx-chart-primary` (chart-level) cascade.
|
|
5362
5709
|
*
|
|
5363
|
-
* @category common/chart/presets
|
|
5364
|
-
* @docsKind primary
|
|
5365
5710
|
* @wcag AA
|
|
5366
5711
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/mini-area.component.ts
|
|
5367
|
-
* @since 0.
|
|
5712
|
+
* @since 0.3.0
|
|
5368
5713
|
* @relatedTo CngxSparkline, CngxMiniBar, CngxChart
|
|
5369
5714
|
*
|
|
5370
|
-
* <example-url
|
|
5371
|
-
* <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
|
|
5372
5718
|
*/
|
|
5373
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
|
+
*/
|
|
5374
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
|
+
*/
|
|
5375
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
|
+
*/
|
|
5376
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
|
+
*/
|
|
5377
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
|
+
*/
|
|
5378
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
|
+
*/
|
|
5379
5751
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5380
5752
|
preset = injectPresetState(() => this.state());
|
|
5381
5753
|
i18n = this.preset.i18n;
|
|
@@ -5466,23 +5838,54 @@ const TWO_PI = Math.PI * 2;
|
|
|
5466
5838
|
* same fallback `CngxMiniBar` uses. A bound `[aria-label]` always
|
|
5467
5839
|
* wins.
|
|
5468
5840
|
*
|
|
5469
|
-
* @category common/chart/presets
|
|
5470
|
-
* @docsKind primary
|
|
5471
5841
|
* @wcag AA
|
|
5472
5842
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/donut.component.ts
|
|
5473
|
-
* @since 0.
|
|
5843
|
+
* @since 0.3.0
|
|
5474
5844
|
* @relatedTo CngxBullet, CngxMiniBar, CngxDeviationBar
|
|
5475
5845
|
*
|
|
5476
|
-
* <example-url
|
|
5477
|
-
* <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
|
|
5478
5849
|
*/
|
|
5479
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
|
+
*/
|
|
5480
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
|
+
*/
|
|
5481
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
|
+
*/
|
|
5482
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
|
+
*/
|
|
5483
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
|
+
*/
|
|
5484
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
|
+
*/
|
|
5485
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
|
+
*/
|
|
5486
5889
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5487
5890
|
preset = injectPresetState(() => this.state());
|
|
5488
5891
|
i18n = this.preset.i18n;
|
|
@@ -5633,22 +6036,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5633
6036
|
* `[actual]` filled bar, and a `[target]` vertical marker. Pure DOM,
|
|
5634
6037
|
* no SVG. Host carries `role="meter"`.
|
|
5635
6038
|
*
|
|
5636
|
-
* @category common/chart/presets
|
|
5637
|
-
* @docsKind primary
|
|
5638
6039
|
* @wcag AA
|
|
5639
6040
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/bullet.component.ts
|
|
5640
|
-
* @since 0.
|
|
6041
|
+
* @since 0.3.0
|
|
5641
6042
|
* @relatedTo CngxDonut, CngxMiniBar, CngxDeviationBar
|
|
5642
6043
|
*
|
|
5643
|
-
* <example-url
|
|
5644
|
-
* <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
|
|
5645
6047
|
*/
|
|
5646
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
|
+
*/
|
|
5647
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
|
+
*/
|
|
5648
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
|
+
*/
|
|
5649
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
|
+
*/
|
|
5650
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
|
+
*/
|
|
5651
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
|
+
*/
|
|
5652
6084
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5653
6085
|
preset = injectPresetState(() => this.state());
|
|
5654
6086
|
i18n = this.preset.i18n;
|
|
@@ -5813,20 +6245,41 @@ function rangeRenderingsEqual(a, b) {
|
|
|
5813
6245
|
* bounded reading; the SR description enumerates segments via the
|
|
5814
6246
|
* auto-generated `aria-label` (or the `[ariaLabel]` override).
|
|
5815
6247
|
*
|
|
5816
|
-
* @category common/chart/presets
|
|
5817
|
-
* @docsKind primary
|
|
5818
6248
|
* @wcag AA
|
|
5819
6249
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/presets/stacked-bar.component.ts
|
|
5820
|
-
* @since 0.
|
|
6250
|
+
* @since 0.3.0
|
|
5821
6251
|
* @relatedTo CngxBar, CngxDeviationBar, CngxBullet
|
|
5822
6252
|
*
|
|
5823
|
-
* <example-url
|
|
5824
|
-
* <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
|
|
5825
6256
|
*/
|
|
5826
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
|
+
*/
|
|
5827
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
|
+
*/
|
|
5828
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
|
+
*/
|
|
5829
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
|
+
*/
|
|
5830
6283
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
5831
6284
|
preset = injectPresetState(() => this.state());
|
|
5832
6285
|
i18n = this.preset.i18n;
|
|
@@ -5978,7 +6431,7 @@ function segmentRenderingsEqual(a, b) {
|
|
|
5978
6431
|
}
|
|
5979
6432
|
|
|
5980
6433
|
/**
|
|
5981
|
-
* @module
|
|
6434
|
+
* @module `@cngx/common/chart`
|
|
5982
6435
|
*
|
|
5983
6436
|
* Declarative, Signal-first chart system. Two-level architecture:
|
|
5984
6437
|
* composable atoms (`<cngx-chart>` element + `[cngxAxis]` and layer
|