@pioneer-code/pioneer-charts 22.1.0 → 22.1.3
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 +28 -50
- package/fesm2022/pioneer-code-pioneer-charts.mjs +482 -140
- package/fesm2022/pioneer-code-pioneer-charts.mjs.map +1 -1
- package/package.json +1 -1
- package/scss/bar-chart/bar-horizontal-chart/bar-horizontal-chart.component.scss +0 -12
- package/scss/pioneer-charts.scss +10 -3
- package/scss/plot-line-area-chart/plot-line-area-chart.component.scss +0 -12
- package/themes/pioneer-charts.css +6 -3
- package/themes/pioneer-charts.min.css +1 -1
- package/types/pioneer-code-pioneer-charts.d.ts +206 -38
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, inject, DestroyRef, afterNextRender, input, viewChild, effect, ViewEncapsulation, Component, model, output, computed } from '@angular/core';
|
|
2
|
+
import { Injectable, inject, ApplicationRef, DestroyRef, afterNextRender, TemplateRef, Directive, input, viewChild, contentChild, effect, ViewEncapsulation, Component, model, output, computed } from '@angular/core';
|
|
3
3
|
import { color } from 'd3-color';
|
|
4
4
|
import { scaleLinear, scaleBand } from 'd3-scale';
|
|
5
5
|
import { select as select$1 } from 'd3-selection';
|
|
@@ -45,6 +45,16 @@ class PcacData {
|
|
|
45
45
|
value = null;
|
|
46
46
|
hide = false;
|
|
47
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;
|
|
48
58
|
}
|
|
49
59
|
var PcacFormatEnum;
|
|
50
60
|
(function (PcacFormatEnum) {
|
|
@@ -73,7 +83,7 @@ class PcacAxisBuilder {
|
|
|
73
83
|
return;
|
|
74
84
|
const yAxis = axisLeft(config.yScale).ticks(config.numberOfTicks);
|
|
75
85
|
if (config.yFormat) {
|
|
76
|
-
switch (config.yFormat
|
|
86
|
+
switch (config.yFormat) {
|
|
77
87
|
case PcacFormatEnum.Percentage:
|
|
78
88
|
yAxis.tickFormat(d => d + "%");
|
|
79
89
|
break;
|
|
@@ -103,7 +113,7 @@ class PcacAxisBuilder {
|
|
|
103
113
|
xAxis.tickFormat((d) => d + 'm');
|
|
104
114
|
break;
|
|
105
115
|
case PcacFormatEnum.Fahrenheit:
|
|
106
|
-
xAxis.tickFormat((d) => d + '
|
|
116
|
+
xAxis.tickFormat((d) => d + ' F');
|
|
107
117
|
break;
|
|
108
118
|
case PcacFormatEnum.OneDayHours:
|
|
109
119
|
xAxis.tickFormat((d) => {
|
|
@@ -139,7 +149,7 @@ class PcacGridBuilder {
|
|
|
139
149
|
config.svg.append('g')
|
|
140
150
|
.attr('class', 'pcac-grid')
|
|
141
151
|
.selectAll('g.rule')
|
|
142
|
-
.data(xScale.ticks(
|
|
152
|
+
.data(xScale.ticks(config.numberOfTicks))
|
|
143
153
|
.enter().append('svg:g')
|
|
144
154
|
.attr('class', 'pcac-grid-rule')
|
|
145
155
|
.attr('transform', (d) => (`translate(${xScale(d)}, 0)`))
|
|
@@ -259,17 +269,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
259
269
|
}] });
|
|
260
270
|
|
|
261
271
|
class PcacTooltipBuilder {
|
|
272
|
+
appRef = inject(ApplicationRef);
|
|
273
|
+
/**
|
|
274
|
+
* One tooltip element shared by every chart on the page, appended to `<body>` so it can float
|
|
275
|
+
* over anything. It's only ever a positioning shell: the default look (`.pcac-d3-tooltip-default`)
|
|
276
|
+
* is toggled on when the library renders its own key/value content and off when a consumer's
|
|
277
|
+
* `<ng-template pcacTooltip>` is rendered into it instead, so a custom template owns the whole box.
|
|
278
|
+
*/
|
|
262
279
|
tooltip = select('body')
|
|
263
280
|
.append('div')
|
|
264
281
|
.attr('class', 'pcac-d3-tooltip');
|
|
282
|
+
/**
|
|
283
|
+
* The consumer template currently rendered into the shell, if any. Created on the first show
|
|
284
|
+
* of a hover and torn down in `hideTooltip()` - not kept around between hovers - so a view is
|
|
285
|
+
* never left holding onto a declaring component that has since been destroyed (e.g. after a
|
|
286
|
+
* route change). While it lives, repeated `mousemove`s just update its context in place.
|
|
287
|
+
*/
|
|
288
|
+
view = null;
|
|
289
|
+
viewTemplate = null;
|
|
290
|
+
/**
|
|
291
|
+
* Shows the tooltip for a hovered datum at the event's position. Renders `template` when the
|
|
292
|
+
* chart has one projected; otherwise falls back to the default key/value content, formatted per
|
|
293
|
+
* `valueFormat`/`keyFormat`.
|
|
294
|
+
*/
|
|
295
|
+
showTooltip(event, template, context, valueFormat, keyFormat) {
|
|
296
|
+
if (template) {
|
|
297
|
+
this.renderTemplate(template, context);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
this.renderDefault(context.$implicit, valueFormat, keyFormat);
|
|
301
|
+
}
|
|
302
|
+
this.position(event);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* @deprecated Builders should call `PcacChart.showTooltip()`, which routes through a chart's
|
|
306
|
+
* projected `pcacTooltip` template. This only ever renders the default content.
|
|
307
|
+
*/
|
|
265
308
|
showBarTooltip(event, data, valueFormat, keyFormat) {
|
|
266
|
-
this.
|
|
267
|
-
.style('top', event.pageY - 55 + 'px')
|
|
268
|
-
.style('display', 'inline-block')
|
|
269
|
-
.html(this.getBarTipData(data, valueFormat, keyFormat));
|
|
309
|
+
this.showTooltip(event, undefined, { $implicit: data, parent: null, isThreshold: false }, valueFormat, keyFormat);
|
|
270
310
|
}
|
|
271
311
|
hideTooltip() {
|
|
272
312
|
this.tooltip.style('display', 'none');
|
|
313
|
+
this.destroyView();
|
|
314
|
+
}
|
|
315
|
+
renderDefault(data, valueFormat, keyFormat) {
|
|
316
|
+
this.destroyView();
|
|
317
|
+
this.tooltip
|
|
318
|
+
.classed('pcac-d3-tooltip-default', true)
|
|
319
|
+
.html(this.getBarTipData(data, valueFormat, keyFormat));
|
|
320
|
+
}
|
|
321
|
+
renderTemplate(template, context) {
|
|
322
|
+
if (this.view && this.viewTemplate === template) {
|
|
323
|
+
// Same hover, new mouse position/datum: keep the view and just refresh what it's bound to.
|
|
324
|
+
Object.assign(this.view.context, context);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
this.destroyView();
|
|
328
|
+
this.tooltip.classed('pcac-d3-tooltip-default', false).html(null);
|
|
329
|
+
// Same technique as the CDK's DomPortalOutlet: create the view off-tree, attach it to the
|
|
330
|
+
// app so it takes part in change detection (a template reading a signal keeps updating
|
|
331
|
+
// while shown), then physically move its nodes into the shell. The view's own injector is
|
|
332
|
+
// the declaring component's, so pipes/DI in the template resolve as they would in place.
|
|
333
|
+
this.view = template.createEmbeddedView(context);
|
|
334
|
+
this.viewTemplate = template;
|
|
335
|
+
this.appRef.attachView(this.view);
|
|
336
|
+
const shell = this.tooltip.node();
|
|
337
|
+
for (const node of this.view.rootNodes) {
|
|
338
|
+
shell.appendChild(node);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// The trigger is a D3-native mouse listener, which nothing in Angular observes under zoneless
|
|
342
|
+
// change detection, so the view has to be checked explicitly for the new context to render
|
|
343
|
+
// before it's measured for positioning.
|
|
344
|
+
this.view.detectChanges();
|
|
345
|
+
}
|
|
346
|
+
destroyView() {
|
|
347
|
+
if (!this.view) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
// `destroy()` also detaches the view from the ApplicationRef it was attached to, but it
|
|
351
|
+
// doesn't pull the nodes we moved into the shell back out of the DOM - that's what a
|
|
352
|
+
// ViewContainerRef would normally do on removal - so the shell is emptied here explicitly.
|
|
353
|
+
this.view.destroy();
|
|
354
|
+
this.view = null;
|
|
355
|
+
this.viewTemplate = null;
|
|
356
|
+
this.tooltip.html(null);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Centers the (already rendered) tooltip horizontally on the cursor and sits it just above.
|
|
360
|
+
* Measured from the real box rather than fixed offsets so it works for content of any size.
|
|
361
|
+
*/
|
|
362
|
+
position(event) {
|
|
363
|
+
const shell = this.tooltip.style('display', 'inline-block').node();
|
|
364
|
+
this.tooltip
|
|
365
|
+
.style('left', event.pageX - shell.offsetWidth / 2 + 'px')
|
|
366
|
+
.style('top', event.pageY - shell.offsetHeight - 8 + 'px');
|
|
273
367
|
}
|
|
274
368
|
getBarTipData(data, valueFormat, keyFormat) {
|
|
275
369
|
let value = data.value;
|
|
@@ -299,7 +393,7 @@ class PcacTooltipBuilder {
|
|
|
299
393
|
}
|
|
300
394
|
}
|
|
301
395
|
const finalValue = value ? value.toString() : value;
|
|
302
|
-
return key ? key + '
|
|
396
|
+
return key ? key + '<br>' + finalValue : `${finalValue}`;
|
|
303
397
|
}
|
|
304
398
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
305
399
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, providedIn: 'root' });
|
|
@@ -318,6 +412,7 @@ class PcacChart {
|
|
|
318
412
|
tooltipBuilder = inject(PcacTooltipBuilder);
|
|
319
413
|
colorService = inject(PcacColorService);
|
|
320
414
|
margin = { top: 8, right: 16, bottom: 20, left: 40 };
|
|
415
|
+
defaultMargin = { ...this.margin };
|
|
321
416
|
svg;
|
|
322
417
|
width = 400;
|
|
323
418
|
height = 400;
|
|
@@ -339,6 +434,35 @@ class PcacChart {
|
|
|
339
434
|
*/
|
|
340
435
|
lastContainerHeight = null;
|
|
341
436
|
lastHeightFull = false;
|
|
437
|
+
/**
|
|
438
|
+
* Resolves the consumer's projected `<ng-template pcacTooltip>`, if any. Each chart component
|
|
439
|
+
* points this at its own `contentChild(PcacTooltipDirective)` query. It's a getter rather than
|
|
440
|
+
* a captured value so it's read lazily, at hover time, from inside a D3 listener: reading the
|
|
441
|
+
* query signal in the component's build effect instead would make the effect depend on it and
|
|
442
|
+
* rebuild the whole chart (restarting its entry animation) whenever the query resolves.
|
|
443
|
+
*/
|
|
444
|
+
tooltipTemplate = () => undefined;
|
|
445
|
+
/**
|
|
446
|
+
* Puts `margin` back to its defaults. Builders must call this at the top of `buildChart()`,
|
|
447
|
+
* before any per-build adjustment (`hideAxis` zeroing sides, label widths measured into
|
|
448
|
+
* `margin.left`): `margin` lives on this per-chart instance and so persists between builds,
|
|
449
|
+
* and without a reset an adjustment made for one config silently carries into the next -
|
|
450
|
+
* e.g. axes drawn with no room after `hideAxis` flips back to false.
|
|
451
|
+
*/
|
|
452
|
+
resetMargin() {
|
|
453
|
+
this.margin = { ...this.defaultMargin };
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Shows the tooltip for a hovered datum, through the chart's `pcacTooltip` template when one is
|
|
457
|
+
* projected and the default key/value content otherwise. Every builder's hover handler should
|
|
458
|
+
* go through here rather than `tooltipBuilder` directly so the template is honored everywhere.
|
|
459
|
+
*/
|
|
460
|
+
showTooltip(event, data, options = {}) {
|
|
461
|
+
this.tooltipBuilder.showTooltip(event, this.tooltipTemplate(), { $implicit: data, parent: options.parent ?? null, isThreshold: options.isThreshold ?? false }, options.valueFormat, options.keyFormat);
|
|
462
|
+
}
|
|
463
|
+
hideTooltip() {
|
|
464
|
+
this.tooltipBuilder.hideTooltip();
|
|
465
|
+
}
|
|
342
466
|
/**
|
|
343
467
|
* Prior to building a chart, we need to initialize the state of the chart.
|
|
344
468
|
*
|
|
@@ -461,11 +585,36 @@ class PcacChart {
|
|
|
461
585
|
}
|
|
462
586
|
})
|
|
463
587
|
.remove();
|
|
588
|
+
// `width` was already computed net of the current `margin.left` by initializeChartState(),
|
|
589
|
+
// so only the *change* in margin comes out of it. Subtracting the whole measured margin
|
|
590
|
+
// double-counted it, and since `margin` persists on the builder between builds, the amount
|
|
591
|
+
// double-counted grew on the next rebuild - the plot area came out narrower than the
|
|
592
|
+
// container allowed and then shrank further after the first resize.
|
|
593
|
+
this.width = this.width + this.margin.left - max;
|
|
464
594
|
this.margin.left = max;
|
|
465
|
-
this.width = this.width - this.margin.left;
|
|
466
595
|
}
|
|
467
596
|
}
|
|
468
597
|
|
|
598
|
+
/**
|
|
599
|
+
* Where each bar of a stacked group starts: the running total of the bars before it, in data
|
|
600
|
+
* order, so the first bar sits on the baseline and each later one on top of the previous. Values
|
|
601
|
+
* are the bar's *own* size (segment), not a pre-accumulated total; a null value counts as 0.
|
|
602
|
+
*
|
|
603
|
+
* Keyed by the bar's own `PcacData` object so D3 callbacks (which only get the datum) can look
|
|
604
|
+
* their offset up directly.
|
|
605
|
+
*/
|
|
606
|
+
function stackStarts(groups) {
|
|
607
|
+
const starts = new Map();
|
|
608
|
+
for (const group of groups) {
|
|
609
|
+
let total = 0;
|
|
610
|
+
for (const bar of group.data) {
|
|
611
|
+
starts.set(bar, total);
|
|
612
|
+
total += Number(bar.value ?? 0);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return starts;
|
|
616
|
+
}
|
|
617
|
+
|
|
469
618
|
/**
|
|
470
619
|
* Provided per-component (see PcacBarHorizontalChartComponent's `providers`), not root-scoped:
|
|
471
620
|
* this builder extends PcacChart, which holds mutable per-chart-instance state (margin, width,
|
|
@@ -478,30 +627,28 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
478
627
|
yScaleGrouped;
|
|
479
628
|
barClickedSource = new Subject();
|
|
480
629
|
config;
|
|
481
|
-
cachedMargins;
|
|
482
630
|
barClicked$ = this.barClickedSource.asObservable();
|
|
483
631
|
buildChart(chartElm, config) {
|
|
484
632
|
if (!config?.data?.length) {
|
|
485
633
|
return;
|
|
486
634
|
}
|
|
487
635
|
this.config = JSON.parse(JSON.stringify(config));
|
|
636
|
+
this.resetMargin();
|
|
488
637
|
if (this.config.hideAxis) {
|
|
489
638
|
this.adjustForHiddenAxis();
|
|
490
639
|
}
|
|
491
640
|
if (!this.initializeChartState(chartElm, this.config)) {
|
|
492
641
|
return;
|
|
493
642
|
}
|
|
643
|
+
// Copy before reversing: `.reverse()` is in place, and this is the consumer's own array -
|
|
644
|
+
// reversing it directly flipped their palette on every rebuild (i.e. every resize).
|
|
494
645
|
if (config.colorOverride && config.colorOverride.colors) {
|
|
495
|
-
this.colors = config.colorOverride.colors.reverse();
|
|
646
|
+
this.colors = [...config.colorOverride.colors].reverse();
|
|
496
647
|
}
|
|
497
648
|
this.buildScales(chartElm, this.config);
|
|
498
649
|
this.drawChart(chartElm, this.config);
|
|
499
650
|
}
|
|
500
651
|
adjustForHiddenAxis() {
|
|
501
|
-
if (!this.cachedMargins) {
|
|
502
|
-
this.cachedMargins = JSON.parse(JSON.stringify(this.margin));
|
|
503
|
-
}
|
|
504
|
-
this.margin = JSON.parse(JSON.stringify(this.cachedMargins));
|
|
505
652
|
this.config.height = this.config.height + this.margin.top + this.margin.bottom;
|
|
506
653
|
this.margin.top = 0;
|
|
507
654
|
this.margin.bottom = 0;
|
|
@@ -584,9 +731,14 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
584
731
|
}
|
|
585
732
|
drawBarsPerGroup(groups, config) {
|
|
586
733
|
const self = this;
|
|
734
|
+
// Stacked bars start where the previous bar in their group ends; every other layout draws
|
|
735
|
+
// from the baseline (start 0).
|
|
736
|
+
const starts = config.isStacked ? stackStarts(config.data) : new Map();
|
|
737
|
+
const startOf = (d) => starts.get(d) ?? 0;
|
|
738
|
+
const endOf = (d) => startOf(d) + Number(d.value ?? 0);
|
|
587
739
|
groups.enter().append('rect')
|
|
588
740
|
.attr('class', 'pcac-bar')
|
|
589
|
-
.attr('x',
|
|
741
|
+
.attr('x', (d) => this.xScale(startOf(d)))
|
|
590
742
|
.attr('y', (d) => {
|
|
591
743
|
const value = !config.isStacked ? this.yScaleGrouped(d.key) : this.yScaleStacked(d.key);
|
|
592
744
|
return value ? value : 0;
|
|
@@ -620,11 +772,12 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
620
772
|
return ct;
|
|
621
773
|
});
|
|
622
774
|
})
|
|
623
|
-
.on('mousemove', (event, d)
|
|
624
|
-
|
|
775
|
+
.on('mousemove', function (event, d) {
|
|
776
|
+
const groupIndex = Number(this.parentNode.getAttribute('data-group-id'));
|
|
777
|
+
self.showTooltip(event, d, { parent: config.data[groupIndex], valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
625
778
|
})
|
|
626
779
|
.on('mouseout', function () {
|
|
627
|
-
self.
|
|
780
|
+
self.hideTooltip();
|
|
628
781
|
select$1(this)
|
|
629
782
|
.transition()
|
|
630
783
|
.duration(self.transitionService.getTransitionDuration() / 5)
|
|
@@ -643,7 +796,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
643
796
|
.transition()
|
|
644
797
|
.duration(this.transitionService.getTransitionDuration())
|
|
645
798
|
.attr('width', (d) => {
|
|
646
|
-
return this.xScale(d.
|
|
799
|
+
return this.xScale(endOf(d)) - this.xScale(startOf(d));
|
|
647
800
|
});
|
|
648
801
|
}
|
|
649
802
|
drawThresholdAcrossChart(config) {
|
|
@@ -652,8 +805,8 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
652
805
|
.attr('data-group-threshold-id', (_, i) => {
|
|
653
806
|
return i;
|
|
654
807
|
})
|
|
655
|
-
.on('mousemove', (event
|
|
656
|
-
this.
|
|
808
|
+
.on('mousemove', (event) => {
|
|
809
|
+
this.showTooltip(event, config.thresholds[0], { isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
657
810
|
})
|
|
658
811
|
.transition()
|
|
659
812
|
.duration(this.transitionService.getTransitionDuration())
|
|
@@ -670,9 +823,10 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
670
823
|
})
|
|
671
824
|
.on('mousemove', function (event) {
|
|
672
825
|
const index = Number(this.parentElement.dataset['groupId']);
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
826
|
+
const threshold = config.thresholds[index];
|
|
827
|
+
// A threshold's own PcacData is typically just a value, so its parent is the *data* group
|
|
828
|
+
// it's drawn against (which has the key) rather than the threshold entry it came from.
|
|
829
|
+
self.showTooltip(event, config.isStacked ? threshold.data[0] : threshold, { parent: config.data[index], isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
676
830
|
})
|
|
677
831
|
.transition()
|
|
678
832
|
.duration(this.transitionService.getTransitionDuration())
|
|
@@ -690,7 +844,9 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
690
844
|
.on('mousemove', function (event) {
|
|
691
845
|
const target = event.target;
|
|
692
846
|
const index = Number(target.getAttribute("data-group-threshold-id"));
|
|
693
|
-
|
|
847
|
+
const groupIndex = Number(this.parentElement.dataset['groupId']);
|
|
848
|
+
// Parent is the data group (see drawThresholdsPerGroup), not the threshold entry itself.
|
|
849
|
+
self.showTooltip(event, config.thresholds[groupIndex].data[index], { parent: config.data[groupIndex], isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
694
850
|
})
|
|
695
851
|
.transition()
|
|
696
852
|
.duration(this.transitionService.getTransitionDuration())
|
|
@@ -715,7 +871,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
715
871
|
})
|
|
716
872
|
.attr('width', '3px')
|
|
717
873
|
.on('mouseout', () => {
|
|
718
|
-
this.
|
|
874
|
+
this.hideTooltip();
|
|
719
875
|
});
|
|
720
876
|
}
|
|
721
877
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarHorizontalChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -782,6 +938,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
782
938
|
args: [{ providedIn: 'root' }]
|
|
783
939
|
}] });
|
|
784
940
|
|
|
941
|
+
/**
|
|
942
|
+
* Marks an `<ng-template>` projected into any chart component as that chart's tooltip. When
|
|
943
|
+
* present it replaces the default key/value tooltip *entirely* - the library only positions the
|
|
944
|
+
* rendered template; it applies no background, padding or text styling of its own, so the template
|
|
945
|
+
* owns the whole box.
|
|
946
|
+
*
|
|
947
|
+
* ```html
|
|
948
|
+
* <pcac-bar-vertical-chart [config]="config">
|
|
949
|
+
* <ng-template pcacTooltip let-point let-group="parent">
|
|
950
|
+
* <div class="my-tooltip">{{ group?.key }} / {{ point.key }}: {{ point.value | number }}</div>
|
|
951
|
+
* </ng-template>
|
|
952
|
+
* </pcac-bar-vertical-chart>
|
|
953
|
+
* ```
|
|
954
|
+
*
|
|
955
|
+
* The template is rendered with full Angular semantics (pipes, directives, components, DI from
|
|
956
|
+
* the declaring component), so anything a normal template can do works here too.
|
|
957
|
+
*/
|
|
958
|
+
class PcacTooltipDirective {
|
|
959
|
+
templateRef = inject(TemplateRef);
|
|
960
|
+
/**
|
|
961
|
+
* Lets the template type-checker know the shape of `let-` variables declared on the
|
|
962
|
+
* `<ng-template>`, so `point.value` etc. are checked against `PcacData` under strictTemplates.
|
|
963
|
+
*/
|
|
964
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
968
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.6", type: PcacTooltipDirective, isStandalone: true, selector: "ng-template[pcacTooltip]", ngImport: i0 });
|
|
969
|
+
}
|
|
970
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipDirective, decorators: [{
|
|
971
|
+
type: Directive,
|
|
972
|
+
args: [{
|
|
973
|
+
selector: 'ng-template[pcacTooltip]'
|
|
974
|
+
}]
|
|
975
|
+
}] });
|
|
976
|
+
|
|
785
977
|
class PcacBarHorizontalChartComponent {
|
|
786
978
|
chartBuilder = inject(BarHorizontalChartBuilder);
|
|
787
979
|
config = input.required(/* @ts-ignore */
|
|
@@ -789,11 +981,20 @@ class PcacBarHorizontalChartComponent {
|
|
|
789
981
|
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
790
982
|
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
791
983
|
barClicked = outputFromObservable(this.chartBuilder.barClicked$);
|
|
984
|
+
/**
|
|
985
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element; replaces the
|
|
986
|
+
* default tooltip when present (see PcacTooltipDirective).
|
|
987
|
+
*/
|
|
988
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
989
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
792
990
|
constructor() {
|
|
793
991
|
// Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
|
|
794
992
|
// lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
|
|
795
993
|
// reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
|
|
796
994
|
effect(() => this.buildChart());
|
|
995
|
+
// Handed over as a getter so the builder reads the query at hover time, not in the effect
|
|
996
|
+
// above (see PcacChart.tooltipTemplate).
|
|
997
|
+
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate()?.templateRef;
|
|
797
998
|
inject(PcacChartResizeService).observe(this.chartElm, () => {
|
|
798
999
|
// Skip the ResizeObserver's routine initial callback when it lands after the effect above
|
|
799
1000
|
// already built successfully at this same width — only a real size change (or a build
|
|
@@ -810,12 +1011,12 @@ class PcacBarHorizontalChartComponent {
|
|
|
810
1011
|
}
|
|
811
1012
|
}
|
|
812
1013
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarHorizontalChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
813
|
-
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}
|
|
1014
|
+
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], queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], 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-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 });
|
|
814
1015
|
}
|
|
815
1016
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarHorizontalChartComponent, decorators: [{
|
|
816
1017
|
type: Component,
|
|
817
|
-
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}
|
|
818
|
-
}], 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"] }] } });
|
|
1018
|
+
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-bar-horizontal-chart.pcac-height-full{display:block;height:100%}pcac-bar-horizontal-chart.pcac-height-full .pcac-bar-horizontal-chart{height:100%}\n"] }]
|
|
1019
|
+
}], 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"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
819
1020
|
|
|
820
1021
|
class PcacBarHorizontalChartConfig extends PcacChartConfig {
|
|
821
1022
|
domainMax = 100;
|
|
@@ -848,17 +1049,20 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
848
1049
|
if (!config?.data?.length) {
|
|
849
1050
|
return;
|
|
850
1051
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
1052
|
+
// Shallow copy: adjustForHiddenAxis() rewrites `height`, and that must not land on the
|
|
1053
|
+
// consumer's own config object (it previously did, growing it by the margins on first build).
|
|
1054
|
+
config = { ...config };
|
|
1055
|
+
this.resetMargin();
|
|
854
1056
|
if (config.hideAxis) {
|
|
855
1057
|
this.adjustForHiddenAxis(config);
|
|
856
1058
|
}
|
|
857
1059
|
if (!this.initializeChartState(chartElm, config)) {
|
|
858
1060
|
return;
|
|
859
1061
|
}
|
|
1062
|
+
// Copy before reversing: `.reverse()` is in place, and this is the consumer's own array -
|
|
1063
|
+
// reversing it directly flipped their palette on every rebuild (i.e. every resize).
|
|
860
1064
|
if (config.colorOverride && config.colorOverride.colors) {
|
|
861
|
-
this.colors = config.colorOverride.colors.reverse();
|
|
1065
|
+
this.colors = [...config.colorOverride.colors].reverse();
|
|
862
1066
|
}
|
|
863
1067
|
this.buildScales(config);
|
|
864
1068
|
this.drawChart(chartElm, config);
|
|
@@ -884,8 +1088,10 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
884
1088
|
return hasGroupLabel;
|
|
885
1089
|
}
|
|
886
1090
|
buildScales(config) {
|
|
1091
|
+
// `this.height`, not `config.height`: with `heightFull` on they differ (see
|
|
1092
|
+
// PcacChart.resolveHeight), and the axis, grid and bar baselines all use the resolved one.
|
|
887
1093
|
this.yScale = scaleLinear()
|
|
888
|
-
.rangeRound([0,
|
|
1094
|
+
.rangeRound([0, this.height])
|
|
889
1095
|
.domain([config.domainMax, 0]);
|
|
890
1096
|
this.xScaleStacked = scaleBand()
|
|
891
1097
|
.domain(config.data.map((d) => d.key))
|
|
@@ -957,6 +1163,11 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
957
1163
|
}
|
|
958
1164
|
drawBarsPerGroup(group, config) {
|
|
959
1165
|
const self = this;
|
|
1166
|
+
// Stacked bars sit on top of the ones before them in their group; every other layout draws
|
|
1167
|
+
// from the baseline (start 0).
|
|
1168
|
+
const starts = config.isStacked ? stackStarts(config.data) : new Map();
|
|
1169
|
+
const startOf = (d) => starts.get(d) ?? 0;
|
|
1170
|
+
const endOf = (d) => startOf(d) + Number(d.value ?? 0);
|
|
960
1171
|
group.enter().append('rect')
|
|
961
1172
|
.attr('class', 'pcac-bar')
|
|
962
1173
|
.attr('x', (d) => {
|
|
@@ -994,11 +1205,12 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
994
1205
|
return ct;
|
|
995
1206
|
});
|
|
996
1207
|
})
|
|
997
|
-
.on('mousemove', (event, d)
|
|
998
|
-
|
|
1208
|
+
.on('mousemove', function (event, d) {
|
|
1209
|
+
const groupIndex = Number(this.parentNode.getAttribute('data-group-id'));
|
|
1210
|
+
self.showTooltip(event, d, { parent: config.data[groupIndex], valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
999
1211
|
})
|
|
1000
1212
|
.on('mouseout', function () {
|
|
1001
|
-
self.
|
|
1213
|
+
self.hideTooltip();
|
|
1002
1214
|
select$1(this)
|
|
1003
1215
|
.transition()
|
|
1004
1216
|
.duration(self.transitionService.getTransitionDuration() / 5)
|
|
@@ -1021,10 +1233,10 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1021
1233
|
// )
|
|
1022
1234
|
.attr('width', !config.isStacked ? this.xScaleGrouped.bandwidth() : this.xScaleStacked.bandwidth())
|
|
1023
1235
|
.attr('y', (d) => {
|
|
1024
|
-
return this.yScale(d
|
|
1236
|
+
return this.yScale(endOf(d));
|
|
1025
1237
|
})
|
|
1026
1238
|
.attr('height', (d) => {
|
|
1027
|
-
return this.
|
|
1239
|
+
return this.yScale(startOf(d)) - this.yScale(endOf(d));
|
|
1028
1240
|
});
|
|
1029
1241
|
}
|
|
1030
1242
|
drawThresholdAcrossChart(config) {
|
|
@@ -1034,7 +1246,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1034
1246
|
return i;
|
|
1035
1247
|
})
|
|
1036
1248
|
.on('mousemove', (event) => {
|
|
1037
|
-
this.
|
|
1249
|
+
this.showTooltip(event, config.thresholds[0], { isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
1038
1250
|
})
|
|
1039
1251
|
.transition()
|
|
1040
1252
|
.duration(this.transitionService.getTransitionDuration())
|
|
@@ -1051,9 +1263,10 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1051
1263
|
})
|
|
1052
1264
|
.on('mousemove', function (event) {
|
|
1053
1265
|
const index = Number(this.parentElement.dataset['groupId']);
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1266
|
+
const threshold = config.thresholds[index];
|
|
1267
|
+
// A threshold's own PcacData is typically just a value, so its parent is the *data* group
|
|
1268
|
+
// it's drawn against (which has the key) rather than the threshold entry it came from.
|
|
1269
|
+
self.showTooltip(event, config.isStacked ? threshold.data[0] : threshold, { parent: config.data[index], isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
1057
1270
|
})
|
|
1058
1271
|
.transition()
|
|
1059
1272
|
.duration(this.transitionService.getTransitionDuration())
|
|
@@ -1067,10 +1280,12 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1067
1280
|
.attr('data-group-threshold-id', (_, i) => {
|
|
1068
1281
|
return i;
|
|
1069
1282
|
})
|
|
1070
|
-
.on('mousemove', function (event
|
|
1283
|
+
.on('mousemove', function (event) {
|
|
1071
1284
|
const target = event.target;
|
|
1072
1285
|
const index = Number(target.getAttribute("data-group-threshold-id"));
|
|
1073
|
-
|
|
1286
|
+
const groupIndex = Number(this.parentElement.dataset['groupId']);
|
|
1287
|
+
// Parent is the data group (see drawThresholdsPerGroup), not the threshold entry itself.
|
|
1288
|
+
self.showTooltip(event, config.thresholds[groupIndex].data[index], { parent: config.data[groupIndex], isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
|
|
1074
1289
|
})
|
|
1075
1290
|
.attr('width', this.xScaleGrouped.bandwidth())
|
|
1076
1291
|
.transition()
|
|
@@ -1102,7 +1317,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1102
1317
|
return 2;
|
|
1103
1318
|
})
|
|
1104
1319
|
.on('mouseout', () => {
|
|
1105
|
-
this.
|
|
1320
|
+
this.hideTooltip();
|
|
1106
1321
|
})
|
|
1107
1322
|
.attr('height', () => {
|
|
1108
1323
|
return '3px';
|
|
@@ -1122,11 +1337,20 @@ class PcacBarVerticalChartComponent {
|
|
|
1122
1337
|
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
1123
1338
|
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
1124
1339
|
barClicked = outputFromObservable(this.chartBuilder.barClicked$);
|
|
1340
|
+
/**
|
|
1341
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element; replaces the
|
|
1342
|
+
* default tooltip when present (see PcacTooltipDirective).
|
|
1343
|
+
*/
|
|
1344
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
1345
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
1125
1346
|
constructor() {
|
|
1126
1347
|
// Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
|
|
1127
1348
|
// lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
|
|
1128
1349
|
// reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
|
|
1129
1350
|
effect(() => this.buildChart());
|
|
1351
|
+
// Handed over as a getter so the builder reads the query at hover time, not in the effect
|
|
1352
|
+
// above (see PcacChart.tooltipTemplate).
|
|
1353
|
+
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate()?.templateRef;
|
|
1130
1354
|
inject(PcacChartResizeService).observe(this.chartElm, () => {
|
|
1131
1355
|
// Skip the ResizeObserver's routine initial callback when it lands after the effect above
|
|
1132
1356
|
// already built successfully at this same width — only a real size change (or a build
|
|
@@ -1143,12 +1367,12 @@ class PcacBarVerticalChartComponent {
|
|
|
1143
1367
|
}
|
|
1144
1368
|
}
|
|
1145
1369
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarVerticalChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1146
|
-
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 });
|
|
1370
|
+
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], queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], 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 });
|
|
1147
1371
|
}
|
|
1148
1372
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarVerticalChartComponent, decorators: [{
|
|
1149
1373
|
type: Component,
|
|
1150
1374
|
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"] }]
|
|
1151
|
-
}], 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"] }] } });
|
|
1375
|
+
}], 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"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
1152
1376
|
|
|
1153
1377
|
class PcacBarVerticalChartConfig extends PcacChartConfig {
|
|
1154
1378
|
domainMax = 100;
|
|
@@ -1187,13 +1411,52 @@ class PcacLegend {
|
|
|
1187
1411
|
this.itemClicked.emit(items);
|
|
1188
1412
|
}
|
|
1189
1413
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLegend, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1190
|
-
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
|
|
1414
|
+
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 $index; let i = $index; 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"] });
|
|
1191
1415
|
}
|
|
1192
1416
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLegend, decorators: [{
|
|
1193
1417
|
type: Component,
|
|
1194
|
-
args: [{ selector: 'pcac-legend', template: "<div class=\"pcac-legend-label\"><small>{{config().heading}}</small></div>\n@for(item of config().items; track
|
|
1418
|
+
args: [{ selector: 'pcac-legend', template: "<div class=\"pcac-legend-label\"><small>{{config().heading}}</small></div>\n@for(item of config().items; track $index; let i = $index; 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"] }]
|
|
1195
1419
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }, { type: i0.Output, args: ["configChange"] }], itemClicked: [{ type: i0.Output, args: ["itemClicked"] }] } });
|
|
1196
1420
|
|
|
1421
|
+
var PcacLineAreaPlotChartConfigType;
|
|
1422
|
+
(function (PcacLineAreaPlotChartConfigType) {
|
|
1423
|
+
PcacLineAreaPlotChartConfigType["Line"] = "line";
|
|
1424
|
+
PcacLineAreaPlotChartConfigType["Area"] = "area";
|
|
1425
|
+
PcacLineAreaPlotChartConfigType["Plot"] = "plot";
|
|
1426
|
+
})(PcacLineAreaPlotChartConfigType || (PcacLineAreaPlotChartConfigType = {}));
|
|
1427
|
+
/**
|
|
1428
|
+
* Sizing for the images drawn in place of a point's dot (see `PcacData.image`). An image is
|
|
1429
|
+
* scaled uniformly (up or down) to fit inside a `maxWidth` x `maxHeight` box, preserving its
|
|
1430
|
+
* aspect ratio, and is centered on the data point exactly where the dot would have been.
|
|
1431
|
+
*/
|
|
1432
|
+
class PcacPointImageConfig {
|
|
1433
|
+
maxWidth = 16;
|
|
1434
|
+
maxHeight = 16;
|
|
1435
|
+
}
|
|
1436
|
+
class PcacLineAreaChartConfig extends PcacChartConfig {
|
|
1437
|
+
enableEffects = true;
|
|
1438
|
+
enableZoom = true;
|
|
1439
|
+
numberOfTicks = 5;
|
|
1440
|
+
hideGrid = false;
|
|
1441
|
+
hideAxis = false;
|
|
1442
|
+
yFormat = PcacFormatEnum.DatasetLength;
|
|
1443
|
+
xFormat = PcacFormatEnum.DatasetLength;
|
|
1444
|
+
yDomainMax;
|
|
1445
|
+
yDomainMin;
|
|
1446
|
+
xDomainMin;
|
|
1447
|
+
xDomainMax;
|
|
1448
|
+
/**
|
|
1449
|
+
* Hex color codes to override the default colors
|
|
1450
|
+
*/
|
|
1451
|
+
colorOverride = [];
|
|
1452
|
+
/**
|
|
1453
|
+
* Bounding box for any point images (`PcacData.image`) on this chart. Optional; each field falls
|
|
1454
|
+
* back to the `PcacPointImageConfig` default when not given, so a consumer only setting `image`
|
|
1455
|
+
* on their data still gets a sensibly-sized result.
|
|
1456
|
+
*/
|
|
1457
|
+
pointImage;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1197
1460
|
/**
|
|
1198
1461
|
* Provided per-component (see PcacLineAreaChartComponent's `providers`), not root-scoped: this
|
|
1199
1462
|
* holds mutable per-chart-instance state (`config`, `lines`) despite looking like a stateless
|
|
@@ -1212,7 +1475,13 @@ class PlaChartEffectsBuilder {
|
|
|
1212
1475
|
buildEffects(config) {
|
|
1213
1476
|
this.config = config;
|
|
1214
1477
|
this.lines = [];
|
|
1215
|
-
|
|
1478
|
+
// Filtered on the same predicate buildCollection() applies to the effect groups (each path's
|
|
1479
|
+
// datum is its series' point array), so `lines[i]` always belongs to the i-th group - an
|
|
1480
|
+
// empty series in the middle of the data would otherwise shift every later group onto the
|
|
1481
|
+
// wrong path.
|
|
1482
|
+
this.config.svg.selectAll('.line, .area')
|
|
1483
|
+
.filter((d) => d?.length !== 0)
|
|
1484
|
+
.each((d, i, n) => {
|
|
1216
1485
|
this.lines.push(n[i]);
|
|
1217
1486
|
});
|
|
1218
1487
|
this.buildCollection();
|
|
@@ -1332,30 +1601,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
1332
1601
|
type: Injectable
|
|
1333
1602
|
}] });
|
|
1334
1603
|
|
|
1335
|
-
var PcacLineAreaPlotChartConfigType;
|
|
1336
|
-
(function (PcacLineAreaPlotChartConfigType) {
|
|
1337
|
-
PcacLineAreaPlotChartConfigType["Line"] = "line";
|
|
1338
|
-
PcacLineAreaPlotChartConfigType["Area"] = "area";
|
|
1339
|
-
PcacLineAreaPlotChartConfigType["Plot"] = "plot";
|
|
1340
|
-
})(PcacLineAreaPlotChartConfigType || (PcacLineAreaPlotChartConfigType = {}));
|
|
1341
|
-
class PcacLineAreaChartConfig extends PcacChartConfig {
|
|
1342
|
-
enableEffects = true;
|
|
1343
|
-
enableZoom = true;
|
|
1344
|
-
numberOfTicks = 5;
|
|
1345
|
-
hideGrid = false;
|
|
1346
|
-
hideAxis = false;
|
|
1347
|
-
yFormat = PcacFormatEnum.DatasetLength;
|
|
1348
|
-
xFormat = PcacFormatEnum.DatasetLength;
|
|
1349
|
-
yDomainMax;
|
|
1350
|
-
yDomainMin;
|
|
1351
|
-
xDomainMin;
|
|
1352
|
-
xDomainMax;
|
|
1353
|
-
/**
|
|
1354
|
-
* Hex color codes to override the default colors
|
|
1355
|
-
*/
|
|
1356
|
-
colorOverride = [];
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
1604
|
class PlaChartScales {
|
|
1360
1605
|
x;
|
|
1361
1606
|
y;
|
|
@@ -1460,6 +1705,14 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1460
1705
|
dotClickedSource = new Subject();
|
|
1461
1706
|
config;
|
|
1462
1707
|
clipPathId; // <-- added
|
|
1708
|
+
/**
|
|
1709
|
+
* How far the clip-path rect extends past the drawable [0, width] x [0, height] area on every
|
|
1710
|
+
* side, so a point sitting exactly on the domain's edge isn't cut in half. 10px comfortably
|
|
1711
|
+
* clears a dot (r = 4, or 6 on hover); a point image can be much bigger than that, so
|
|
1712
|
+
* buildChart() widens this to half the largest image dimension whenever any point has one.
|
|
1713
|
+
*/
|
|
1714
|
+
clipBuffer = 10;
|
|
1715
|
+
pointImage;
|
|
1463
1716
|
dotClicked$ = this.dotClickedSource.asObservable();
|
|
1464
1717
|
buildChart(chartElm, config, type) {
|
|
1465
1718
|
if (!config?.data?.length) {
|
|
@@ -1472,6 +1725,7 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1472
1725
|
hide: false,
|
|
1473
1726
|
data: []
|
|
1474
1727
|
}));
|
|
1728
|
+
this.resetMargin();
|
|
1475
1729
|
if (this.config.hideAxis) {
|
|
1476
1730
|
this.config.height = this.config.height + 12;
|
|
1477
1731
|
this.margin.top = 8;
|
|
@@ -1482,12 +1736,19 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1482
1736
|
if (!this.initializeChartState(chartElm, this.config)) {
|
|
1483
1737
|
return;
|
|
1484
1738
|
}
|
|
1485
|
-
|
|
1739
|
+
// `?.length`, not a bare truthiness check: PcacLineAreaChartConfig defaults colorOverride to
|
|
1740
|
+
// `[]`, and an empty array is truthy - a config built with `new` would otherwise replace the
|
|
1741
|
+
// theme palette with nothing and every series would render with no color at all.
|
|
1742
|
+
if (this.config.colorOverride?.length) {
|
|
1486
1743
|
this.colors = this.config.colorOverride;
|
|
1487
1744
|
}
|
|
1488
|
-
this.
|
|
1489
|
-
this.
|
|
1490
|
-
|
|
1745
|
+
this.pointImage = { ...new PcacPointImageConfig(), ...this.config.pointImage };
|
|
1746
|
+
this.clipBuffer = this.config.data.some((series) => series.data.some((point) => !!point.image))
|
|
1747
|
+
? Math.max(10, Math.ceil(this.pointImage.maxWidth / 2), Math.ceil(this.pointImage.maxHeight / 2))
|
|
1748
|
+
: 10;
|
|
1749
|
+
this.scales = new PlaChartScalesBuilder().build(this.config, this.width, this.height);
|
|
1750
|
+
this.lineGenerator = buildLineGenerator(this.config.xFormat, this.scales);
|
|
1751
|
+
this.areaGenerator = buildAreaGenerator(this.config.xFormat, this.scales, this.height);
|
|
1491
1752
|
if (this.config.enableZoom) {
|
|
1492
1753
|
this.zoomBehavior = buildZoomBehavior(this.width, this.height, (event) => {
|
|
1493
1754
|
// Rescale x
|
|
@@ -1502,14 +1763,22 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1502
1763
|
yFormat: this.config.yFormat,
|
|
1503
1764
|
xFormat: this.config.xFormat
|
|
1504
1765
|
});
|
|
1505
|
-
// Update lines/areas
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
this.
|
|
1512
|
-
|
|
1766
|
+
// Update lines/areas. Fresh generators against the rescaled x, so they go through the
|
|
1767
|
+
// same getXFormat() as the dots below - positioning by bare index here (which this used
|
|
1768
|
+
// to do, and which also overwrote the original generators' x accessor for good) is only
|
|
1769
|
+
// right for the default DatasetLength format; a DateTime/Decimal chart's lines drifted
|
|
1770
|
+
// away from its dots as soon as it was zoomed.
|
|
1771
|
+
const zoomedScales = { x: newX, y: this.scales.y };
|
|
1772
|
+
const zoomedLine = buildLineGenerator(this.config.xFormat, zoomedScales);
|
|
1773
|
+
const zoomedArea = buildAreaGenerator(this.config.xFormat, zoomedScales, this.height);
|
|
1774
|
+
this.svg.selectAll('.line').attr('d', (d) => zoomedLine(d));
|
|
1775
|
+
this.svg.selectAll('.area').attr('d', (d) => zoomedArea(d));
|
|
1776
|
+
// Update dots / point images. Nested selectAll (not a flat svg.selectAll('.point')) so
|
|
1777
|
+
// that `i` is the point's index *within its own series* - the xFormat default
|
|
1778
|
+
// (DatasetLength) positions by index, and a flat selection would number every series'
|
|
1779
|
+
// points consecutively, shoving the second series' points off to the right on zoom.
|
|
1780
|
+
this.svg.selectAll('.dots').selectAll('.point')
|
|
1781
|
+
.attr('transform', (d, i) => this.pointTransform(d, i, newX));
|
|
1513
1782
|
});
|
|
1514
1783
|
}
|
|
1515
1784
|
this.drawChart(chartElm, this.config, type);
|
|
@@ -1560,10 +1829,12 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1560
1829
|
.append('clipPath')
|
|
1561
1830
|
.attr('id', this.clipPathId)
|
|
1562
1831
|
.append('rect')
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
.attr('
|
|
1566
|
-
.attr('
|
|
1832
|
+
// Extend the clip-path past the drawable area on every side so a dot (or point image) at
|
|
1833
|
+
// the x-domain's min/max, or the top/bottom of the y range, isn't cut in half. See clipBuffer.
|
|
1834
|
+
.attr('x', -this.clipBuffer)
|
|
1835
|
+
.attr('y', -this.clipBuffer)
|
|
1836
|
+
.attr('width', this.width + this.clipBuffer * 2)
|
|
1837
|
+
.attr('height', this.height + this.clipBuffer * 2);
|
|
1567
1838
|
}
|
|
1568
1839
|
attachZoomBehavior() {
|
|
1569
1840
|
if (!this.config.enableZoom)
|
|
@@ -1589,7 +1860,7 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1589
1860
|
drawLineArea(config, type) {
|
|
1590
1861
|
for (let i = 0; i < config.data.length; i++) {
|
|
1591
1862
|
if (type === PcacLineAreaPlotChartConfigType.Area) {
|
|
1592
|
-
this.drawArea(config.data[i].data, i);
|
|
1863
|
+
this.drawArea(config.data[i].data, i, config.data[i].hide);
|
|
1593
1864
|
}
|
|
1594
1865
|
else if (type === PcacLineAreaPlotChartConfigType.Line) {
|
|
1595
1866
|
this.drawLine(config.data[i].data, i, config.data[i].hide);
|
|
@@ -1613,13 +1884,16 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1613
1884
|
.attr('fill', 'none')
|
|
1614
1885
|
.attr('style', () => hide ? 'display: none' : null);
|
|
1615
1886
|
}
|
|
1616
|
-
drawArea(lineData, index) {
|
|
1887
|
+
drawArea(lineData, index, hide = false) {
|
|
1617
1888
|
this.svg.append('g')
|
|
1618
1889
|
.attr('class', 'areas')
|
|
1619
1890
|
.attr('clip-path', `url(#${this.clipPathId})`) // <-- apply clip
|
|
1620
1891
|
.append('path')
|
|
1621
1892
|
.datum(lineData)
|
|
1622
1893
|
.attr('class', 'area')
|
|
1894
|
+
// Same `hide` handling as drawLine()/drawDots(); the area used to ignore it and paint
|
|
1895
|
+
// a hidden series' fill anyway.
|
|
1896
|
+
.style('display', () => hide ? 'none' : null)
|
|
1623
1897
|
.style('opacity', 0.5)
|
|
1624
1898
|
.style('fill', () => {
|
|
1625
1899
|
return this.colors[index];
|
|
@@ -1629,54 +1903,80 @@ class PlaChartBuilder extends PcacChart {
|
|
|
1629
1903
|
.duration(this.transitionService.getTransitionDuration())
|
|
1630
1904
|
.attr('d', this.areaGenerator);
|
|
1631
1905
|
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Draws one `<g class="dots">` per series holding a `<g class="point">` per data point. The
|
|
1908
|
+
* point group carries the x position (as a translate) so that zoom only has to touch that one
|
|
1909
|
+
* attribute regardless of what's inside; the child is either the regular `<circle class="dot">`
|
|
1910
|
+
* or, when the point has a `PcacData.image`, an `<image class="dot-image">` in its place. Both
|
|
1911
|
+
* animate in from the baseline the same way, and the tooltip / click handlers sit on the group
|
|
1912
|
+
* so they behave identically for either.
|
|
1913
|
+
*/
|
|
1632
1914
|
drawDots(config) {
|
|
1633
1915
|
const self = this;
|
|
1916
|
+
const duration = this.transitionService.getTransitionDuration();
|
|
1917
|
+
const { maxWidth, maxHeight } = this.pointImage;
|
|
1634
1918
|
for (let index = 0; index < config.data.length; index++) {
|
|
1635
|
-
|
|
1919
|
+
const series = config.data[index];
|
|
1920
|
+
const points = this.svg.append('g')
|
|
1636
1921
|
.attr('class', 'dots')
|
|
1637
1922
|
.attr('clip-path', `url(#${this.clipPathId})`) // <-- apply clip
|
|
1638
|
-
.
|
|
1639
|
-
.
|
|
1640
|
-
.
|
|
1641
|
-
.
|
|
1642
|
-
.attr('
|
|
1643
|
-
|
|
1644
|
-
})
|
|
1645
|
-
.attr('cx', (d, i) => {
|
|
1646
|
-
return getXFormat(config.xFormat, d, i, this.scales.x);
|
|
1647
|
-
})
|
|
1648
|
-
.attr('cy', (_) => {
|
|
1649
|
-
return this.scales.y(0);
|
|
1650
|
-
})
|
|
1651
|
-
.attr('fill', '#fff')
|
|
1923
|
+
.attr('style', series.hide ? 'display: none' : null)
|
|
1924
|
+
.selectAll('.point')
|
|
1925
|
+
.data(series.data)
|
|
1926
|
+
.enter().append('g')
|
|
1927
|
+
.attr('class', 'point')
|
|
1928
|
+
.attr('transform', (d, i) => this.pointTransform(d, i, this.scales.x))
|
|
1652
1929
|
.on('mouseover', function (event, d) {
|
|
1653
|
-
self.
|
|
1654
|
-
|
|
1930
|
+
self.showTooltip(event, d, { parent: series, valueFormat: self.config.yFormat, keyFormat: self.config.xFormat });
|
|
1931
|
+
// No-op for an image point (no circle inside to grow).
|
|
1932
|
+
select$1(this).select('.dot')
|
|
1655
1933
|
.transition()
|
|
1656
|
-
.duration(
|
|
1934
|
+
.duration(duration / 3)
|
|
1657
1935
|
.attr('r', 6)
|
|
1658
1936
|
.attr('fill', self.colors[index]);
|
|
1659
1937
|
})
|
|
1660
1938
|
.on('mouseout', function () {
|
|
1661
|
-
self.
|
|
1662
|
-
select$1(this)
|
|
1939
|
+
self.hideTooltip();
|
|
1940
|
+
select$1(this).select('.dot')
|
|
1663
1941
|
.transition()
|
|
1664
|
-
.duration(
|
|
1942
|
+
.duration(duration / 3)
|
|
1665
1943
|
.attr('r', 4)
|
|
1666
1944
|
.attr('fill', '#fff');
|
|
1667
1945
|
})
|
|
1668
1946
|
.on('click', (_event, d) => {
|
|
1669
1947
|
this.dotClickedSource.next(d);
|
|
1670
|
-
})
|
|
1948
|
+
});
|
|
1949
|
+
points.filter((d) => !d.image)
|
|
1950
|
+
.append('circle')
|
|
1951
|
+
.attr('class', 'dot')
|
|
1952
|
+
.attr('stroke', this.colors[index])
|
|
1953
|
+
.attr('cy', this.scales.y(0))
|
|
1954
|
+
.attr('fill', '#fff')
|
|
1671
1955
|
.transition()
|
|
1672
|
-
.duration(
|
|
1673
|
-
.attr('cy', (d) =>
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1956
|
+
.duration(duration)
|
|
1957
|
+
.attr('cy', (d) => this.scales.y(d.value))
|
|
1958
|
+
.attr('r', 4);
|
|
1959
|
+
// `preserveAspectRatio="xMidYMid meet"` is what does the "resize to fit" - the image is
|
|
1960
|
+
// scaled uniformly to fit inside the maxWidth x maxHeight box and centered within it, so
|
|
1961
|
+
// a non-square image still lands centered on the point. x/y offset by half the box so the
|
|
1962
|
+
// box (not its top-left corner) is centered on the data point, matching where a dot sits.
|
|
1963
|
+
points.filter((d) => !!d.image)
|
|
1964
|
+
.append('image')
|
|
1965
|
+
.attr('class', 'dot-image')
|
|
1966
|
+
.attr('href', (d) => d.image)
|
|
1967
|
+
.attr('width', maxWidth)
|
|
1968
|
+
.attr('height', maxHeight)
|
|
1969
|
+
.attr('preserveAspectRatio', 'xMidYMid meet')
|
|
1970
|
+
.attr('x', -maxWidth / 2)
|
|
1971
|
+
.attr('y', this.scales.y(0) - maxHeight / 2)
|
|
1972
|
+
.transition()
|
|
1973
|
+
.duration(duration)
|
|
1974
|
+
.attr('y', (d) => this.scales.y(d.value) - maxHeight / 2);
|
|
1678
1975
|
}
|
|
1679
1976
|
}
|
|
1977
|
+
pointTransform(d, i, xScale) {
|
|
1978
|
+
return `translate(${getXFormat(this.config.xFormat, d, i, xScale)}, 0)`;
|
|
1979
|
+
}
|
|
1680
1980
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
1681
1981
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder });
|
|
1682
1982
|
}
|
|
@@ -1693,6 +1993,15 @@ class PcacLineAreaChartComponent {
|
|
|
1693
1993
|
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
1694
1994
|
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
1695
1995
|
dotClicked = outputFromObservable(this.chartBuilder.dotClicked$);
|
|
1996
|
+
/**
|
|
1997
|
+
* The consumer's `<ng-template pcacTooltip>`, forwarded by the PcacLineChart/PcacAreaChart/
|
|
1998
|
+
* PcacPlotChart wrapper it was projected into. An input rather than a `contentChild()` query
|
|
1999
|
+
* of this component's own: content queries only see nodes declared directly inside the
|
|
2000
|
+
* element in the consumer's template, not ones the wrapper re-projects through `<ng-content>`,
|
|
2001
|
+
* so the wrapper has to run the query and pass the result down.
|
|
2002
|
+
*/
|
|
2003
|
+
tooltipTemplate = input(/* @ts-ignore */
|
|
2004
|
+
...(ngDevMode ? [undefined, { debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
1696
2005
|
constructor() {
|
|
1697
2006
|
// Reacts to config()/type() the same way ngOnChanges used to — reading them here (rather
|
|
1698
2007
|
// than a lifecycle hook) is what makes this an effect: it tracks whichever signals
|
|
@@ -1701,6 +2010,9 @@ class PcacLineAreaChartComponent {
|
|
|
1701
2010
|
// is always bound to a constant per wrapper (PcacLineChart/PcacAreaChart/PcacPlotChart), so
|
|
1702
2011
|
// this is unreachable today, but reacting to it is the more correct behavior regardless.
|
|
1703
2012
|
effect(() => this.buildChart());
|
|
2013
|
+
// Handed over as a getter so the builder reads the input at hover time, not in the effect
|
|
2014
|
+
// above (see PcacChart.tooltipTemplate).
|
|
2015
|
+
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate();
|
|
1704
2016
|
inject(PcacChartResizeService).observe(this.chartElm, () => {
|
|
1705
2017
|
// Skip the ResizeObserver's routine initial callback when it lands after the effect above
|
|
1706
2018
|
// already built successfully at this same width — only a real size change (or a build
|
|
@@ -1717,25 +2029,31 @@ class PcacLineAreaChartComponent {
|
|
|
1717
2029
|
}
|
|
1718
2030
|
}
|
|
1719
2031
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1720
|
-
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}
|
|
2032
|
+
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 }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, 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-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 });
|
|
1721
2033
|
}
|
|
1722
2034
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, decorators: [{
|
|
1723
2035
|
type: Component,
|
|
1724
|
-
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}
|
|
1725
|
-
}], 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"] }] } });
|
|
2036
|
+
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-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"] }]
|
|
2037
|
+
}], 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"] }], tooltipTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipTemplate", required: false }] }] } });
|
|
1726
2038
|
|
|
1727
2039
|
class PcacPlotChart {
|
|
1728
2040
|
config = input.required(/* @ts-ignore */
|
|
1729
2041
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1730
2042
|
types = PcacLineAreaPlotChartConfigType;
|
|
1731
2043
|
dotClicked = output();
|
|
2044
|
+
/**
|
|
2045
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element, forwarded to the
|
|
2046
|
+
* inner chart (see PcacLineAreaChartComponent.tooltipTemplate for why it can't query it itself).
|
|
2047
|
+
*/
|
|
2048
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
2049
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
1732
2050
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPlotChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1733
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
2051
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.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" } }, queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Plot\" (dotClicked)=\"dotClicked.emit($event)\"/>", dependencies: [{ kind: "component", type: PcacLineAreaChartComponent, selector: "pcac-line-area-chart", inputs: ["config", "type", "tooltipTemplate"], outputs: ["dotClicked"] }] });
|
|
1734
2052
|
}
|
|
1735
2053
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPlotChart, decorators: [{
|
|
1736
2054
|
type: Component,
|
|
1737
|
-
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)\"/>" }]
|
|
1738
|
-
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
2055
|
+
args: [{ selector: 'pcac-plot-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Plot\" (dotClicked)=\"dotClicked.emit($event)\"/>" }]
|
|
2056
|
+
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
1739
2057
|
|
|
1740
2058
|
class PcacPlotChartConfig extends PcacLineAreaChartConfig {
|
|
1741
2059
|
}
|
|
@@ -1745,13 +2063,19 @@ class PcacLineChart {
|
|
|
1745
2063
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1746
2064
|
types = PcacLineAreaPlotChartConfigType;
|
|
1747
2065
|
dotClicked = output();
|
|
2066
|
+
/**
|
|
2067
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element, forwarded to the
|
|
2068
|
+
* inner chart (see PcacLineAreaChartComponent.tooltipTemplate for why it can't query it itself).
|
|
2069
|
+
*/
|
|
2070
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
2071
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
1748
2072
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1749
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
2073
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.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" } }, queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Line\" (dotClicked)=\"dotClicked.emit($event)\" />", dependencies: [{ kind: "component", type: PcacLineAreaChartComponent, selector: "pcac-line-area-chart", inputs: ["config", "type", "tooltipTemplate"], outputs: ["dotClicked"] }] });
|
|
1750
2074
|
}
|
|
1751
2075
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineChart, decorators: [{
|
|
1752
2076
|
type: Component,
|
|
1753
|
-
args: [{ selector: 'pcac-line-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Line\" />" }]
|
|
1754
|
-
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
2077
|
+
args: [{ selector: 'pcac-line-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Line\" (dotClicked)=\"dotClicked.emit($event)\" />" }]
|
|
2078
|
+
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
1755
2079
|
|
|
1756
2080
|
class PcacLineChartConfig extends PcacLineAreaChartConfig {
|
|
1757
2081
|
}
|
|
@@ -1761,13 +2085,19 @@ class PcacAreaChart {
|
|
|
1761
2085
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1762
2086
|
types = PcacLineAreaPlotChartConfigType;
|
|
1763
2087
|
dotClicked = output();
|
|
2088
|
+
/**
|
|
2089
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element, forwarded to the
|
|
2090
|
+
* inner chart (see PcacLineAreaChartComponent.tooltipTemplate for why it can't query it itself).
|
|
2091
|
+
*/
|
|
2092
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
2093
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
1764
2094
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAreaChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1765
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
2095
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.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" } }, queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Area\" (dotClicked)=\"dotClicked.emit($event)\" />", dependencies: [{ kind: "component", type: PcacLineAreaChartComponent, selector: "pcac-line-area-chart", inputs: ["config", "type", "tooltipTemplate"], outputs: ["dotClicked"] }] });
|
|
1766
2096
|
}
|
|
1767
2097
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAreaChart, decorators: [{
|
|
1768
2098
|
type: Component,
|
|
1769
|
-
args: [{ selector: 'pcac-area-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [type]=\"types.Area\" />" }]
|
|
1770
|
-
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }] } });
|
|
2099
|
+
args: [{ selector: 'pcac-area-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Area\" (dotClicked)=\"dotClicked.emit($event)\" />" }]
|
|
2100
|
+
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
1771
2101
|
|
|
1772
2102
|
class PcacAreaChartConfig extends PcacLineAreaChartConfig {
|
|
1773
2103
|
}
|
|
@@ -1775,6 +2105,9 @@ class PcacAreaChartConfig extends PcacLineAreaChartConfig {
|
|
|
1775
2105
|
// export * from './plot-line-area-chart.builder';
|
|
1776
2106
|
// export * from './plot-line-area-chart.component';
|
|
1777
2107
|
// export * from './plot-line-area-chart.model';
|
|
2108
|
+
// The rest of that model stays internal (the shared PcacLineAreaChartConfig is reached through
|
|
2109
|
+
// the per-chart PcacLineChartConfig/PcacAreaChartConfig/PcacPlotChartConfig subclasses), but
|
|
2110
|
+
// the point-image sizing type is part of those configs' public shape, so it's exported alone.
|
|
1778
2111
|
|
|
1779
2112
|
/**
|
|
1780
2113
|
* Provided per-component (see PcacPieChartComponent's `providers`), not root-scoped:
|
|
@@ -1837,10 +2170,10 @@ class PieChartBuilder extends PcacChart {
|
|
|
1837
2170
|
.style('fill', ct);
|
|
1838
2171
|
})
|
|
1839
2172
|
.on('mousemove', (event, d) => {
|
|
1840
|
-
self.
|
|
2173
|
+
self.showTooltip(event, d.data);
|
|
1841
2174
|
})
|
|
1842
2175
|
.on('mouseout', function (_, d) {
|
|
1843
|
-
self.
|
|
2176
|
+
self.hideTooltip();
|
|
1844
2177
|
select$1(this)
|
|
1845
2178
|
.transition()
|
|
1846
2179
|
.duration(self.transitionService.getTransitionDuration() / 3)
|
|
@@ -1877,11 +2210,20 @@ class PcacPieChartComponent {
|
|
|
1877
2210
|
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
1878
2211
|
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
1879
2212
|
sliceClicked = outputFromObservable(this.chartBuilder.sliceClicked$);
|
|
2213
|
+
/**
|
|
2214
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element; replaces the
|
|
2215
|
+
* default tooltip when present (see PcacTooltipDirective).
|
|
2216
|
+
*/
|
|
2217
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
2218
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
1880
2219
|
constructor() {
|
|
1881
2220
|
// Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
|
|
1882
2221
|
// lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
|
|
1883
2222
|
// reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
|
|
1884
2223
|
effect(() => this.buildChart());
|
|
2224
|
+
// Handed over as a getter so the builder reads the query at hover time, not in the effect
|
|
2225
|
+
// above (see PcacChart.tooltipTemplate).
|
|
2226
|
+
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate()?.templateRef;
|
|
1885
2227
|
inject(PcacChartResizeService).observe(this.chartElm, () => {
|
|
1886
2228
|
// Skip the ResizeObserver's routine initial callback when it lands after the effect above
|
|
1887
2229
|
// already built successfully at this same width — only a real size change (or a build
|
|
@@ -1898,12 +2240,12 @@ class PcacPieChartComponent {
|
|
|
1898
2240
|
}
|
|
1899
2241
|
}
|
|
1900
2242
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1901
|
-
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 });
|
|
2243
|
+
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], queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], 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 });
|
|
1902
2244
|
}
|
|
1903
2245
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPieChartComponent, decorators: [{
|
|
1904
2246
|
type: Component,
|
|
1905
2247
|
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"] }]
|
|
1906
|
-
}], 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"] }] } });
|
|
2248
|
+
}], 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"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
1907
2249
|
|
|
1908
2250
|
class PcacPieChartConfig extends PcacChartConfig {
|
|
1909
2251
|
numberOfTicks = 5;
|
|
@@ -1917,5 +2259,5 @@ class PcacPieChartConfig extends PcacChartConfig {
|
|
|
1917
2259
|
* Generated bundle index. Do not edit.
|
|
1918
2260
|
*/
|
|
1919
2261
|
|
|
1920
|
-
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 };
|
|
2262
|
+
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, PcacTooltipDirective, PcacTransitionService, PieChartBuilder };
|
|
1921
2263
|
//# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map
|