@pioneer-code/pioneer-charts 22.0.4 → 22.1.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/fesm2022/pioneer-code-pioneer-charts.mjs +299 -160
- package/fesm2022/pioneer-code-pioneer-charts.mjs.map +1 -1
- package/package.json +3 -3
- package/scss/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.scss +13 -0
- package/scss/bar-chart/bar-vertical-chart/bar-vertical-chart.component.scss +13 -0
- package/scss/legend/legend.component.scss +8 -1
- package/scss/plot-line-area-chart/plot-line-area-chart.component.scss +18 -0
- package/types/pioneer-code-pioneer-charts.d.ts +75 -11
|
@@ -9,10 +9,10 @@ import { format } from 'd3-format';
|
|
|
9
9
|
import { select, scaleTime, zoom } from 'd3';
|
|
10
10
|
import { takeUntilDestroyed, outputFromObservable } from '@angular/core/rxjs-interop';
|
|
11
11
|
import { debounceTime } from 'rxjs/operators';
|
|
12
|
+
import { transition } from 'd3-transition';
|
|
12
13
|
import { range } from 'd3-array';
|
|
13
14
|
import { line, area, arc, pie } from 'd3-shape';
|
|
14
15
|
import { interpolate } from 'd3-interpolate';
|
|
15
|
-
import { transition } from 'd3-transition';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Base configuration for all charts.
|
|
@@ -24,12 +24,37 @@ class PcacChartConfig {
|
|
|
24
24
|
*/
|
|
25
25
|
data = [];
|
|
26
26
|
height = 200;
|
|
27
|
+
/**
|
|
28
|
+
* When true, `height` becomes a *minimum* height: if the container the chart is placed in is
|
|
29
|
+
* taller than `height`, the chart grows to fill it instead.
|
|
30
|
+
*
|
|
31
|
+
* The chart fills its own host element (`<pcac-bar-vertical-chart>` etc.), which it stretches
|
|
32
|
+
* to `height: 100%` while this is on - so the consumer just needs to give the element wrapping
|
|
33
|
+
* the chart a definite height (an explicit height, or a flex/grid track that resolves to one).
|
|
34
|
+
* If that wrapper turns out to be auto-height, there's nothing definite to fill and the chart
|
|
35
|
+
* falls back to `height`.
|
|
36
|
+
*
|
|
37
|
+
* Optional (rather than defaulted like the properties above) so that adding it doesn't force
|
|
38
|
+
* every existing consumer that builds a config as an object literal to declare it; the `= false`
|
|
39
|
+
* initializer still applies to anything constructed via `new`.
|
|
40
|
+
*/
|
|
41
|
+
heightFull = false;
|
|
27
42
|
}
|
|
28
43
|
class PcacData {
|
|
29
44
|
key = null;
|
|
30
45
|
value = null;
|
|
31
46
|
hide = false;
|
|
32
47
|
data = [];
|
|
48
|
+
/**
|
|
49
|
+
* URL (or data URI) of an image to draw at this point *in place of* its dot. Currently honored
|
|
50
|
+
* by the line/area/plot charts only, on the innermost (point-level) `PcacData`; sized by the
|
|
51
|
+
* chart config's `pointImage` (see `PcacLineAreaChartConfig.pointImage`). Points without one
|
|
52
|
+
* keep their regular dot, so the two can be mixed within a single series.
|
|
53
|
+
*
|
|
54
|
+
* Optional (rather than defaulted) for the same reason as `PcacChartConfig.heightFull`: so
|
|
55
|
+
* existing object-literal / JSON data doesn't have to declare it.
|
|
56
|
+
*/
|
|
57
|
+
image;
|
|
33
58
|
}
|
|
34
59
|
var PcacFormatEnum;
|
|
35
60
|
(function (PcacFormatEnum) {
|
|
@@ -91,7 +116,7 @@ class PcacAxisBuilder {
|
|
|
91
116
|
xAxis.tickFormat((d) => d + 'f');
|
|
92
117
|
break;
|
|
93
118
|
case PcacFormatEnum.OneDayHours:
|
|
94
|
-
xAxis.tickFormat((d
|
|
119
|
+
xAxis.tickFormat((d) => {
|
|
95
120
|
const h = d;
|
|
96
121
|
const hour = h % 12 === 0 ? 12 : h % 12;
|
|
97
122
|
const period = h < 12 ? 'am' : 'pm';
|
|
@@ -108,10 +133,10 @@ class PcacAxisBuilder {
|
|
|
108
133
|
.attr('transform', 'translate(0,' + config.height + ')')
|
|
109
134
|
.call(xAxis);
|
|
110
135
|
}
|
|
111
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
112
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
136
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAxisBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
137
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAxisBuilder, providedIn: 'root' });
|
|
113
138
|
}
|
|
114
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
139
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAxisBuilder, decorators: [{
|
|
115
140
|
type: Injectable,
|
|
116
141
|
args: [{
|
|
117
142
|
providedIn: 'root',
|
|
@@ -148,10 +173,10 @@ class PcacGridBuilder {
|
|
|
148
173
|
.attr('x2', config.width)
|
|
149
174
|
.attr('class', (_, i) => (i === 0 ? 'pcac-grid-rule-last' : ''));
|
|
150
175
|
}
|
|
151
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
152
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
176
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacGridBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
177
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacGridBuilder, providedIn: 'root' });
|
|
153
178
|
}
|
|
154
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacGridBuilder, decorators: [{
|
|
155
180
|
type: Injectable,
|
|
156
181
|
args: [{
|
|
157
182
|
providedIn: 'root',
|
|
@@ -218,10 +243,10 @@ class PcacColorService {
|
|
|
218
243
|
setAlert(color) {
|
|
219
244
|
this.alert = color;
|
|
220
245
|
}
|
|
221
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
222
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
246
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacColorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
247
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacColorService, providedIn: 'root' });
|
|
223
248
|
}
|
|
224
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacColorService, decorators: [{
|
|
225
250
|
type: Injectable,
|
|
226
251
|
args: [{
|
|
227
252
|
providedIn: 'root',
|
|
@@ -233,10 +258,10 @@ class PcacTransitionService {
|
|
|
233
258
|
getTransitionDuration() {
|
|
234
259
|
return this.transitionDuration;
|
|
235
260
|
}
|
|
236
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
237
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
261
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTransitionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
262
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTransitionService, providedIn: 'root' });
|
|
238
263
|
}
|
|
239
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
264
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTransitionService, decorators: [{
|
|
240
265
|
type: Injectable,
|
|
241
266
|
args: [{
|
|
242
267
|
providedIn: 'root',
|
|
@@ -283,13 +308,13 @@ class PcacTooltipBuilder {
|
|
|
283
308
|
break;
|
|
284
309
|
}
|
|
285
310
|
}
|
|
286
|
-
|
|
311
|
+
const finalValue = value ? value.toString() : value;
|
|
287
312
|
return key ? key + '</br>' + finalValue : `${finalValue}`;
|
|
288
313
|
}
|
|
289
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
290
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
314
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
315
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, providedIn: 'root' });
|
|
291
316
|
}
|
|
292
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
317
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, decorators: [{
|
|
293
318
|
type: Injectable,
|
|
294
319
|
args: [{
|
|
295
320
|
providedIn: 'root',
|
|
@@ -316,6 +341,14 @@ class PcacChart {
|
|
|
316
341
|
* stable basis for "did the container itself resize" — the raw container measurement is.
|
|
317
342
|
*/
|
|
318
343
|
lastContainerWidth = null;
|
|
344
|
+
/**
|
|
345
|
+
* Raw container height measured by the last successful `initializeChartState()` call, and
|
|
346
|
+
* whether that build was running with `heightFull` on. Only consulted by `containerSizeChanged`
|
|
347
|
+
* when it was: without `heightFull` the container's height is driven *by* the chart's own SVG
|
|
348
|
+
* height, so comparing it would report "changed" every time the chart itself grew or shrank.
|
|
349
|
+
*/
|
|
350
|
+
lastContainerHeight = null;
|
|
351
|
+
lastHeightFull = false;
|
|
319
352
|
/**
|
|
320
353
|
* Prior to building a chart, we need to initialize the state of the chart.
|
|
321
354
|
*
|
|
@@ -330,20 +363,44 @@ class PcacChart {
|
|
|
330
363
|
*/
|
|
331
364
|
initializeChartState(chartElm, config) {
|
|
332
365
|
select$1(chartElm.nativeElement).select('g').remove();
|
|
333
|
-
const
|
|
366
|
+
const container = chartElm.nativeElement.parentNode;
|
|
367
|
+
const containerWidth = container.clientWidth;
|
|
334
368
|
const measuredWidth = containerWidth - this.margin.left - this.margin.right;
|
|
335
369
|
if (measuredWidth <= 0) {
|
|
336
370
|
return false;
|
|
337
371
|
}
|
|
338
372
|
this.width = measuredWidth;
|
|
339
|
-
this.height = config
|
|
373
|
+
this.height = this.resolveHeight(container, config);
|
|
340
374
|
this.colors = this.colorService.getColorScale(Math.max(config.data.length, config.data[0]?.data ? config.data[0].data.length : 0));
|
|
341
375
|
this.lastContainerWidth = containerWidth;
|
|
376
|
+
this.lastContainerHeight = container.clientHeight;
|
|
377
|
+
this.lastHeightFull = config.heightFull === true;
|
|
342
378
|
return true;
|
|
343
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* `config.height` normally *is* the height of the drawing area. With `config.heightFull` on it
|
|
382
|
+
* becomes a floor instead: the chart fills its container, and only falls back to `config.height`
|
|
383
|
+
* when the container is shorter than that (or has no definite height of its own to fill - see
|
|
384
|
+
* `PcacChartConfig.heightFull`, where an auto-height container measures ~0 here and the
|
|
385
|
+
* `Math.max` keeps the configured height).
|
|
386
|
+
*
|
|
387
|
+
* Note this deliberately subtracts the margins, so it's the *total* SVG that ends up matching
|
|
388
|
+
* the container: `buildContainer()` adds `margin.top`/`margin.bottom` back on top of `height`
|
|
389
|
+
* when sizing the `<svg>`, so filling without this would overflow the container by exactly the
|
|
390
|
+
* vertical margins.
|
|
391
|
+
* @param container The chart's container element (the `<svg>`'s parent)
|
|
392
|
+
* @param config Chart specific configuration
|
|
393
|
+
*/
|
|
394
|
+
resolveHeight(container, config) {
|
|
395
|
+
if (!config.heightFull) {
|
|
396
|
+
return config.height;
|
|
397
|
+
}
|
|
398
|
+
return Math.max(config.height, container.clientHeight - this.margin.top - this.margin.bottom);
|
|
399
|
+
}
|
|
344
400
|
/**
|
|
345
401
|
* True if the container's current raw layout width differs from the one measured by the last
|
|
346
|
-
* successful build, or if no successful build has happened yet.
|
|
402
|
+
* successful build, or if no successful build has happened yet. For a `heightFull` chart, a
|
|
403
|
+
* change in the container's height counts too - that's the whole size the chart is tracking.
|
|
347
404
|
*
|
|
348
405
|
* `PcacChartResizeService`'s `ResizeObserver` is guaranteed to fire once as soon as it starts
|
|
349
406
|
* observing — that's what lets a chart recover from the 0-width race described on
|
|
@@ -357,8 +414,19 @@ class PcacChart {
|
|
|
357
414
|
if (this.lastContainerWidth === null) {
|
|
358
415
|
return true;
|
|
359
416
|
}
|
|
360
|
-
const
|
|
361
|
-
|
|
417
|
+
const container = chartElm.nativeElement.parentNode;
|
|
418
|
+
const containerWidth = container.clientWidth;
|
|
419
|
+
if (containerWidth > 0 && containerWidth !== this.lastContainerWidth) {
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
if (!this.lastHeightFull) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
// Height only matters for a `heightFull` chart, and only there is it safe to compare: the
|
|
426
|
+
// container's height is definite (see `resolveHeight`), so it changes when the *layout*
|
|
427
|
+
// changes, not in response to the height this chart just drew itself at.
|
|
428
|
+
const containerHeight = container.clientHeight;
|
|
429
|
+
return containerHeight > 0 && containerHeight !== this.lastContainerHeight;
|
|
362
430
|
}
|
|
363
431
|
/**
|
|
364
432
|
* 1) Set the width and height of the SVG
|
|
@@ -404,7 +472,6 @@ class PcacChart {
|
|
|
404
472
|
})
|
|
405
473
|
.remove();
|
|
406
474
|
this.margin.left = max;
|
|
407
|
-
this.margin.bottom = this.margin.bottom;
|
|
408
475
|
this.width = this.width - this.margin.left;
|
|
409
476
|
}
|
|
410
477
|
}
|
|
@@ -531,7 +598,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
531
598
|
.attr('class', 'pcac-bar')
|
|
532
599
|
.attr('x', 0)
|
|
533
600
|
.attr('y', (d) => {
|
|
534
|
-
|
|
601
|
+
const value = !config.isStacked ? this.yScaleGrouped(d.key) : this.yScaleStacked(d.key);
|
|
535
602
|
return value ? value : 0;
|
|
536
603
|
})
|
|
537
604
|
.attr('data-group-bar-id', (_, i) => {
|
|
@@ -546,7 +613,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
546
613
|
return this.colors[i];
|
|
547
614
|
})
|
|
548
615
|
.attr('width', 0)
|
|
549
|
-
.on('mouseover', function (
|
|
616
|
+
.on('mouseover', function () {
|
|
550
617
|
select$1(this)
|
|
551
618
|
.transition()
|
|
552
619
|
.duration(self.transitionService.getTransitionDuration() / 7.5)
|
|
@@ -566,7 +633,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
566
633
|
.on('mousemove', (event, d) => {
|
|
567
634
|
self.tooltipBuilder.showBarTooltip(event, d, config.tickFormat || PcacFormatEnum.None);
|
|
568
635
|
})
|
|
569
|
-
.on('mouseout', function (
|
|
636
|
+
.on('mouseout', function () {
|
|
570
637
|
self.tooltipBuilder.hideTooltip();
|
|
571
638
|
select$1(this)
|
|
572
639
|
.transition()
|
|
@@ -590,7 +657,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
590
657
|
});
|
|
591
658
|
}
|
|
592
659
|
drawThresholdAcrossChart(config) {
|
|
593
|
-
this.applyPreTransitionThresholdStyles(this.svg.select('.pcac-bars').append('rect')
|
|
660
|
+
this.applyPreTransitionThresholdStyles(this.svg.select('.pcac-bars').append('rect'))
|
|
594
661
|
.attr('height', this.height)
|
|
595
662
|
.attr('data-group-threshold-id', (_, i) => {
|
|
596
663
|
return i;
|
|
@@ -606,7 +673,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
606
673
|
}
|
|
607
674
|
drawThresholdsPerGroup(group, config) {
|
|
608
675
|
const self = this;
|
|
609
|
-
this.applyPreTransitionThresholdStyles(this.svg.selectAll('.pcac-bar-group').append('rect')
|
|
676
|
+
this.applyPreTransitionThresholdStyles(this.svg.selectAll('.pcac-bar-group').append('rect'))
|
|
610
677
|
.attr('height', this.yScaleStacked.bandwidth())
|
|
611
678
|
.attr('data-group-threshold-id', (_, i) => {
|
|
612
679
|
return i;
|
|
@@ -625,7 +692,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
625
692
|
}
|
|
626
693
|
drawThresholdsPerBarInGroup(group, config) {
|
|
627
694
|
const self = this;
|
|
628
|
-
this.applyPreTransitionThresholdStyles(group.enter().append('rect')
|
|
695
|
+
this.applyPreTransitionThresholdStyles(group.enter().append('rect'))
|
|
629
696
|
.attr('data-group-threshold-id', (_, i) => {
|
|
630
697
|
return i;
|
|
631
698
|
})
|
|
@@ -645,7 +712,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
645
712
|
return this.xScale(config.thresholds[n[0].parentElement.dataset['groupId']].data[i].value);
|
|
646
713
|
});
|
|
647
714
|
}
|
|
648
|
-
applyPreTransitionThresholdStyles(elm
|
|
715
|
+
applyPreTransitionThresholdStyles(elm) {
|
|
649
716
|
return elm.attr('class', 'pcac-threshold')
|
|
650
717
|
.style('fill', () => {
|
|
651
718
|
return this.colorService.getAlert();
|
|
@@ -661,10 +728,10 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
661
728
|
this.tooltipBuilder.hideTooltip();
|
|
662
729
|
});
|
|
663
730
|
}
|
|
664
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
665
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
731
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarHorizontalChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
732
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarHorizontalChartBuilder });
|
|
666
733
|
}
|
|
667
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
734
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarHorizontalChartBuilder, decorators: [{
|
|
668
735
|
type: Injectable
|
|
669
736
|
}] });
|
|
670
737
|
|
|
@@ -717,10 +784,10 @@ class PcacChartResizeService {
|
|
|
717
784
|
destroyRef.onDestroy(() => observer.disconnect());
|
|
718
785
|
});
|
|
719
786
|
}
|
|
720
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
721
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
787
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacChartResizeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
788
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacChartResizeService, providedIn: 'root' });
|
|
722
789
|
}
|
|
723
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
790
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacChartResizeService, decorators: [{
|
|
724
791
|
type: Injectable,
|
|
725
792
|
args: [{ providedIn: 'root' }]
|
|
726
793
|
}] });
|
|
@@ -729,7 +796,8 @@ class PcacBarHorizontalChartComponent {
|
|
|
729
796
|
chartBuilder = inject(BarHorizontalChartBuilder);
|
|
730
797
|
config = input.required(/* @ts-ignore */
|
|
731
798
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
732
|
-
chartElm = viewChild.required('chart'
|
|
799
|
+
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
800
|
+
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
733
801
|
barClicked = outputFromObservable(this.chartBuilder.barClicked$);
|
|
734
802
|
constructor() {
|
|
735
803
|
// Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
|
|
@@ -751,12 +819,12 @@ class PcacBarHorizontalChartComponent {
|
|
|
751
819
|
this.chartBuilder.buildChart(this.chartElm(), config);
|
|
752
820
|
}
|
|
753
821
|
}
|
|
754
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
755
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.
|
|
822
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarHorizontalChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
823
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.6", type: PcacBarHorizontalChartComponent, isStandalone: true, selector: "pcac-bar-horizontal-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { barClicked: "barClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, providers: [BarHorizontalChartBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-bar-horizontal-chart\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-bar-horizontal-chart{display:block}.pcac-bar-horizontal-chart svg{width:100%;display:block}.pcac-d3-tooltip{position:absolute;text-align:center;font-size:14px;padding:.5rem;pointer-events:none;display:none;background-color:#000000bf;color:#fff;border-radius:5px}pcac-bar-horizontal-chart.pcac-height-full{display:block;height:100%}pcac-bar-horizontal-chart.pcac-height-full .pcac-bar-horizontal-chart{height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
756
824
|
}
|
|
757
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
825
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarHorizontalChartComponent, decorators: [{
|
|
758
826
|
type: Component,
|
|
759
|
-
args: [{ selector: 'pcac-bar-horizontal-chart', encapsulation: ViewEncapsulation.None, providers: [BarHorizontalChartBuilder], template: "<section class=\"pcac-bar-horizontal-chart\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-bar-horizontal-chart{display:block}.pcac-bar-horizontal-chart svg{width:100%;display:block}.pcac-d3-tooltip{position:absolute;text-align:center;font-size:14px;padding:.5rem;pointer-events:none;display:none;background-color:#000000bf;color:#fff;border-radius:5px}\n"] }]
|
|
827
|
+
args: [{ selector: 'pcac-bar-horizontal-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, encapsulation: ViewEncapsulation.None, providers: [BarHorizontalChartBuilder], template: "<section class=\"pcac-bar-horizontal-chart\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-bar-horizontal-chart{display:block}.pcac-bar-horizontal-chart svg{width:100%;display:block}.pcac-d3-tooltip{position:absolute;text-align:center;font-size:14px;padding:.5rem;pointer-events:none;display:none;background-color:#000000bf;color:#fff;border-radius:5px}pcac-bar-horizontal-chart.pcac-height-full{display:block;height:100%}pcac-bar-horizontal-chart.pcac-height-full .pcac-bar-horizontal-chart{height:100%}\n"] }]
|
|
760
828
|
}], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], chartElm: [{ type: i0.ViewChild, args: ['chart', { isSignal: true }] }], barClicked: [{ type: i0.Output, args: ["barClicked"] }] } });
|
|
761
829
|
|
|
762
830
|
class PcacBarHorizontalChartConfig extends PcacChartConfig {
|
|
@@ -872,11 +940,11 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
872
940
|
.attr('data-group-id', (d, i) => {
|
|
873
941
|
return i;
|
|
874
942
|
})
|
|
875
|
-
.attr('transform', (d
|
|
943
|
+
.attr('transform', (d) => {
|
|
876
944
|
return 'translate(' + this.xScaleStacked(d.key) + ',0)';
|
|
877
945
|
});
|
|
878
946
|
const group = groupsContainer.selectAll('rect')
|
|
879
|
-
.data((d
|
|
947
|
+
.data((d) => {
|
|
880
948
|
return d.data;
|
|
881
949
|
});
|
|
882
950
|
this.drawBarsPerGroup(group, config);
|
|
@@ -901,8 +969,8 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
901
969
|
const self = this;
|
|
902
970
|
group.enter().append('rect')
|
|
903
971
|
.attr('class', 'pcac-bar')
|
|
904
|
-
.attr('x', (d
|
|
905
|
-
|
|
972
|
+
.attr('x', (d) => {
|
|
973
|
+
const value = !config.isStacked ? this.xScaleGrouped(d.key) : this.xScaleStacked(d.key);
|
|
906
974
|
return value ? value : 0;
|
|
907
975
|
})
|
|
908
976
|
.attr('data-group-bar-id', (_, i) => {
|
|
@@ -919,7 +987,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
919
987
|
return this.height;
|
|
920
988
|
})
|
|
921
989
|
.attr('height', 0)
|
|
922
|
-
.on('mouseover', function (
|
|
990
|
+
.on('mouseover', function () {
|
|
923
991
|
select$1(this)
|
|
924
992
|
.transition()
|
|
925
993
|
.duration(self.transitionService.getTransitionDuration() / 5)
|
|
@@ -939,7 +1007,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
939
1007
|
.on('mousemove', (event, d) => {
|
|
940
1008
|
self.tooltipBuilder.showBarTooltip(event, d, config.tickFormat || PcacFormatEnum.None);
|
|
941
1009
|
})
|
|
942
|
-
.on('mouseout', function (
|
|
1010
|
+
.on('mouseout', function () {
|
|
943
1011
|
self.tooltipBuilder.hideTooltip();
|
|
944
1012
|
select$1(this)
|
|
945
1013
|
.transition()
|
|
@@ -970,7 +1038,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
970
1038
|
});
|
|
971
1039
|
}
|
|
972
1040
|
drawThresholdAcrossChart(config) {
|
|
973
|
-
this.applyPreTransitionThresholdStyles(this.svg.select('.pcac-bars').append('rect')
|
|
1041
|
+
this.applyPreTransitionThresholdStyles(this.svg.select('.pcac-bars').append('rect'))
|
|
974
1042
|
.attr('width', this.width)
|
|
975
1043
|
.attr('data-group-threshold-id', (_, i) => {
|
|
976
1044
|
return i;
|
|
@@ -986,7 +1054,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
986
1054
|
}
|
|
987
1055
|
drawThresholdsPerGroup(group, config) {
|
|
988
1056
|
const self = this;
|
|
989
|
-
this.applyPreTransitionThresholdStyles(this.svg.selectAll('.pcac-bar-group').append('rect')
|
|
1057
|
+
this.applyPreTransitionThresholdStyles(this.svg.selectAll('.pcac-bar-group').append('rect'))
|
|
990
1058
|
.attr('width', this.xScaleStacked.bandwidth())
|
|
991
1059
|
.attr('data-group-threshold-id', (_, i) => {
|
|
992
1060
|
return i;
|
|
@@ -1005,7 +1073,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1005
1073
|
}
|
|
1006
1074
|
drawThresholdsPerBarInGroup(group, config) {
|
|
1007
1075
|
const self = this;
|
|
1008
|
-
this.applyPreTransitionThresholdStyles(group.enter().append('rect')
|
|
1076
|
+
this.applyPreTransitionThresholdStyles(group.enter().append('rect'))
|
|
1009
1077
|
.attr('data-group-threshold-id', (_, i) => {
|
|
1010
1078
|
return i;
|
|
1011
1079
|
})
|
|
@@ -1021,7 +1089,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1021
1089
|
return this.yScale(config.thresholds[n[0].parentElement.dataset['groupId']].data[i].value);
|
|
1022
1090
|
});
|
|
1023
1091
|
}
|
|
1024
|
-
applyPreTransitionThresholdStyles(elm
|
|
1092
|
+
applyPreTransitionThresholdStyles(elm) {
|
|
1025
1093
|
return elm.attr('class', 'pcac-threshold')
|
|
1026
1094
|
.attr('x', (d) => {
|
|
1027
1095
|
// Not every caller's selection has a per-item PcacData bound (the whole-chart threshold
|
|
@@ -1050,10 +1118,10 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1050
1118
|
return '3px';
|
|
1051
1119
|
});
|
|
1052
1120
|
}
|
|
1053
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1054
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
1121
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarVerticalChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
1122
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarVerticalChartBuilder });
|
|
1055
1123
|
}
|
|
1056
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarVerticalChartBuilder, decorators: [{
|
|
1057
1125
|
type: Injectable
|
|
1058
1126
|
}] });
|
|
1059
1127
|
|
|
@@ -1061,7 +1129,8 @@ class PcacBarVerticalChartComponent {
|
|
|
1061
1129
|
chartBuilder = inject(BarVerticalChartBuilder);
|
|
1062
1130
|
config = input.required(/* @ts-ignore */
|
|
1063
1131
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1064
|
-
chartElm = viewChild.required('chart'
|
|
1132
|
+
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
1133
|
+
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
1065
1134
|
barClicked = outputFromObservable(this.chartBuilder.barClicked$);
|
|
1066
1135
|
constructor() {
|
|
1067
1136
|
// Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
|
|
@@ -1083,12 +1152,12 @@ class PcacBarVerticalChartComponent {
|
|
|
1083
1152
|
this.chartBuilder.buildChart(this.chartElm(), config);
|
|
1084
1153
|
}
|
|
1085
1154
|
}
|
|
1086
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1087
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.
|
|
1155
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarVerticalChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1156
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.6", type: PcacBarVerticalChartComponent, isStandalone: true, selector: "pcac-bar-vertical-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { barClicked: "barClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, providers: [BarVerticalChartBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-bar-vertical-chart\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-bar-vertical-chart svg{width:100%;display:block}pcac-bar-vertical-chart.pcac-height-full{display:block;height:100%}pcac-bar-vertical-chart.pcac-height-full .pcac-bar-vertical-chart{height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
1088
1157
|
}
|
|
1089
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarVerticalChartComponent, decorators: [{
|
|
1090
1159
|
type: Component,
|
|
1091
|
-
args: [{ selector: 'pcac-bar-vertical-chart', encapsulation: ViewEncapsulation.None, providers: [BarVerticalChartBuilder], template: "<section class=\"pcac-bar-vertical-chart\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-bar-vertical-chart svg{width:100%;display:block}\n"] }]
|
|
1160
|
+
args: [{ selector: 'pcac-bar-vertical-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, encapsulation: ViewEncapsulation.None, providers: [BarVerticalChartBuilder], template: "<section class=\"pcac-bar-vertical-chart\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-bar-vertical-chart svg{width:100%;display:block}pcac-bar-vertical-chart.pcac-height-full{display:block;height:100%}pcac-bar-vertical-chart.pcac-height-full .pcac-bar-vertical-chart{height:100%}\n"] }]
|
|
1092
1161
|
}], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], chartElm: [{ type: i0.ViewChild, args: ['chart', { isSignal: true }] }], barClicked: [{ type: i0.Output, args: ["barClicked"] }] } });
|
|
1093
1162
|
|
|
1094
1163
|
class PcacBarVerticalChartConfig extends PcacChartConfig {
|
|
@@ -1127,14 +1196,53 @@ class PcacLegend {
|
|
|
1127
1196
|
this.config.set({ ...this.config(), items });
|
|
1128
1197
|
this.itemClicked.emit(items);
|
|
1129
1198
|
}
|
|
1130
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1131
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.
|
|
1199
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLegend, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1200
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: PcacLegend, isStandalone: true, selector: "pcac-legend", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { config: "configChange", itemClicked: "itemClicked" }, ngImport: i0, template: "<div class=\"pcac-legend-label\"><small>{{config().heading}}</small></div>\n@for(item of config().items; track item; let i = $index; let first = $first; let last = $last;) {\n<div class=\"pcac-legend-item\" [class.pcac-legend-item-last]=\"last\" [class.pcac-legend-unchecked]=\"!item.checked\"\n role=\"switch\" [attr.aria-checked]=\"item.checked\" tabindex=\"0\" (click)=\"onItemClicked(i)\"\n (keydown.enter)=\"onItemClicked(i)\" (keydown.space)=\"onItemClicked(i); $event.preventDefault()\">\n @let color = item.colorOverride ? item.colorOverride : colorScale()[i];\n <div class=\"pcac-legend-circle\" [style.backgroundColor]=\"color\"></div>\n <small>{{ item.label }}</small>\n</div>\n}\n", styles: [":host{display:flex;align-items:center}.pcac-legend-label{margin-right:8px;margin-bottom:2.5px}.pcac-legend-item{cursor:pointer;display:flex;align-items:center;margin-right:8px}.pcac-legend-item:hover .pcac-legend-circle{box-shadow:0 0 6px #0000004d;transform:scale(1.2)}.pcac-legend-circle{display:inline-block;width:12px;height:12px;border-radius:50%;margin-right:4px;transition:box-shadow .3s ease,transform .3s ease}.pcac-legend-unchecked{opacity:.5}.pcac-legend-item-last{margin-right:0}.pcac-legend-item:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n"] });
|
|
1132
1201
|
}
|
|
1133
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1202
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLegend, decorators: [{
|
|
1134
1203
|
type: Component,
|
|
1135
|
-
args: [{ selector: 'pcac-legend', template: "<
|
|
1204
|
+
args: [{ selector: 'pcac-legend', template: "<div class=\"pcac-legend-label\"><small>{{config().heading}}</small></div>\n@for(item of config().items; track item; let i = $index; let first = $first; let last = $last;) {\n<div class=\"pcac-legend-item\" [class.pcac-legend-item-last]=\"last\" [class.pcac-legend-unchecked]=\"!item.checked\"\n role=\"switch\" [attr.aria-checked]=\"item.checked\" tabindex=\"0\" (click)=\"onItemClicked(i)\"\n (keydown.enter)=\"onItemClicked(i)\" (keydown.space)=\"onItemClicked(i); $event.preventDefault()\">\n @let color = item.colorOverride ? item.colorOverride : colorScale()[i];\n <div class=\"pcac-legend-circle\" [style.backgroundColor]=\"color\"></div>\n <small>{{ item.label }}</small>\n</div>\n}\n", styles: [":host{display:flex;align-items:center}.pcac-legend-label{margin-right:8px;margin-bottom:2.5px}.pcac-legend-item{cursor:pointer;display:flex;align-items:center;margin-right:8px}.pcac-legend-item:hover .pcac-legend-circle{box-shadow:0 0 6px #0000004d;transform:scale(1.2)}.pcac-legend-circle{display:inline-block;width:12px;height:12px;border-radius:50%;margin-right:4px;transition:box-shadow .3s ease,transform .3s ease}.pcac-legend-unchecked{opacity:.5}.pcac-legend-item-last{margin-right:0}.pcac-legend-item:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n"] }]
|
|
1136
1205
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }, { type: i0.Output, args: ["configChange"] }], itemClicked: [{ type: i0.Output, args: ["itemClicked"] }] } });
|
|
1137
1206
|
|
|
1207
|
+
var PcacLineAreaPlotChartConfigType;
|
|
1208
|
+
(function (PcacLineAreaPlotChartConfigType) {
|
|
1209
|
+
PcacLineAreaPlotChartConfigType["Line"] = "line";
|
|
1210
|
+
PcacLineAreaPlotChartConfigType["Area"] = "area";
|
|
1211
|
+
PcacLineAreaPlotChartConfigType["Plot"] = "plot";
|
|
1212
|
+
})(PcacLineAreaPlotChartConfigType || (PcacLineAreaPlotChartConfigType = {}));
|
|
1213
|
+
/**
|
|
1214
|
+
* Sizing for the images drawn in place of a point's dot (see `PcacData.image`). An image is
|
|
1215
|
+
* scaled uniformly (up or down) to fit inside a `maxWidth` x `maxHeight` box, preserving its
|
|
1216
|
+
* aspect ratio, and is centered on the data point exactly where the dot would have been.
|
|
1217
|
+
*/
|
|
1218
|
+
class PcacPointImageConfig {
|
|
1219
|
+
maxWidth = 16;
|
|
1220
|
+
maxHeight = 16;
|
|
1221
|
+
}
|
|
1222
|
+
class PcacLineAreaChartConfig extends PcacChartConfig {
|
|
1223
|
+
enableEffects = true;
|
|
1224
|
+
enableZoom = true;
|
|
1225
|
+
numberOfTicks = 5;
|
|
1226
|
+
hideGrid = false;
|
|
1227
|
+
hideAxis = false;
|
|
1228
|
+
yFormat = PcacFormatEnum.DatasetLength;
|
|
1229
|
+
xFormat = PcacFormatEnum.DatasetLength;
|
|
1230
|
+
yDomainMax;
|
|
1231
|
+
yDomainMin;
|
|
1232
|
+
xDomainMin;
|
|
1233
|
+
xDomainMax;
|
|
1234
|
+
/**
|
|
1235
|
+
* Hex color codes to override the default colors
|
|
1236
|
+
*/
|
|
1237
|
+
colorOverride = [];
|
|
1238
|
+
/**
|
|
1239
|
+
* Bounding box for any point images (`PcacData.image`) on this chart. Optional; each field falls
|
|
1240
|
+
* back to the `PcacPointImageConfig` default when not given, so a consumer only setting `image`
|
|
1241
|
+
* on their data still gets a sensibly-sized result.
|
|
1242
|
+
*/
|
|
1243
|
+
pointImage;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1138
1246
|
/**
|
|
1139
1247
|
* Provided per-component (see PcacLineAreaChartComponent's `providers`), not root-scoped: this
|
|
1140
1248
|
* holds mutable per-chart-instance state (`config`, `lines`) despite looking like a stateless
|
|
@@ -1243,10 +1351,9 @@ class PlaChartEffectsBuilder {
|
|
|
1243
1351
|
}
|
|
1244
1352
|
let beginning = 0;
|
|
1245
1353
|
let end = line.getTotalLength();
|
|
1246
|
-
let target = 0;
|
|
1247
1354
|
let pos;
|
|
1248
1355
|
while (true) {
|
|
1249
|
-
target = Math.floor((beginning + end) / 2);
|
|
1356
|
+
const target = Math.floor((beginning + end) / 2);
|
|
1250
1357
|
pos = line.getPointAtLength(target);
|
|
1251
1358
|
if ((target === end || target === beginning) && pos.x !== mousePos[0]) {
|
|
1252
1359
|
break;
|
|
@@ -1261,50 +1368,26 @@ class PlaChartEffectsBuilder {
|
|
|
1261
1368
|
break;
|
|
1262
1369
|
}
|
|
1263
1370
|
}
|
|
1264
|
-
|
|
1371
|
+
const textTarget = this.config.y.invert(pos.y);
|
|
1265
1372
|
select$1(nodes[index]).select('text')
|
|
1266
1373
|
.text(textTarget.toFixed(0));
|
|
1267
1374
|
return 'translate(' + mousePos[0] + ',' + pos.y + ')';
|
|
1268
1375
|
});
|
|
1269
1376
|
}
|
|
1270
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1271
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
1377
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartEffectsBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1378
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartEffectsBuilder });
|
|
1272
1379
|
}
|
|
1273
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1380
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartEffectsBuilder, decorators: [{
|
|
1274
1381
|
type: Injectable
|
|
1275
1382
|
}] });
|
|
1276
1383
|
|
|
1277
|
-
var PcacLineAreaPlotChartConfigType;
|
|
1278
|
-
(function (PcacLineAreaPlotChartConfigType) {
|
|
1279
|
-
PcacLineAreaPlotChartConfigType["Line"] = "line";
|
|
1280
|
-
PcacLineAreaPlotChartConfigType["Area"] = "area";
|
|
1281
|
-
PcacLineAreaPlotChartConfigType["Plot"] = "plot";
|
|
1282
|
-
})(PcacLineAreaPlotChartConfigType || (PcacLineAreaPlotChartConfigType = {}));
|
|
1283
|
-
class PcacLineAreaChartConfig extends PcacChartConfig {
|
|
1284
|
-
enableEffects = true;
|
|
1285
|
-
enableZoom = true;
|
|
1286
|
-
numberOfTicks = 5;
|
|
1287
|
-
hideGrid = false;
|
|
1288
|
-
hideAxis = false;
|
|
1289
|
-
yFormat = PcacFormatEnum.DatasetLength;
|
|
1290
|
-
xFormat = PcacFormatEnum.DatasetLength;
|
|
1291
|
-
yDomainMax;
|
|
1292
|
-
yDomainMin;
|
|
1293
|
-
xDomainMin;
|
|
1294
|
-
xDomainMax;
|
|
1295
|
-
/**
|
|
1296
|
-
* Hex color codes to override the default colors
|
|
1297
|
-
*/
|
|
1298
|
-
colorOverride = [];
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
1384
|
class PlaChartScales {
|
|
1302
1385
|
x;
|
|
1303
1386
|
y;
|
|
1304
1387
|
}
|
|
1305
1388
|
class PlaChartScalesBuilder {
|
|
1306
1389
|
build(config, chartWidth, chartHeight) {
|
|
1307
|
-
|
|
1390
|
+
const resp = new PlaChartScales();
|
|
1308
1391
|
resp.x = this.buildXScale(config, chartWidth);
|
|
1309
1392
|
resp.y = this.buildYScale(config, chartHeight);
|
|
1310
1393
|
return resp;
|
|
@@ -1402,6 +1485,14 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1402
1485
|
dotClickedSource = new Subject();
|
|
1403
1486
|
config;
|
|
1404
1487
|
clipPathId; // <-- added
|
|
1488
|
+
/**
|
|
1489
|
+
* How far the clip-path rect extends past the drawable [0, width] x [0, height] area on every
|
|
1490
|
+
* side, so a point sitting exactly on the domain's edge isn't cut in half. 10px comfortably
|
|
1491
|
+
* clears a dot (r = 4, or 6 on hover); a point image can be much bigger than that, so
|
|
1492
|
+
* buildChart() widens this to half the largest image dimension whenever any point has one.
|
|
1493
|
+
*/
|
|
1494
|
+
clipBuffer = 10;
|
|
1495
|
+
pointImage;
|
|
1405
1496
|
dotClicked$ = this.dotClickedSource.asObservable();
|
|
1406
1497
|
buildChart(chartElm, config, type) {
|
|
1407
1498
|
if (!config?.data?.length) {
|
|
@@ -1424,9 +1515,16 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1424
1515
|
if (!this.initializeChartState(chartElm, this.config)) {
|
|
1425
1516
|
return;
|
|
1426
1517
|
}
|
|
1427
|
-
|
|
1518
|
+
// `?.length`, not a bare truthiness check: PcacLineAreaChartConfig defaults colorOverride to
|
|
1519
|
+
// `[]`, and an empty array is truthy - a config built with `new` would otherwise replace the
|
|
1520
|
+
// theme palette with nothing and every series would render with no color at all.
|
|
1521
|
+
if (this.config.colorOverride?.length) {
|
|
1428
1522
|
this.colors = this.config.colorOverride;
|
|
1429
1523
|
}
|
|
1524
|
+
this.pointImage = { ...new PcacPointImageConfig(), ...this.config.pointImage };
|
|
1525
|
+
this.clipBuffer = this.config.data.some((series) => series.data.some((point) => !!point.image))
|
|
1526
|
+
? Math.max(10, Math.ceil(this.pointImage.maxWidth / 2), Math.ceil(this.pointImage.maxHeight / 2))
|
|
1527
|
+
: 10;
|
|
1430
1528
|
this.scales = new PlaChartScalesBuilder().build(config, this.width, this.height);
|
|
1431
1529
|
this.lineGenerator = buildLineGenerator(config.xFormat, this.scales);
|
|
1432
1530
|
this.areaGenerator = buildAreaGenerator(config.xFormat, this.scales, this.height);
|
|
@@ -1449,9 +1547,12 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1449
1547
|
.attr('d', (d) => this.lineGenerator.x((_, i) => newX(i))(d));
|
|
1450
1548
|
this.svg.selectAll('.area')
|
|
1451
1549
|
.attr('d', (d) => this.areaGenerator.x((_, i) => newX(i))(d));
|
|
1452
|
-
// Update dots
|
|
1453
|
-
|
|
1454
|
-
|
|
1550
|
+
// Update dots / point images. Nested selectAll (not a flat svg.selectAll('.point')) so
|
|
1551
|
+
// that `i` is the point's index *within its own series* - the xFormat default
|
|
1552
|
+
// (DatasetLength) positions by index, and a flat selection would number every series'
|
|
1553
|
+
// points consecutively, shoving the second series' points off to the right on zoom.
|
|
1554
|
+
this.svg.selectAll('.dots').selectAll('.point')
|
|
1555
|
+
.attr('transform', (d, i) => this.pointTransform(d, i, newX));
|
|
1455
1556
|
});
|
|
1456
1557
|
}
|
|
1457
1558
|
this.drawChart(chartElm, this.config, type);
|
|
@@ -1502,10 +1603,12 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1502
1603
|
.append('clipPath')
|
|
1503
1604
|
.attr('id', this.clipPathId)
|
|
1504
1605
|
.append('rect')
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
.attr('
|
|
1508
|
-
.attr('
|
|
1606
|
+
// Extend the clip-path past the drawable area on every side so a dot (or point image) at
|
|
1607
|
+
// the x-domain's min/max, or the top/bottom of the y range, isn't cut in half. See clipBuffer.
|
|
1608
|
+
.attr('x', -this.clipBuffer)
|
|
1609
|
+
.attr('y', -this.clipBuffer)
|
|
1610
|
+
.attr('width', this.width + this.clipBuffer * 2)
|
|
1611
|
+
.attr('height', this.height + this.clipBuffer * 2);
|
|
1509
1612
|
}
|
|
1510
1613
|
attachZoomBehavior() {
|
|
1511
1614
|
if (!this.config.enableZoom)
|
|
@@ -1571,58 +1674,84 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1571
1674
|
.duration(this.transitionService.getTransitionDuration())
|
|
1572
1675
|
.attr('d', this.areaGenerator);
|
|
1573
1676
|
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Draws one `<g class="dots">` per series holding a `<g class="point">` per data point. The
|
|
1679
|
+
* point group carries the x position (as a translate) so that zoom only has to touch that one
|
|
1680
|
+
* attribute regardless of what's inside; the child is either the regular `<circle class="dot">`
|
|
1681
|
+
* or, when the point has a `PcacData.image`, an `<image class="dot-image">` in its place. Both
|
|
1682
|
+
* animate in from the baseline the same way, and the tooltip / click handlers sit on the group
|
|
1683
|
+
* so they behave identically for either.
|
|
1684
|
+
*/
|
|
1574
1685
|
drawDots(config) {
|
|
1575
1686
|
const self = this;
|
|
1687
|
+
const duration = this.transitionService.getTransitionDuration();
|
|
1688
|
+
const { maxWidth, maxHeight } = this.pointImage;
|
|
1576
1689
|
for (let index = 0; index < config.data.length; index++) {
|
|
1577
|
-
|
|
1690
|
+
const series = config.data[index];
|
|
1691
|
+
const points = this.svg.append('g')
|
|
1578
1692
|
.attr('class', 'dots')
|
|
1579
1693
|
.attr('clip-path', `url(#${this.clipPathId})`) // <-- apply clip
|
|
1580
|
-
.
|
|
1581
|
-
.
|
|
1582
|
-
.
|
|
1583
|
-
.
|
|
1584
|
-
.attr('
|
|
1585
|
-
|
|
1586
|
-
})
|
|
1587
|
-
.attr('cx', (d, i) => {
|
|
1588
|
-
return getXFormat(config.xFormat, d, i, this.scales.x);
|
|
1589
|
-
})
|
|
1590
|
-
.attr('cy', (_) => {
|
|
1591
|
-
return this.scales.y(0);
|
|
1592
|
-
})
|
|
1593
|
-
.attr('fill', '#fff')
|
|
1694
|
+
.attr('style', series.hide ? 'display: none' : null)
|
|
1695
|
+
.selectAll('.point')
|
|
1696
|
+
.data(series.data)
|
|
1697
|
+
.enter().append('g')
|
|
1698
|
+
.attr('class', 'point')
|
|
1699
|
+
.attr('transform', (d, i) => this.pointTransform(d, i, this.scales.x))
|
|
1594
1700
|
.on('mouseover', function (event, d) {
|
|
1595
1701
|
self.tooltipBuilder.showBarTooltip(event, d, self.config.yFormat, self.config.xFormat);
|
|
1596
|
-
|
|
1702
|
+
// No-op for an image point (no circle inside to grow).
|
|
1703
|
+
select$1(this).select('.dot')
|
|
1597
1704
|
.transition()
|
|
1598
|
-
.duration(
|
|
1705
|
+
.duration(duration / 3)
|
|
1599
1706
|
.attr('r', 6)
|
|
1600
1707
|
.attr('fill', self.colors[index]);
|
|
1601
1708
|
})
|
|
1602
1709
|
.on('mouseout', function () {
|
|
1603
1710
|
self.tooltipBuilder.hideTooltip();
|
|
1604
|
-
select$1(this)
|
|
1711
|
+
select$1(this).select('.dot')
|
|
1605
1712
|
.transition()
|
|
1606
|
-
.duration(
|
|
1713
|
+
.duration(duration / 3)
|
|
1607
1714
|
.attr('r', 4)
|
|
1608
1715
|
.attr('fill', '#fff');
|
|
1609
1716
|
})
|
|
1610
1717
|
.on('click', (_event, d) => {
|
|
1611
1718
|
this.dotClickedSource.next(d);
|
|
1612
|
-
})
|
|
1719
|
+
});
|
|
1720
|
+
points.filter((d) => !d.image)
|
|
1721
|
+
.append('circle')
|
|
1722
|
+
.attr('class', 'dot')
|
|
1723
|
+
.attr('stroke', this.colors[index])
|
|
1724
|
+
.attr('cy', this.scales.y(0))
|
|
1725
|
+
.attr('fill', '#fff')
|
|
1613
1726
|
.transition()
|
|
1614
|
-
.duration(
|
|
1615
|
-
.attr('cy', (d) =>
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1727
|
+
.duration(duration)
|
|
1728
|
+
.attr('cy', (d) => this.scales.y(d.value))
|
|
1729
|
+
.attr('r', 4);
|
|
1730
|
+
// `preserveAspectRatio="xMidYMid meet"` is what does the "resize to fit" - the image is
|
|
1731
|
+
// scaled uniformly to fit inside the maxWidth x maxHeight box and centered within it, so
|
|
1732
|
+
// a non-square image still lands centered on the point. x/y offset by half the box so the
|
|
1733
|
+
// box (not its top-left corner) is centered on the data point, matching where a dot sits.
|
|
1734
|
+
points.filter((d) => !!d.image)
|
|
1735
|
+
.append('image')
|
|
1736
|
+
.attr('class', 'dot-image')
|
|
1737
|
+
.attr('href', (d) => d.image)
|
|
1738
|
+
.attr('width', maxWidth)
|
|
1739
|
+
.attr('height', maxHeight)
|
|
1740
|
+
.attr('preserveAspectRatio', 'xMidYMid meet')
|
|
1741
|
+
.attr('x', -maxWidth / 2)
|
|
1742
|
+
.attr('y', this.scales.y(0) - maxHeight / 2)
|
|
1743
|
+
.transition()
|
|
1744
|
+
.duration(duration)
|
|
1745
|
+
.attr('y', (d) => this.scales.y(d.value) - maxHeight / 2);
|
|
1620
1746
|
}
|
|
1621
1747
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1748
|
+
pointTransform(d, i, xScale) {
|
|
1749
|
+
return `translate(${getXFormat(this.config.xFormat, d, i, xScale)}, 0)`;
|
|
1750
|
+
}
|
|
1751
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
1752
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder });
|
|
1624
1753
|
}
|
|
1625
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1754
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder, decorators: [{
|
|
1626
1755
|
type: Injectable
|
|
1627
1756
|
}] });
|
|
1628
1757
|
|
|
@@ -1632,7 +1761,8 @@ class PcacLineAreaChartComponent {
|
|
|
1632
1761
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1633
1762
|
type = input.required(/* @ts-ignore */
|
|
1634
1763
|
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
1635
|
-
chartElm = viewChild.required('chart'
|
|
1764
|
+
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
1765
|
+
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
1636
1766
|
dotClicked = outputFromObservable(this.chartBuilder.dotClicked$);
|
|
1637
1767
|
constructor() {
|
|
1638
1768
|
// Reacts to config()/type() the same way ngOnChanges used to — reading them here (rather
|
|
@@ -1657,12 +1787,12 @@ class PcacLineAreaChartComponent {
|
|
|
1657
1787
|
this.chartBuilder.buildChart(this.chartElm(), config, this.type());
|
|
1658
1788
|
}
|
|
1659
1789
|
}
|
|
1660
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1661
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.
|
|
1790
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1791
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.6", type: PcacLineAreaChartComponent, isStandalone: true, selector: "pcac-line-area-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { dotClicked: "dotClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, providers: [PlaChartBuilder, PlaChartEffectsBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}.pcac-d3-tooltip{position:absolute;text-align:center;font-size:14px;padding:.5rem;pointer-events:none;display:none;background-color:#000000bf;color:#fff;border-radius:5px}pcac-line-chart.pcac-height-full,pcac-area-chart.pcac-height-full,pcac-plot-chart.pcac-height-full,pcac-line-area-chart.pcac-height-full{display:block;height:100%}pcac-line-area-chart.pcac-height-full .pcac-line-area-chart{height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
1662
1792
|
}
|
|
1663
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1793
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, decorators: [{
|
|
1664
1794
|
type: Component,
|
|
1665
|
-
args: [{ selector: 'pcac-line-area-chart', encapsulation: ViewEncapsulation.None, providers: [PlaChartBuilder, PlaChartEffectsBuilder], template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}.pcac-d3-tooltip{position:absolute;text-align:center;font-size:14px;padding:.5rem;pointer-events:none;display:none;background-color:#000000bf;color:#fff;border-radius:5px}\n"] }]
|
|
1795
|
+
args: [{ selector: 'pcac-line-area-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, encapsulation: ViewEncapsulation.None, providers: [PlaChartBuilder, PlaChartEffectsBuilder], template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}.pcac-d3-tooltip{position:absolute;text-align:center;font-size:14px;padding:.5rem;pointer-events:none;display:none;background-color:#000000bf;color:#fff;border-radius:5px}pcac-line-chart.pcac-height-full,pcac-area-chart.pcac-height-full,pcac-plot-chart.pcac-height-full,pcac-line-area-chart.pcac-height-full{display:block;height:100%}pcac-line-area-chart.pcac-height-full .pcac-line-area-chart{height:100%}\n"] }]
|
|
1666
1796
|
}], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], chartElm: [{ type: i0.ViewChild, args: ['chart', { isSignal: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
1667
1797
|
|
|
1668
1798
|
class PcacPlotChart {
|
|
@@ -1670,12 +1800,12 @@ class PcacPlotChart {
|
|
|
1670
1800
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1671
1801
|
types = PcacLineAreaPlotChartConfigType;
|
|
1672
1802
|
dotClicked = output();
|
|
1673
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1674
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.
|
|
1803
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPlotChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1804
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.6", type: PcacPlotChart, isStandalone: true, selector: "pcac-plot-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { dotClicked: "dotClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, ngImport: i0, template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Plot\" (dotClicked)=\"dotClicked.emit($event)\"/>", dependencies: [{ kind: "component", type: PcacLineAreaChartComponent, selector: "pcac-line-area-chart", inputs: ["config", "type"], outputs: ["dotClicked"] }] });
|
|
1675
1805
|
}
|
|
1676
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1806
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPlotChart, decorators: [{
|
|
1677
1807
|
type: Component,
|
|
1678
|
-
args: [{ selector: 'pcac-plot-chart', imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Plot\" (dotClicked)=\"dotClicked.emit($event)\"/>" }]
|
|
1808
|
+
args: [{ selector: 'pcac-plot-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Plot\" (dotClicked)=\"dotClicked.emit($event)\"/>" }]
|
|
1679
1809
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
1680
1810
|
|
|
1681
1811
|
class PcacPlotChartConfig extends PcacLineAreaChartConfig {
|
|
@@ -1686,12 +1816,12 @@ class PcacLineChart {
|
|
|
1686
1816
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1687
1817
|
types = PcacLineAreaPlotChartConfigType;
|
|
1688
1818
|
dotClicked = output();
|
|
1689
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1690
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.
|
|
1819
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1820
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.6", type: PcacLineChart, isStandalone: true, selector: "pcac-line-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { dotClicked: "dotClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, ngImport: i0, template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Line\" />", dependencies: [{ kind: "component", type: PcacLineAreaChartComponent, selector: "pcac-line-area-chart", inputs: ["config", "type"], outputs: ["dotClicked"] }] });
|
|
1691
1821
|
}
|
|
1692
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1822
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineChart, decorators: [{
|
|
1693
1823
|
type: Component,
|
|
1694
|
-
args: [{ selector: 'pcac-line-chart', imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Line\" />" }]
|
|
1824
|
+
args: [{ selector: 'pcac-line-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Line\" />" }]
|
|
1695
1825
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
1696
1826
|
|
|
1697
1827
|
class PcacLineChartConfig extends PcacLineAreaChartConfig {
|
|
@@ -1702,12 +1832,12 @@ class PcacAreaChart {
|
|
|
1702
1832
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1703
1833
|
types = PcacLineAreaPlotChartConfigType;
|
|
1704
1834
|
dotClicked = output();
|
|
1705
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1706
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.
|
|
1835
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAreaChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1836
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.6", type: PcacAreaChart, isStandalone: true, selector: "pcac-area-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { dotClicked: "dotClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, ngImport: i0, template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Area\" />", dependencies: [{ kind: "component", type: PcacLineAreaChartComponent, selector: "pcac-line-area-chart", inputs: ["config", "type"], outputs: ["dotClicked"] }] });
|
|
1707
1837
|
}
|
|
1708
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1838
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAreaChart, decorators: [{
|
|
1709
1839
|
type: Component,
|
|
1710
|
-
args: [{ selector: 'pcac-area-chart', imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Area\" />" }]
|
|
1840
|
+
args: [{ selector: 'pcac-area-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Area\" />" }]
|
|
1711
1841
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
1712
1842
|
|
|
1713
1843
|
class PcacAreaChartConfig extends PcacLineAreaChartConfig {
|
|
@@ -1716,6 +1846,9 @@ class PcacAreaChartConfig extends PcacLineAreaChartConfig {
|
|
|
1716
1846
|
// export * from './plot-line-area-chart.builder';
|
|
1717
1847
|
// export * from './plot-line-area-chart.component';
|
|
1718
1848
|
// export * from './plot-line-area-chart.model';
|
|
1849
|
+
// The rest of that model stays internal (the shared PcacLineAreaChartConfig is reached through
|
|
1850
|
+
// the per-chart PcacLineChartConfig/PcacAreaChartConfig/PcacPlotChartConfig subclasses), but
|
|
1851
|
+
// the point-image sizing type is part of those configs' public shape, so it's exported alone.
|
|
1719
1852
|
|
|
1720
1853
|
/**
|
|
1721
1854
|
* Provided per-component (see PcacPieChartComponent's `providers`), not root-scoped:
|
|
@@ -1734,14 +1867,19 @@ class PieChartBuilder extends PcacChart {
|
|
|
1734
1867
|
if (!config?.data?.length) {
|
|
1735
1868
|
return;
|
|
1736
1869
|
}
|
|
1737
|
-
|
|
1870
|
+
// The pie deliberately opts out of `heightFull`: `height` here feeds the radius rather than a
|
|
1871
|
+
// drawing area, so growing into a tall container would silently change the size of the pie
|
|
1872
|
+
// itself. `PcacPieChartConfig` inherits the property from PcacChartConfig, so it's neutralized
|
|
1873
|
+
// here rather than being absent from the type. (`<pcac-pie-chart>` also never gets the
|
|
1874
|
+
// `pcac-height-full` class the other charts use to stretch their host.)
|
|
1875
|
+
if (!this.initializeChartState(chartElm, { ...config, heightFull: false })) {
|
|
1738
1876
|
return;
|
|
1739
1877
|
}
|
|
1740
1878
|
this.radius = Math.min(Math.min(this.height, this.width), Math.min(this.height, this.width)) / 2;
|
|
1741
|
-
this.buildShapes(
|
|
1879
|
+
this.buildShapes();
|
|
1742
1880
|
this.drawChart(chartElm, config);
|
|
1743
1881
|
}
|
|
1744
|
-
buildShapes(
|
|
1882
|
+
buildShapes() {
|
|
1745
1883
|
const radiusOffset = 10;
|
|
1746
1884
|
this.arcShape = arc()
|
|
1747
1885
|
.innerRadius(0)
|
|
@@ -1799,10 +1937,10 @@ class PieChartBuilder extends PcacChart {
|
|
|
1799
1937
|
const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
|
|
1800
1938
|
return (t) => this.arcShape(i(t)) ?? '';
|
|
1801
1939
|
}
|
|
1802
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1803
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
1940
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PieChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
1941
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PieChartBuilder });
|
|
1804
1942
|
}
|
|
1805
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1943
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PieChartBuilder, decorators: [{
|
|
1806
1944
|
type: Injectable
|
|
1807
1945
|
}] });
|
|
1808
1946
|
|
|
@@ -1810,7 +1948,8 @@ class PcacPieChartComponent {
|
|
|
1810
1948
|
chartBuilder = inject(PieChartBuilder);
|
|
1811
1949
|
config = input.required(/* @ts-ignore */
|
|
1812
1950
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1813
|
-
chartElm = viewChild.required('chart'
|
|
1951
|
+
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
1952
|
+
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
1814
1953
|
sliceClicked = outputFromObservable(this.chartBuilder.sliceClicked$);
|
|
1815
1954
|
constructor() {
|
|
1816
1955
|
// Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
|
|
@@ -1832,10 +1971,10 @@ class PcacPieChartComponent {
|
|
|
1832
1971
|
this.chartBuilder.buildChart(this.chartElm(), config);
|
|
1833
1972
|
}
|
|
1834
1973
|
}
|
|
1835
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
1836
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.
|
|
1974
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1975
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.6", type: PcacPieChartComponent, isStandalone: true, selector: "pcac-pie-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { sliceClicked: "sliceClicked" }, providers: [PieChartBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-pie-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-pie-chart svg{width:100%;display:block}.pcac-pie-chart .dot{fill:none;stroke-width:1px}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
1837
1976
|
}
|
|
1838
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
1977
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPieChartComponent, decorators: [{
|
|
1839
1978
|
type: Component,
|
|
1840
1979
|
args: [{ selector: 'pcac-pie-chart', encapsulation: ViewEncapsulation.None, providers: [PieChartBuilder], template: "<section class=\"pcac-pie-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-pie-chart svg{width:100%;display:block}.pcac-pie-chart .dot{fill:none;stroke-width:1px}\n"] }]
|
|
1841
1980
|
}], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], chartElm: [{ type: i0.ViewChild, args: ['chart', { isSignal: true }] }], sliceClicked: [{ type: i0.Output, args: ["sliceClicked"] }] } });
|
|
@@ -1852,5 +1991,5 @@ class PcacPieChartConfig extends PcacChartConfig {
|
|
|
1852
1991
|
* Generated bundle index. Do not edit.
|
|
1853
1992
|
*/
|
|
1854
1993
|
|
|
1855
|
-
export { BarHorizontalChartBuilder, BarVerticalChartBuilder, PcacAreaChart, PcacAreaChartConfig, PcacAxisBuilder, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChart, PcacChartConfig, PcacChartResizeService, PcacColorService, PcacData, PcacFormatEnum, PcacGridBuilder, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacTooltipBuilder, PcacTransitionService, PieChartBuilder };
|
|
1994
|
+
export { BarHorizontalChartBuilder, BarVerticalChartBuilder, PcacAreaChart, PcacAreaChartConfig, PcacAxisBuilder, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChart, PcacChartConfig, PcacChartResizeService, PcacColorService, PcacData, PcacFormatEnum, PcacGridBuilder, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointImageConfig, PcacTooltipBuilder, PcacTransitionService, PieChartBuilder };
|
|
1856
1995
|
//# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map
|