ngx-mira-charts 0.2.1-dev.2 → 0.3.0-dev.1
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/README.md +1 -0
- package/fesm2022/ngx-mira-charts.mjs +173 -152
- package/fesm2022/ngx-mira-charts.mjs.map +1 -1
- package/index.d.ts +270 -228
- package/package.json +1 -1
|
@@ -1,52 +1,116 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { viewChild, TemplateRef,
|
|
2
|
+
import { Directive, viewChild, TemplateRef, input, model, computed, numberAttribute, inject, forwardRef, ChangeDetectionStrategy, Component, LOCALE_ID, contentChildren, contentChild, signal, ElementRef, DestroyRef, afterNextRender, booleanAttribute, afterRenderEffect, linkedSignal } from '@angular/core';
|
|
3
3
|
import { NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* About how many ticks the y scale aims for, unless the y axis asks for
|
|
7
|
+
* another number.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_TICK_COUNT = 5;
|
|
12
|
+
// A class of its own rather than the chart's: the library's parts can't
|
|
13
|
+
// import the chart, which imports the axes to leave them room. The way
|
|
14
|
+
// Angular Material's tabs inject `MAT_TAB_GROUP`.
|
|
15
|
+
/**
|
|
16
|
+
* What a chart with an x and a y axis tells the parts in it: its data and
|
|
17
|
+
* series, its size and plot area, its scales, the labels along x, and the
|
|
18
|
+
* pointer and the datum under it. Every kind of chart provides itself under
|
|
19
|
+
* it, and the library's own parts inject it. Inject it in a part of your own:
|
|
20
|
+
* a layer that draws in the chart's svg (`MiraChartLayer`), or a component
|
|
21
|
+
* that shows something in HTML over it.
|
|
22
|
+
*
|
|
23
|
+
* Each value is a signal: a template or a `computed` that reads it follows
|
|
24
|
+
* the chart as its data, series and size change. Places are in px within the
|
|
25
|
+
* chart's svg, worked out at the size it draws at. HTML in the chart's
|
|
26
|
+
* content is laid over the svg from its top left corner, so it takes the same
|
|
27
|
+
* px, and it lets the pointer through to the svg: give what takes clicks
|
|
28
|
+
* `pointer-events: auto`.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* protected readonly y = computed(() => this.#chart.yScale()(this.value()))
|
|
33
|
+
*
|
|
34
|
+
* readonly #chart = inject(MiraCartesianContext)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
class MiraCartesianContext {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The legend as the chart sees it: the edge it sits along, and the room it
|
|
41
|
+
* takes there. The legend provides itself under it, so the chart finds it
|
|
42
|
+
* without importing it, and an app without a legend doesn't ship one.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
class ChartLegend {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Declared before the layer, whose query names it: the query is read as the
|
|
50
|
+
// layer's class is defined, in the built package as in the specs.
|
|
51
|
+
/**
|
|
52
|
+
* Marks what a layer draws (`MiraChartLayer`): the `<ng-template>` in the
|
|
53
|
+
* layer's own template that the chart renders into its svg. One per layer,
|
|
54
|
+
* whatever comes before it; in an `@if`, it's drawn while the `@if` is on.
|
|
55
|
+
* Import it in your layer's component: without it, the template goes
|
|
56
|
+
* unnoticed, and the layer draws nothing.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```html
|
|
60
|
+
* <ng-template miraLayerContent>
|
|
61
|
+
* <svg:line class="target" [attr.y1]="y()" [attr.y2]="y()" … />
|
|
62
|
+
* </ng-template>
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
class MiraLayerContent {
|
|
66
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraLayerContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
67
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.35", type: MiraLayerContent, isStandalone: true, selector: "ng-template[miraLayerContent]", ngImport: i0 });
|
|
68
|
+
}
|
|
69
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraLayerContent, decorators: [{
|
|
70
|
+
type: Directive,
|
|
71
|
+
args: [{ selector: 'ng-template[miraLayerContent]' }]
|
|
72
|
+
}] });
|
|
5
73
|
/**
|
|
6
74
|
* Something a chart draws in its svg: a line, an axis, the grid, or a layer
|
|
7
|
-
* of your own. A layer is an element of its own in the chart's content
|
|
8
|
-
* renders
|
|
9
|
-
*
|
|
10
|
-
*
|
|
75
|
+
* of your own. A layer is an element of its own in the chart's content: the
|
|
76
|
+
* chart renders the layer's `<ng-template miraLayerContent>` into its svg, in
|
|
77
|
+
* the order the layers are written, so the first one ends up at the bottom.
|
|
78
|
+
* The rest of the layer's template, if it has any, shows where the layer is
|
|
79
|
+
* written, in HTML over the svg.
|
|
11
80
|
*
|
|
12
|
-
* To draw a layer of your own, extend this class
|
|
13
|
-
* under it,
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
81
|
+
* To draw a layer of your own, extend this class in a component that
|
|
82
|
+
* provides itself under it,
|
|
83
|
+
* `{ provide: MiraChartLayer, useExisting: forwardRef(() => Target) }`, and
|
|
84
|
+
* put what it draws in an `<ng-template miraLayerContent>` in its template,
|
|
85
|
+
* as `svg:` elements, importing `MiraLayerContent`. Inject
|
|
86
|
+
* `MiraCartesianContext` for the plot area and the scales. The template runs
|
|
87
|
+
* again when a signal it reads changes, or when your component is checked, as
|
|
88
|
+
* on a new input: keep what it reads in signals, or call `markForCheck()`
|
|
89
|
+
* when that changes.
|
|
18
90
|
*
|
|
19
91
|
* @example
|
|
20
92
|
* ```ts
|
|
21
|
-
* @Component({
|
|
22
|
-
* selector: 'app-target',
|
|
23
|
-
* providers: [
|
|
24
|
-
* { provide: MiraChartLayer, useExisting: forwardRef(() => Target) },
|
|
25
|
-
* ],
|
|
26
|
-
* template: `
|
|
27
|
-
* <ng-template>
|
|
28
|
-
* <svg:line [attr.y1]="y()" [attr.y2]="y()" … />
|
|
29
|
-
* </ng-template>
|
|
30
|
-
* `,
|
|
31
|
-
* })
|
|
32
93
|
* export class Target extends MiraChartLayer {
|
|
33
94
|
* readonly value = input.required<number>()
|
|
34
95
|
*
|
|
35
96
|
* protected readonly y = computed(() => this.#chart.yScale()(this.value()))
|
|
36
97
|
*
|
|
37
|
-
* readonly #chart = inject(
|
|
98
|
+
* readonly #chart = inject(MiraCartesianContext)
|
|
38
99
|
* }
|
|
39
100
|
* ```
|
|
40
101
|
*/
|
|
41
102
|
class MiraChartLayer {
|
|
42
|
-
/**
|
|
43
|
-
|
|
103
|
+
/**
|
|
104
|
+
* What the layer draws: its `<ng-template miraLayerContent>`, while it's
|
|
105
|
+
* there.
|
|
106
|
+
*/
|
|
107
|
+
template = viewChild(MiraLayerContent, ...(ngDevMode ? [{ debugName: "template", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
44
108
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraChartLayer, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
45
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.3.35", type: MiraChartLayer, isStandalone: true, viewQueries: [{ propertyName: "template", first: true, predicate:
|
|
109
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.3.35", type: MiraChartLayer, isStandalone: true, viewQueries: [{ propertyName: "template", first: true, predicate: MiraLayerContent, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0 });
|
|
46
110
|
}
|
|
47
111
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraChartLayer, decorators: [{
|
|
48
112
|
type: Directive
|
|
49
|
-
}], propDecorators: { template: [{ type: i0.ViewChild, args: [i0.forwardRef(() =>
|
|
113
|
+
}], propDecorators: { template: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MiraLayerContent), { ...{ read: TemplateRef }, isSignal: true }] }] } });
|
|
50
114
|
|
|
51
115
|
/**
|
|
52
116
|
* A layer that plots the values under a key of the chart's data: a line or
|
|
@@ -54,8 +118,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImpo
|
|
|
54
118
|
* series that aren't hidden, whatever kind they are.
|
|
55
119
|
*
|
|
56
120
|
* A series extends this class, and provides itself under it as well as under
|
|
57
|
-
*
|
|
58
|
-
* in.
|
|
121
|
+
* `MiraChartLayer`. It also implements `color`, the color it's drawn in.
|
|
59
122
|
*/
|
|
60
123
|
class MiraSeries extends MiraChartLayer {
|
|
61
124
|
/** The key of the values to plot. */
|
|
@@ -126,7 +189,8 @@ function valueAt(datum, key) {
|
|
|
126
189
|
}
|
|
127
190
|
/**
|
|
128
191
|
* The value under `key` as a number to plot, or null when there's nothing to
|
|
129
|
-
* plot there: no value, null, NaN, or something other than a
|
|
192
|
+
* plot there: no value, null, NaN, an infinity, or something other than a
|
|
193
|
+
* number.
|
|
130
194
|
*
|
|
131
195
|
* @internal
|
|
132
196
|
*/
|
|
@@ -290,36 +354,6 @@ function ticksBetween([min, max], increment) {
|
|
|
290
354
|
return ticks;
|
|
291
355
|
}
|
|
292
356
|
|
|
293
|
-
/**
|
|
294
|
-
* About how many ticks the y scale aims for, unless the y axis asks for
|
|
295
|
-
* another number.
|
|
296
|
-
*
|
|
297
|
-
* @internal
|
|
298
|
-
*/
|
|
299
|
-
const DEFAULT_TICK_COUNT = 5;
|
|
300
|
-
/**
|
|
301
|
-
* What the parts of a chart with an x and a y axis, its layers, its tooltip
|
|
302
|
-
* and its legend, draw by: the data, the series, the size, the plot area, the
|
|
303
|
-
* scales, the labels along x, and the pointer and the datum under it. Every
|
|
304
|
-
* kind of chart provides itself under it, with `provideCartesianChart`, and
|
|
305
|
-
* the library's own parts inject it: they can't import the chart, which
|
|
306
|
-
* imports the axes to leave room for them. The way Angular Material's tabs
|
|
307
|
-
* inject `MAT_TAB_GROUP`.
|
|
308
|
-
*
|
|
309
|
-
* @internal
|
|
310
|
-
*/
|
|
311
|
-
class CartesianContext {
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* The legend as the chart sees it: the edge it sits along, and the room it
|
|
315
|
-
* takes there. The legend provides itself under it, so the chart finds it
|
|
316
|
-
* without importing it, and an app without a legend doesn't ship one.
|
|
317
|
-
*
|
|
318
|
-
* @internal
|
|
319
|
-
*/
|
|
320
|
-
class ChartLegend {
|
|
321
|
-
}
|
|
322
|
-
|
|
323
357
|
/**
|
|
324
358
|
* The category axis under the plot: a tick per datum, labelled with the
|
|
325
359
|
* datum's value under `dataKey`. Its line runs at zero, where values rise and
|
|
@@ -336,7 +370,7 @@ class MiraXAxis extends MiraChartLayer {
|
|
|
336
370
|
dataKey = input(...(ngDevMode ? [undefined, { debugName: "dataKey" }] : []));
|
|
337
371
|
/** The room the axis takes under the plot, in px: 30 by default. */
|
|
338
372
|
height = input(30, ...(ngDevMode ? [{ debugName: "height", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
339
|
-
chart = inject(
|
|
373
|
+
chart = inject(MiraCartesianContext);
|
|
340
374
|
// Where the ticks and labels hang from: the bottom of the plot.
|
|
341
375
|
bottom = computed(() => this.chart.plot().top + this.chart.plot().height, ...(ngDevMode ? [{ debugName: "bottom" }] : []));
|
|
342
376
|
// Where the axis line runs: at zero, kept on the plot.
|
|
@@ -356,7 +390,7 @@ class MiraXAxis extends MiraChartLayer {
|
|
|
356
390
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraXAxis, isStandalone: true, selector: "mira-x-axis", inputs: { dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
357
391
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraXAxis) },
|
|
358
392
|
], usesInheritance: true, ngImport: i0, template: `
|
|
359
|
-
<ng-template>
|
|
393
|
+
<ng-template miraLayerContent>
|
|
360
394
|
<svg:g class="mira-x-axis">
|
|
361
395
|
<svg:line
|
|
362
396
|
[attr.x1]="chart.plot().left"
|
|
@@ -376,14 +410,14 @@ class MiraXAxis extends MiraChartLayer {
|
|
|
376
410
|
}
|
|
377
411
|
</svg:g>
|
|
378
412
|
</ng-template>
|
|
379
|
-
`, isInline: true, styles: [".mira-x-axis{font-size:12px}line{stroke:var(--_mira-axis-color)}text{fill:var(--_mira-axis-color)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
413
|
+
`, isInline: true, styles: [".mira-x-axis{font-size:12px}line{stroke:var(--_mira-axis-color)}text{fill:var(--_mira-axis-color)}\n"], dependencies: [{ kind: "directive", type: MiraLayerContent, selector: "ng-template[miraLayerContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
380
414
|
}
|
|
381
415
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraXAxis, decorators: [{
|
|
382
416
|
type: Component,
|
|
383
|
-
args: [{ selector: 'mira-x-axis', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
417
|
+
args: [{ selector: 'mira-x-axis', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MiraLayerContent], providers: [
|
|
384
418
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraXAxis) },
|
|
385
419
|
], template: `
|
|
386
|
-
<ng-template>
|
|
420
|
+
<ng-template miraLayerContent>
|
|
387
421
|
<svg:g class="mira-x-axis">
|
|
388
422
|
<svg:line
|
|
389
423
|
[attr.x1]="chart.plot().left"
|
|
@@ -426,7 +460,7 @@ class MiraYAxis extends MiraChartLayer {
|
|
|
426
460
|
tickCount = input(DEFAULT_TICK_COUNT, ...(ngDevMode ? [{ debugName: "tickCount", transform: numberAttribute }] : [{
|
|
427
461
|
transform: numberAttribute,
|
|
428
462
|
}]));
|
|
429
|
-
chart = inject(
|
|
463
|
+
chart = inject(MiraCartesianContext);
|
|
430
464
|
x = computed(() => this.chart.plot().left, ...(ngDevMode ? [{ debugName: "x" }] : []));
|
|
431
465
|
ticks = computed(() => {
|
|
432
466
|
const ticks = this.chart.yTicks();
|
|
@@ -447,7 +481,7 @@ class MiraYAxis extends MiraChartLayer {
|
|
|
447
481
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraYAxis, isStandalone: true, selector: "mira-y-axis", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, tickCount: { classPropertyName: "tickCount", publicName: "tickCount", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
448
482
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraYAxis) },
|
|
449
483
|
], usesInheritance: true, ngImport: i0, template: `
|
|
450
|
-
<ng-template>
|
|
484
|
+
<ng-template miraLayerContent>
|
|
451
485
|
<svg:g class="mira-y-axis">
|
|
452
486
|
<svg:line
|
|
453
487
|
[attr.x1]="x()"
|
|
@@ -467,14 +501,14 @@ class MiraYAxis extends MiraChartLayer {
|
|
|
467
501
|
}
|
|
468
502
|
</svg:g>
|
|
469
503
|
</ng-template>
|
|
470
|
-
`, isInline: true, styles: [".mira-y-axis{font-size:12px}line{stroke:var(--_mira-axis-color)}text{fill:var(--_mira-axis-color)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
504
|
+
`, isInline: true, styles: [".mira-y-axis{font-size:12px}line{stroke:var(--_mira-axis-color)}text{fill:var(--_mira-axis-color)}\n"], dependencies: [{ kind: "directive", type: MiraLayerContent, selector: "ng-template[miraLayerContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
471
505
|
}
|
|
472
506
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraYAxis, decorators: [{
|
|
473
507
|
type: Component,
|
|
474
|
-
args: [{ selector: 'mira-y-axis', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
508
|
+
args: [{ selector: 'mira-y-axis', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MiraLayerContent], providers: [
|
|
475
509
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraYAxis) },
|
|
476
510
|
], template: `
|
|
477
|
-
<ng-template>
|
|
511
|
+
<ng-template miraLayerContent>
|
|
478
512
|
<svg:g class="mira-y-axis">
|
|
479
513
|
<svg:line
|
|
480
514
|
[attr.x1]="x()"
|
|
@@ -572,10 +606,11 @@ const FALLBACK_SIZE = { width: 600, height: 300 };
|
|
|
572
606
|
* under it. Nothing about a kind of chart: a line chart extends it with a
|
|
573
607
|
* point per datum along x, and a bar chart with a band per datum.
|
|
574
608
|
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
609
|
+
* Parts of your own, a layer (`MiraChartLayer`) that draws in the svg or a
|
|
610
|
+
* component that shows something in HTML over it, inject
|
|
611
|
+
* `MiraCartesianContext`. A chart isn't provided as `MiraCartesianChart`:
|
|
612
|
+
* neither `inject()` nor a query such as `viewChild()` finds one by it, so
|
|
613
|
+
* query a chart by its own class, `MiraLineChart` or `MiraBarChart`.
|
|
579
614
|
*
|
|
580
615
|
* Its colors are CSS custom properties, to set anywhere above the chart:
|
|
581
616
|
*
|
|
@@ -618,7 +653,8 @@ class MiraCartesianChart {
|
|
|
618
653
|
margin = input({}, ...(ngDevMode ? [{ debugName: "margin" }] : []));
|
|
619
654
|
/** What the chart shows, for screen readers. */
|
|
620
655
|
ariaLabel = input(...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : []));
|
|
621
|
-
|
|
656
|
+
// The members that implement `MiraCartesianContext` carry no docs of their
|
|
657
|
+
// own: theirs are on the context, and an IDE shows them here too.
|
|
622
658
|
size = computed(() => {
|
|
623
659
|
const measured = this.#measured();
|
|
624
660
|
// A size of 0 means the chart is hidden, or its container gives it none:
|
|
@@ -630,10 +666,6 @@ class MiraCartesianChart {
|
|
|
630
666
|
height: this.height() ?? (measured?.height || FALLBACK_SIZE.height),
|
|
631
667
|
};
|
|
632
668
|
}, ...(ngDevMode ? [{ debugName: "size", equal: sameSize }] : [{ equal: sameSize }]));
|
|
633
|
-
/**
|
|
634
|
-
* Where the series are drawn: the chart less its margin, its axes and its
|
|
635
|
-
* legend.
|
|
636
|
-
*/
|
|
637
669
|
plot = computed(() => {
|
|
638
670
|
const { width, height } = this.size();
|
|
639
671
|
const margin = { ...DEFAULT_MARGIN, ...this.margin() };
|
|
@@ -650,37 +682,21 @@ class MiraCartesianChart {
|
|
|
650
682
|
height: Math.max(0, height - margin.top - bottom),
|
|
651
683
|
};
|
|
652
684
|
}, ...(ngDevMode ? [{ debugName: "plot" }] : []));
|
|
653
|
-
/** Maps a value to its y. */
|
|
654
685
|
yScale = computed(() => {
|
|
655
686
|
const { top, height } = this.plot();
|
|
656
687
|
return linearScale(this.#yNice().domain, [top + height, top]);
|
|
657
688
|
}, ...(ngDevMode ? [{ debugName: "yScale" }] : []));
|
|
658
|
-
/** Round values over the y scale, for the y axis and the grid to mark. */
|
|
659
689
|
yTicks = computed(() => {
|
|
660
690
|
const scale = this.yScale();
|
|
661
691
|
return this.#yNice().ticks.map((value) => ({ value, offset: scale(value) }));
|
|
662
692
|
}, ...(ngDevMode ? [{ debugName: "yTicks" }] : []));
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
* under the x axis's `dataKey`, or its index without one. The x axis marks
|
|
666
|
-
* its ticks with them, and the tooltip titles its box with one.
|
|
667
|
-
*/
|
|
693
|
+
// The x axis marks its ticks with them, and the tooltip titles its box with
|
|
694
|
+
// one.
|
|
668
695
|
xLabels = computed(() => {
|
|
669
696
|
const key = this.xAxis()?.dataKey();
|
|
670
697
|
return this.data().map((datum, index) => key === undefined ? String(index) : String(valueAt(datum, key) ?? ''));
|
|
671
698
|
}, ...(ngDevMode ? [{ debugName: "xLabels" }] : []));
|
|
672
|
-
/**
|
|
673
|
-
* Where the pointer last moved over the svg, in the svg's px, or null once
|
|
674
|
-
* it's left. It's placed again when the chart resizes under a pointer that
|
|
675
|
-
* stays put, but not when the chart moves under it, as when the page
|
|
676
|
-
* scrolls: then it waits for the pointer to move.
|
|
677
|
-
*/
|
|
678
699
|
pointer = computed(() => this.#pointer(), ...(ngDevMode ? [{ debugName: "pointer" }] : []));
|
|
679
|
-
/**
|
|
680
|
-
* The index of the datum nearest the pointer along x, or null while the
|
|
681
|
-
* pointer is off the plot. It follows the data and the size as they change
|
|
682
|
-
* under a pointer that stays put.
|
|
683
|
-
*/
|
|
684
700
|
activeIndex = computed(() => {
|
|
685
701
|
const pointer = this.#pointer();
|
|
686
702
|
if (!pointer)
|
|
@@ -694,10 +710,6 @@ class MiraCartesianChart {
|
|
|
694
710
|
return null;
|
|
695
711
|
return nearestIndex(this.xPositions(), pointer.x);
|
|
696
712
|
}, ...(ngDevMode ? [{ debugName: "activeIndex" }] : []));
|
|
697
|
-
/**
|
|
698
|
-
* The datum under the pointer: its index, the row itself, its x and its
|
|
699
|
-
* label; or null while the pointer is off the plot.
|
|
700
|
-
*/
|
|
701
713
|
active = computed(() => {
|
|
702
714
|
const index = this.activeIndex();
|
|
703
715
|
return index === null
|
|
@@ -709,12 +721,9 @@ class MiraCartesianChart {
|
|
|
709
721
|
label: this.xLabels()[index],
|
|
710
722
|
};
|
|
711
723
|
}, ...(ngDevMode ? [{ debugName: "active" }] : []));
|
|
712
|
-
/** The series, of whatever kind, in the order they're written, hidden too. */
|
|
713
724
|
series = contentChildren(MiraSeries, ...(ngDevMode ? [{ debugName: "series" }] : []));
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
* fits their values, and the tooltip shows them.
|
|
717
|
-
*/
|
|
725
|
+
// The y axis fits their values, the bars share their bands, and the tooltip
|
|
726
|
+
// shows them.
|
|
718
727
|
visibleSeries = computed(() => this.series().filter((series) => !series.hidden()), ...(ngDevMode ? [{ debugName: "visibleSeries" }] : []));
|
|
719
728
|
/** The chart's layers, in the order they're written. */
|
|
720
729
|
layers = contentChildren(MiraChartLayer, ...(ngDevMode ? [{ debugName: "layers" }] : []));
|
|
@@ -845,7 +854,7 @@ class MiraCartesianGrid extends MiraChartLayer {
|
|
|
845
854
|
vertical = input(true, ...(ngDevMode ? [{ debugName: "vertical", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
846
855
|
/** Dashes the lines, as the svg attribute does: `"3 3"`. */
|
|
847
856
|
strokeDasharray = input(...(ngDevMode ? [undefined, { debugName: "strokeDasharray" }] : []));
|
|
848
|
-
chart = inject(
|
|
857
|
+
chart = inject(MiraCartesianContext);
|
|
849
858
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraCartesianGrid, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
850
859
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraCartesianGrid, isStandalone: true, selector: "mira-cartesian-grid", inputs: { horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, vertical: { classPropertyName: "vertical", publicName: "vertical", isSignal: true, isRequired: false, transformFunction: null }, strokeDasharray: { classPropertyName: "strokeDasharray", publicName: "strokeDasharray", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
851
860
|
{
|
|
@@ -853,7 +862,7 @@ class MiraCartesianGrid extends MiraChartLayer {
|
|
|
853
862
|
useExisting: forwardRef(() => MiraCartesianGrid),
|
|
854
863
|
},
|
|
855
864
|
], usesInheritance: true, ngImport: i0, template: `
|
|
856
|
-
<ng-template>
|
|
865
|
+
<ng-template miraLayerContent>
|
|
857
866
|
<svg:g
|
|
858
867
|
class="mira-cartesian-grid"
|
|
859
868
|
[attr.stroke-dasharray]="strokeDasharray() ?? null"
|
|
@@ -880,17 +889,17 @@ class MiraCartesianGrid extends MiraChartLayer {
|
|
|
880
889
|
}
|
|
881
890
|
</svg:g>
|
|
882
891
|
</ng-template>
|
|
883
|
-
`, isInline: true, styles: ["line{stroke:var(--_mira-grid-color)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
892
|
+
`, isInline: true, styles: ["line{stroke:var(--_mira-grid-color)}\n"], dependencies: [{ kind: "directive", type: MiraLayerContent, selector: "ng-template[miraLayerContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
884
893
|
}
|
|
885
894
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraCartesianGrid, decorators: [{
|
|
886
895
|
type: Component,
|
|
887
|
-
args: [{ selector: 'mira-cartesian-grid', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
896
|
+
args: [{ selector: 'mira-cartesian-grid', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MiraLayerContent], providers: [
|
|
888
897
|
{
|
|
889
898
|
provide: MiraChartLayer,
|
|
890
899
|
useExisting: forwardRef(() => MiraCartesianGrid),
|
|
891
900
|
},
|
|
892
901
|
], template: `
|
|
893
|
-
<ng-template>
|
|
902
|
+
<ng-template miraLayerContent>
|
|
894
903
|
<svg:g
|
|
895
904
|
class="mira-cartesian-grid"
|
|
896
905
|
[attr.stroke-dasharray]="strokeDasharray() ?? null"
|
|
@@ -948,12 +957,12 @@ class MiraCursor extends MiraChartLayer {
|
|
|
948
957
|
? { kind: 'line', x, top, bottom: top + height }
|
|
949
958
|
: { kind: 'band', x: x - bandwidth / 2, y: top, width: bandwidth, height };
|
|
950
959
|
}, ...(ngDevMode ? [{ debugName: "shape" }] : []));
|
|
951
|
-
#chart = inject(
|
|
960
|
+
#chart = inject(MiraCartesianContext);
|
|
952
961
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraCursor, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
953
962
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraCursor, isStandalone: true, selector: "mira-cursor", providers: [
|
|
954
963
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraCursor) },
|
|
955
964
|
], usesInheritance: true, ngImport: i0, template: `
|
|
956
|
-
<ng-template>
|
|
965
|
+
<ng-template miraLayerContent>
|
|
957
966
|
@if (shape(); as shape) {
|
|
958
967
|
@if (shape.kind === 'band') {
|
|
959
968
|
<svg:rect
|
|
@@ -974,14 +983,14 @@ class MiraCursor extends MiraChartLayer {
|
|
|
974
983
|
}
|
|
975
984
|
}
|
|
976
985
|
</ng-template>
|
|
977
|
-
`, isInline: true, styles: [".mira-cursor,.mira-cursor-band{pointer-events:none}.mira-cursor{stroke:var(--_mira-cursor-color)}.mira-cursor-band{fill:var(--_mira-cursor-color);fill-opacity:.25}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
986
|
+
`, isInline: true, styles: [".mira-cursor,.mira-cursor-band{pointer-events:none}.mira-cursor{stroke:var(--_mira-cursor-color)}.mira-cursor-band{fill:var(--_mira-cursor-color);fill-opacity:.25}\n"], dependencies: [{ kind: "directive", type: MiraLayerContent, selector: "ng-template[miraLayerContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
978
987
|
}
|
|
979
988
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraCursor, decorators: [{
|
|
980
989
|
type: Component,
|
|
981
|
-
args: [{ selector: 'mira-cursor', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
990
|
+
args: [{ selector: 'mira-cursor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MiraLayerContent], providers: [
|
|
982
991
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraCursor) },
|
|
983
992
|
], template: `
|
|
984
|
-
<ng-template>
|
|
993
|
+
<ng-template miraLayerContent>
|
|
985
994
|
@if (shape(); as shape) {
|
|
986
995
|
@if (shape.kind === 'band') {
|
|
987
996
|
<svg:rect
|
|
@@ -1136,7 +1145,7 @@ class MiraTooltip {
|
|
|
1136
1145
|
}, ...(ngDevMode ? [{ debugName: "position" }] : []));
|
|
1137
1146
|
// The box, while it shows, to measure.
|
|
1138
1147
|
frame = viewChild('frame', ...(ngDevMode ? [{ debugName: "frame" }] : []));
|
|
1139
|
-
#chart = inject(
|
|
1148
|
+
#chart = inject(MiraCartesianContext);
|
|
1140
1149
|
// The box's size, as the browser last laid it out.
|
|
1141
1150
|
#size = signal({ width: 0, height: 0 }, ...(ngDevMode ? [{ debugName: "#size", equal: (a, b) => a.width === b.width && a.height === b.height }] : [{ equal: (a, b) => a.width === b.width && a.height === b.height }]));
|
|
1142
1151
|
#locale = inject(LOCALE_ID);
|
|
@@ -1396,8 +1405,9 @@ class MiraLegend {
|
|
|
1396
1405
|
* The chart whose series the legend lists, for a legend out of it: give
|
|
1397
1406
|
* the chart a reference, `<mira-line-chart #chart>`, and name it,
|
|
1398
1407
|
* `<mira-legend [for]="chart" />`. Unset, the chart the legend is in. With
|
|
1399
|
-
* no chart, as while a chart named through a query
|
|
1400
|
-
* off, the legend lists
|
|
1408
|
+
* no chart, as while a chart named through a query by its class,
|
|
1409
|
+
* `viewChild(MiraLineChart)`, is in an `@if` that's off, the legend lists
|
|
1410
|
+
* nothing.
|
|
1401
1411
|
*/
|
|
1402
1412
|
for = input(...(ngDevMode ? [undefined, { debugName: "for" }] : []));
|
|
1403
1413
|
/**
|
|
@@ -1437,7 +1447,7 @@ class MiraLegend {
|
|
|
1437
1447
|
}]));
|
|
1438
1448
|
#host = inject(ElementRef).nativeElement;
|
|
1439
1449
|
// The chart the legend is in, if it's in one.
|
|
1440
|
-
#parent = inject(
|
|
1450
|
+
#parent = inject(MiraCartesianContext, { optional: true });
|
|
1441
1451
|
// The room the legend took, as the browser last laid it out: none yet on a
|
|
1442
1452
|
// side it has just moved to, which the old room says nothing about.
|
|
1443
1453
|
#measured = linkedSignal(...(ngDevMode ? [{ debugName: "#measured", source: this.position,
|
|
@@ -1596,21 +1606,6 @@ function inRows(side) {
|
|
|
1596
1606
|
return side === 'top' || side === 'bottom';
|
|
1597
1607
|
}
|
|
1598
1608
|
|
|
1599
|
-
/**
|
|
1600
|
-
* The providers of a kind of cartesian chart: under `MiraCartesianChart`, for
|
|
1601
|
-
* layers of your own, and under the context the library's layers inject.
|
|
1602
|
-
* Every kind of chart lists them, given `forwardRef(() => TheChart)`:
|
|
1603
|
-
* providers aren't inherited.
|
|
1604
|
-
*
|
|
1605
|
-
* @internal
|
|
1606
|
-
*/
|
|
1607
|
-
function provideCartesianChart(chart) {
|
|
1608
|
-
return [
|
|
1609
|
-
{ provide: MiraCartesianChart, useExisting: chart },
|
|
1610
|
-
{ provide: CartesianContext, useExisting: chart },
|
|
1611
|
-
];
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
1609
|
/**
|
|
1615
1610
|
* Draws a layer's template in a view of its own. Angular tracks the signals a
|
|
1616
1611
|
* template reads in the component view it's drawn into: drawn straight into
|
|
@@ -1646,7 +1641,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImpo
|
|
|
1646
1641
|
/**
|
|
1647
1642
|
* A chart of lines over categories, a point per datum. What's in it comes as
|
|
1648
1643
|
* content, drawn in the order it's written, so the first one ends up at the
|
|
1649
|
-
* bottom.
|
|
1644
|
+
* bottom. What it tells the parts in it, `plot`, `yScale` and the rest, is
|
|
1645
|
+
* described on `MiraCartesianContext`, which parts of your own inject.
|
|
1650
1646
|
*
|
|
1651
1647
|
* @example
|
|
1652
1648
|
* ```html
|
|
@@ -1660,17 +1656,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImpo
|
|
|
1660
1656
|
* ```
|
|
1661
1657
|
*/
|
|
1662
1658
|
class MiraLineChart extends MiraCartesianChart {
|
|
1663
|
-
/**
|
|
1659
|
+
/**
|
|
1660
|
+
* A point per datum, from edge to edge of the plot, or in its middle for a
|
|
1661
|
+
* single datum.
|
|
1662
|
+
*/
|
|
1664
1663
|
xPositions = computed(() => {
|
|
1665
1664
|
const { left, width } = this.plot();
|
|
1666
1665
|
return pointPositions(this.data().length, [left, left + width]);
|
|
1667
1666
|
}, ...(ngDevMode ? [{ debugName: "xPositions" }] : []));
|
|
1668
1667
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraLineChart, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1669
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraLineChart, isStandalone: true, selector: "mira-line-chart", providers: [
|
|
1668
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraLineChart, isStandalone: true, selector: "mira-line-chart", providers: [
|
|
1669
|
+
{
|
|
1670
|
+
provide: MiraCartesianContext,
|
|
1671
|
+
useExisting: forwardRef(() => MiraLineChart),
|
|
1672
|
+
},
|
|
1673
|
+
], usesInheritance: true, ngImport: i0, template: "\n <div class=\"mira-chart\">\n <svg\n #svg\n role=\"img\"\n [attr.width]=\"size().width\"\n [attr.height]=\"size().height\"\n [attr.viewBox]=\"viewBox()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n >\n @for (layer of drawnLayers(); track layer) {\n <svg:g [miraLayerOutlet]=\"layer.template()\" />\n }\n </svg>\n <div class=\"mira-chart-overlay\">\n <ng-content />\n </div>\n </div>\n", isInline: true, styles: [":host{--_mira-axis-color: var(--mira-axis-color, #666);--_mira-grid-color: var(--mira-grid-color, #ccc);--_mira-background: var(--mira-background, #fff);--_mira-cursor-color: var(--mira-cursor-color, #999)}@supports (color: light-dark(#000,#fff)){:host{--_mira-axis-color: var(--mira-axis-color, light-dark(#666, #999));--_mira-grid-color: var(--mira-grid-color, light-dark(#ccc, #333));--_mira-background: var(--mira-background, Canvas);--_mira-cursor-color: var(--mira-cursor-color, light-dark(#999, #666))}}\n", ".mira-chart{display:grid;width:fit-content}.mira-chart>*{grid-area:1 / 1}svg{display:block}.mira-chart-overlay{position:relative;pointer-events:none;isolation:isolate}\n"], dependencies: [{ kind: "component", type: LayerOutlet, selector: "g[miraLayerOutlet]", inputs: ["miraLayerOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1670
1674
|
}
|
|
1671
1675
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraLineChart, decorators: [{
|
|
1672
1676
|
type: Component,
|
|
1673
|
-
args: [{ selector: 'mira-line-chart', changeDetection: ChangeDetectionStrategy.OnPush, imports: [LayerOutlet], providers: [
|
|
1677
|
+
args: [{ selector: 'mira-line-chart', changeDetection: ChangeDetectionStrategy.OnPush, imports: [LayerOutlet], providers: [
|
|
1678
|
+
{
|
|
1679
|
+
provide: MiraCartesianContext,
|
|
1680
|
+
useExisting: forwardRef(() => MiraLineChart),
|
|
1681
|
+
},
|
|
1682
|
+
], template: CARTESIAN_CHART_TEMPLATE, styles: [":host{--_mira-axis-color: var(--mira-axis-color, #666);--_mira-grid-color: var(--mira-grid-color, #ccc);--_mira-background: var(--mira-background, #fff);--_mira-cursor-color: var(--mira-cursor-color, #999)}@supports (color: light-dark(#000,#fff)){:host{--_mira-axis-color: var(--mira-axis-color, light-dark(#666, #999));--_mira-grid-color: var(--mira-grid-color, light-dark(#ccc, #333));--_mira-background: var(--mira-background, Canvas);--_mira-cursor-color: var(--mira-cursor-color, light-dark(#999, #666))}}\n", ".mira-chart{display:grid;width:fit-content}.mira-chart>*{grid-area:1 / 1}svg{display:block}.mira-chart-overlay{position:relative;pointer-events:none;isolation:isolate}\n"] }]
|
|
1674
1683
|
}] });
|
|
1675
1684
|
|
|
1676
1685
|
/**
|
|
@@ -1791,7 +1800,7 @@ class MiraLine extends MiraSeries {
|
|
|
1791
1800
|
return null;
|
|
1792
1801
|
return this.#points()[index] ?? null;
|
|
1793
1802
|
}, ...(ngDevMode ? [{ debugName: "activePoint" }] : []));
|
|
1794
|
-
#chart = inject(
|
|
1803
|
+
#chart = inject(MiraCartesianContext);
|
|
1795
1804
|
// A point per datum, or null where the datum has no value to plot.
|
|
1796
1805
|
#points = computed(() => {
|
|
1797
1806
|
const key = this.dataKey();
|
|
@@ -1807,7 +1816,7 @@ class MiraLine extends MiraSeries {
|
|
|
1807
1816
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraLine) },
|
|
1808
1817
|
{ provide: MiraSeries, useExisting: forwardRef(() => MiraLine) },
|
|
1809
1818
|
], usesInheritance: true, ngImport: i0, template: `
|
|
1810
|
-
<ng-template>
|
|
1819
|
+
<ng-template miraLayerContent>
|
|
1811
1820
|
<svg:g class="mira-line">
|
|
1812
1821
|
<svg:path
|
|
1813
1822
|
class="mira-line-curve"
|
|
@@ -1843,15 +1852,15 @@ class MiraLine extends MiraSeries {
|
|
|
1843
1852
|
}
|
|
1844
1853
|
</svg:g>
|
|
1845
1854
|
</ng-template>
|
|
1846
|
-
`, isInline: true, styles: [".mira-line-curve{fill:none;stroke-width:2}.mira-line-halo{fill-opacity:.25}.mira-line-active-dot{stroke:var(--_mira-background);stroke-width:2}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1855
|
+
`, isInline: true, styles: [".mira-line-curve{fill:none;stroke-width:2}.mira-line-halo{fill-opacity:.25}.mira-line-active-dot{stroke:var(--_mira-background);stroke-width:2}\n"], dependencies: [{ kind: "directive", type: MiraLayerContent, selector: "ng-template[miraLayerContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1847
1856
|
}
|
|
1848
1857
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraLine, decorators: [{
|
|
1849
1858
|
type: Component,
|
|
1850
|
-
args: [{ selector: 'mira-line', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
1859
|
+
args: [{ selector: 'mira-line', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MiraLayerContent], providers: [
|
|
1851
1860
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraLine) },
|
|
1852
1861
|
{ provide: MiraSeries, useExisting: forwardRef(() => MiraLine) },
|
|
1853
1862
|
], template: `
|
|
1854
|
-
<ng-template>
|
|
1863
|
+
<ng-template miraLayerContent>
|
|
1855
1864
|
<svg:g class="mira-line">
|
|
1856
1865
|
<svg:path
|
|
1857
1866
|
class="mira-line-curve"
|
|
@@ -1893,7 +1902,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImpo
|
|
|
1893
1902
|
/**
|
|
1894
1903
|
* A chart of bars over categories, a band per datum. What's in it comes as
|
|
1895
1904
|
* content, drawn in the order it's written, so the first one ends up at the
|
|
1896
|
-
* bottom.
|
|
1905
|
+
* bottom. What it tells the parts in it, `plot`, `yScale` and the rest, is
|
|
1906
|
+
* described on `MiraCartesianContext`, which parts of your own inject.
|
|
1897
1907
|
*
|
|
1898
1908
|
* @example
|
|
1899
1909
|
* ```html
|
|
@@ -1918,11 +1928,21 @@ class MiraBarChart extends MiraCartesianChart {
|
|
|
1918
1928
|
return bandPositions(this.data().length, [left, left + width]);
|
|
1919
1929
|
}, ...(ngDevMode ? [{ debugName: "#bands" }] : []));
|
|
1920
1930
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraBarChart, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1921
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraBarChart, isStandalone: true, selector: "mira-bar-chart", providers: [
|
|
1931
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: MiraBarChart, isStandalone: true, selector: "mira-bar-chart", providers: [
|
|
1932
|
+
{
|
|
1933
|
+
provide: MiraCartesianContext,
|
|
1934
|
+
useExisting: forwardRef(() => MiraBarChart),
|
|
1935
|
+
},
|
|
1936
|
+
], usesInheritance: true, ngImport: i0, template: "\n <div class=\"mira-chart\">\n <svg\n #svg\n role=\"img\"\n [attr.width]=\"size().width\"\n [attr.height]=\"size().height\"\n [attr.viewBox]=\"viewBox()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n >\n @for (layer of drawnLayers(); track layer) {\n <svg:g [miraLayerOutlet]=\"layer.template()\" />\n }\n </svg>\n <div class=\"mira-chart-overlay\">\n <ng-content />\n </div>\n </div>\n", isInline: true, styles: [":host{--_mira-axis-color: var(--mira-axis-color, #666);--_mira-grid-color: var(--mira-grid-color, #ccc);--_mira-background: var(--mira-background, #fff);--_mira-cursor-color: var(--mira-cursor-color, #999)}@supports (color: light-dark(#000,#fff)){:host{--_mira-axis-color: var(--mira-axis-color, light-dark(#666, #999));--_mira-grid-color: var(--mira-grid-color, light-dark(#ccc, #333));--_mira-background: var(--mira-background, Canvas);--_mira-cursor-color: var(--mira-cursor-color, light-dark(#999, #666))}}\n", ".mira-chart{display:grid;width:fit-content}.mira-chart>*{grid-area:1 / 1}svg{display:block}.mira-chart-overlay{position:relative;pointer-events:none;isolation:isolate}\n"], dependencies: [{ kind: "component", type: LayerOutlet, selector: "g[miraLayerOutlet]", inputs: ["miraLayerOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1922
1937
|
}
|
|
1923
1938
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraBarChart, decorators: [{
|
|
1924
1939
|
type: Component,
|
|
1925
|
-
args: [{ selector: 'mira-bar-chart', changeDetection: ChangeDetectionStrategy.OnPush, imports: [LayerOutlet], providers: [
|
|
1940
|
+
args: [{ selector: 'mira-bar-chart', changeDetection: ChangeDetectionStrategy.OnPush, imports: [LayerOutlet], providers: [
|
|
1941
|
+
{
|
|
1942
|
+
provide: MiraCartesianContext,
|
|
1943
|
+
useExisting: forwardRef(() => MiraBarChart),
|
|
1944
|
+
},
|
|
1945
|
+
], template: CARTESIAN_CHART_TEMPLATE, styles: [":host{--_mira-axis-color: var(--mira-axis-color, #666);--_mira-grid-color: var(--mira-grid-color, #ccc);--_mira-background: var(--mira-background, #fff);--_mira-cursor-color: var(--mira-cursor-color, #999)}@supports (color: light-dark(#000,#fff)){:host{--_mira-axis-color: var(--mira-axis-color, light-dark(#666, #999));--_mira-grid-color: var(--mira-grid-color, light-dark(#ccc, #333));--_mira-background: var(--mira-background, Canvas);--_mira-cursor-color: var(--mira-cursor-color, light-dark(#999, #666))}}\n", ".mira-chart{display:grid;width:fit-content}.mira-chart>*{grid-area:1 / 1}svg{display:block}.mira-chart-overlay{position:relative;pointer-events:none;isolation:isolate}\n"] }]
|
|
1926
1946
|
}] });
|
|
1927
1947
|
|
|
1928
1948
|
// The room the bars leave on each side of their band, as a share of the band.
|
|
@@ -1977,7 +1997,7 @@ class MiraBar extends MiraSeries {
|
|
|
1977
1997
|
}, ...(ngDevMode ? [{ debugName: "bars" }] : []));
|
|
1978
1998
|
// The nearest chart: a bar in a line chart throws, even with a bar chart
|
|
1979
1999
|
// further out.
|
|
1980
|
-
#chart = inject(
|
|
2000
|
+
#chart = inject(MiraCartesianContext);
|
|
1981
2001
|
#bandwidth = bandwidthOf(this.#chart);
|
|
1982
2002
|
// The bar's place in each band: the chart's visible bars share it, side by
|
|
1983
2003
|
// side in the order they're written.
|
|
@@ -1990,7 +2010,7 @@ class MiraBar extends MiraSeries {
|
|
|
1990
2010
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraBar) },
|
|
1991
2011
|
{ provide: MiraSeries, useExisting: forwardRef(() => MiraBar) },
|
|
1992
2012
|
], usesInheritance: true, ngImport: i0, template: `
|
|
1993
|
-
<ng-template>
|
|
2013
|
+
<ng-template miraLayerContent>
|
|
1994
2014
|
<svg:g class="mira-bar" [attr.fill]="fill()">
|
|
1995
2015
|
@for (bar of bars(); track bar.index) {
|
|
1996
2016
|
<svg:rect
|
|
@@ -2002,19 +2022,20 @@ class MiraBar extends MiraSeries {
|
|
|
2002
2022
|
}
|
|
2003
2023
|
</svg:g>
|
|
2004
2024
|
</ng-template>
|
|
2005
|
-
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2025
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: MiraLayerContent, selector: "ng-template[miraLayerContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2006
2026
|
}
|
|
2007
2027
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: MiraBar, decorators: [{
|
|
2008
2028
|
type: Component,
|
|
2009
2029
|
args: [{
|
|
2010
2030
|
selector: 'mira-bar',
|
|
2011
2031
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2032
|
+
imports: [MiraLayerContent],
|
|
2012
2033
|
providers: [
|
|
2013
2034
|
{ provide: MiraChartLayer, useExisting: forwardRef(() => MiraBar) },
|
|
2014
2035
|
{ provide: MiraSeries, useExisting: forwardRef(() => MiraBar) },
|
|
2015
2036
|
],
|
|
2016
2037
|
template: `
|
|
2017
|
-
<ng-template>
|
|
2038
|
+
<ng-template miraLayerContent>
|
|
2018
2039
|
<svg:g class="mira-bar" [attr.fill]="fill()">
|
|
2019
2040
|
@for (bar of bars(); track bar.index) {
|
|
2020
2041
|
<svg:rect
|
|
@@ -2061,5 +2082,5 @@ function slotOf(rank, count, bandwidth) {
|
|
|
2061
2082
|
* Generated bundle index. Do not edit.
|
|
2062
2083
|
*/
|
|
2063
2084
|
|
|
2064
|
-
export { MiraBar, MiraBarChart, MiraCartesianChart, MiraCartesianGrid, MiraChartLayer, MiraCursor, MiraLegend, MiraLegendItemContent, MiraLine, MiraLineChart, MiraSeries, MiraTooltip, MiraTooltipContent, MiraXAxis, MiraYAxis };
|
|
2085
|
+
export { MiraBar, MiraBarChart, MiraCartesianChart, MiraCartesianContext, MiraCartesianGrid, MiraChartLayer, MiraCursor, MiraLayerContent, MiraLegend, MiraLegendItemContent, MiraLine, MiraLineChart, MiraSeries, MiraTooltip, MiraTooltipContent, MiraXAxis, MiraYAxis };
|
|
2065
2086
|
//# sourceMappingURL=ngx-mira-charts.mjs.map
|