@pioneer-code/pioneer-charts 22.1.1 → 22.1.4

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.
@@ -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';
@@ -83,7 +83,7 @@ class PcacAxisBuilder {
83
83
  return;
84
84
  const yAxis = axisLeft(config.yScale).ticks(config.numberOfTicks);
85
85
  if (config.yFormat) {
86
- switch (config.yFormat.toLocaleLowerCase()) {
86
+ switch (config.yFormat) {
87
87
  case PcacFormatEnum.Percentage:
88
88
  yAxis.tickFormat(d => d + "%");
89
89
  break;
@@ -113,7 +113,7 @@ class PcacAxisBuilder {
113
113
  xAxis.tickFormat((d) => d + 'm');
114
114
  break;
115
115
  case PcacFormatEnum.Fahrenheit:
116
- xAxis.tickFormat((d) => d + 'f');
116
+ xAxis.tickFormat((d) => d + ' F');
117
117
  break;
118
118
  case PcacFormatEnum.OneDayHours:
119
119
  xAxis.tickFormat((d) => {
@@ -149,7 +149,7 @@ class PcacGridBuilder {
149
149
  config.svg.append('g')
150
150
  .attr('class', 'pcac-grid')
151
151
  .selectAll('g.rule')
152
- .data(xScale.ticks(5))
152
+ .data(xScale.ticks(config.numberOfTicks))
153
153
  .enter().append('svg:g')
154
154
  .attr('class', 'pcac-grid-rule')
155
155
  .attr('transform', (d) => (`translate(${xScale(d)}, 0)`))
@@ -269,17 +269,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
269
269
  }] });
270
270
 
271
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
+ */
272
279
  tooltip = select('body')
273
280
  .append('div')
274
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
+ */
275
308
  showBarTooltip(event, data, valueFormat, keyFormat) {
276
- this.tooltip.style('left', event.pageX - 60 + 'px')
277
- .style('top', event.pageY - 55 + 'px')
278
- .style('display', 'inline-block')
279
- .html(this.getBarTipData(data, valueFormat, keyFormat));
309
+ this.showTooltip(event, undefined, { $implicit: data, parent: null, isThreshold: false }, valueFormat, keyFormat);
280
310
  }
281
311
  hideTooltip() {
282
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');
283
367
  }
284
368
  getBarTipData(data, valueFormat, keyFormat) {
285
369
  let value = data.value;
@@ -309,7 +393,7 @@ class PcacTooltipBuilder {
309
393
  }
310
394
  }
311
395
  const finalValue = value ? value.toString() : value;
312
- return key ? key + '</br>' + finalValue : `${finalValue}`;
396
+ return key ? key + '<br>' + finalValue : `${finalValue}`;
313
397
  }
314
398
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
315
399
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacTooltipBuilder, providedIn: 'root' });
@@ -328,6 +412,7 @@ class PcacChart {
328
412
  tooltipBuilder = inject(PcacTooltipBuilder);
329
413
  colorService = inject(PcacColorService);
330
414
  margin = { top: 8, right: 16, bottom: 20, left: 40 };
415
+ defaultMargin = { ...this.margin };
331
416
  svg;
332
417
  width = 400;
333
418
  height = 400;
@@ -349,6 +434,35 @@ class PcacChart {
349
434
  */
350
435
  lastContainerHeight = null;
351
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
+ }
352
466
  /**
353
467
  * Prior to building a chart, we need to initialize the state of the chart.
354
468
  *
@@ -471,11 +585,36 @@ class PcacChart {
471
585
  }
472
586
  })
473
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;
474
594
  this.margin.left = max;
475
- this.width = this.width - this.margin.left;
476
595
  }
477
596
  }
478
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
+
479
618
  /**
480
619
  * Provided per-component (see PcacBarHorizontalChartComponent's `providers`), not root-scoped:
481
620
  * this builder extends PcacChart, which holds mutable per-chart-instance state (margin, width,
@@ -488,30 +627,28 @@ class BarHorizontalChartBuilder extends PcacChart {
488
627
  yScaleGrouped;
489
628
  barClickedSource = new Subject();
490
629
  config;
491
- cachedMargins;
492
630
  barClicked$ = this.barClickedSource.asObservable();
493
631
  buildChart(chartElm, config) {
494
632
  if (!config?.data?.length) {
495
633
  return;
496
634
  }
497
635
  this.config = JSON.parse(JSON.stringify(config));
636
+ this.resetMargin();
498
637
  if (this.config.hideAxis) {
499
638
  this.adjustForHiddenAxis();
500
639
  }
501
640
  if (!this.initializeChartState(chartElm, this.config)) {
502
641
  return;
503
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).
504
645
  if (config.colorOverride && config.colorOverride.colors) {
505
- this.colors = config.colorOverride.colors.reverse();
646
+ this.colors = [...config.colorOverride.colors].reverse();
506
647
  }
507
648
  this.buildScales(chartElm, this.config);
508
649
  this.drawChart(chartElm, this.config);
509
650
  }
510
651
  adjustForHiddenAxis() {
511
- if (!this.cachedMargins) {
512
- this.cachedMargins = JSON.parse(JSON.stringify(this.margin));
513
- }
514
- this.margin = JSON.parse(JSON.stringify(this.cachedMargins));
515
652
  this.config.height = this.config.height + this.margin.top + this.margin.bottom;
516
653
  this.margin.top = 0;
517
654
  this.margin.bottom = 0;
@@ -594,9 +731,14 @@ class BarHorizontalChartBuilder extends PcacChart {
594
731
  }
595
732
  drawBarsPerGroup(groups, config) {
596
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);
597
739
  groups.enter().append('rect')
598
740
  .attr('class', 'pcac-bar')
599
- .attr('x', 0)
741
+ .attr('x', (d) => this.xScale(startOf(d)))
600
742
  .attr('y', (d) => {
601
743
  const value = !config.isStacked ? this.yScaleGrouped(d.key) : this.yScaleStacked(d.key);
602
744
  return value ? value : 0;
@@ -630,11 +772,12 @@ class BarHorizontalChartBuilder extends PcacChart {
630
772
  return ct;
631
773
  });
632
774
  })
633
- .on('mousemove', (event, d) => {
634
- self.tooltipBuilder.showBarTooltip(event, d, config.tickFormat || PcacFormatEnum.None);
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 });
635
778
  })
636
779
  .on('mouseout', function () {
637
- self.tooltipBuilder.hideTooltip();
780
+ self.hideTooltip();
638
781
  select$1(this)
639
782
  .transition()
640
783
  .duration(self.transitionService.getTransitionDuration() / 5)
@@ -653,7 +796,7 @@ class BarHorizontalChartBuilder extends PcacChart {
653
796
  .transition()
654
797
  .duration(this.transitionService.getTransitionDuration())
655
798
  .attr('width', (d) => {
656
- return this.xScale(d.value);
799
+ return this.xScale(endOf(d)) - this.xScale(startOf(d));
657
800
  });
658
801
  }
659
802
  drawThresholdAcrossChart(config) {
@@ -662,8 +805,8 @@ class BarHorizontalChartBuilder extends PcacChart {
662
805
  .attr('data-group-threshold-id', (_, i) => {
663
806
  return i;
664
807
  })
665
- .on('mousemove', (event, _) => {
666
- this.tooltipBuilder.showBarTooltip(event, config.thresholds[0], config.tickFormat || PcacFormatEnum.None);
808
+ .on('mousemove', (event) => {
809
+ this.showTooltip(event, config.thresholds[0], { isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
667
810
  })
668
811
  .transition()
669
812
  .duration(this.transitionService.getTransitionDuration())
@@ -680,9 +823,10 @@ class BarHorizontalChartBuilder extends PcacChart {
680
823
  })
681
824
  .on('mousemove', function (event) {
682
825
  const index = Number(this.parentElement.dataset['groupId']);
683
- self.tooltipBuilder.showBarTooltip(event, config.isStacked ?
684
- config.thresholds[index].data[0] :
685
- config.thresholds[index], config.tickFormat || PcacFormatEnum.None);
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 });
686
830
  })
687
831
  .transition()
688
832
  .duration(this.transitionService.getTransitionDuration())
@@ -700,7 +844,9 @@ class BarHorizontalChartBuilder extends PcacChart {
700
844
  .on('mousemove', function (event) {
701
845
  const target = event.target;
702
846
  const index = Number(target.getAttribute("data-group-threshold-id"));
703
- self.tooltipBuilder.showBarTooltip(event, config.thresholds[Number(this.parentElement.dataset['groupId'])].data[index], config.tickFormat || PcacFormatEnum.None);
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 });
704
850
  })
705
851
  .transition()
706
852
  .duration(this.transitionService.getTransitionDuration())
@@ -725,7 +871,7 @@ class BarHorizontalChartBuilder extends PcacChart {
725
871
  })
726
872
  .attr('width', '3px')
727
873
  .on('mouseout', () => {
728
- this.tooltipBuilder.hideTooltip();
874
+ this.hideTooltip();
729
875
  });
730
876
  }
731
877
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: BarHorizontalChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
@@ -792,6 +938,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
792
938
  args: [{ providedIn: 'root' }]
793
939
  }] });
794
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
+
795
977
  class PcacBarHorizontalChartComponent {
796
978
  chartBuilder = inject(BarHorizontalChartBuilder);
797
979
  config = input.required(/* @ts-ignore */
@@ -799,11 +981,20 @@ class PcacBarHorizontalChartComponent {
799
981
  chartElm = viewChild.required('chart', /* @ts-ignore */
800
982
  ...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
801
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 */ []));
802
990
  constructor() {
803
991
  // Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
804
992
  // lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
805
993
  // reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
806
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;
807
998
  inject(PcacChartResizeService).observe(this.chartElm, () => {
808
999
  // Skip the ResizeObserver's routine initial callback when it lands after the effect above
809
1000
  // already built successfully at this same width — only a real size change (or a build
@@ -820,12 +1011,12 @@ class PcacBarHorizontalChartComponent {
820
1011
  }
821
1012
  }
822
1013
  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 });
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 });
824
1015
  }
825
1016
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarHorizontalChartComponent, decorators: [{
826
1017
  type: Component,
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"] }]
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"] }] } });
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 }] }] } });
829
1020
 
830
1021
  class PcacBarHorizontalChartConfig extends PcacChartConfig {
831
1022
  domainMax = 100;
@@ -858,17 +1049,20 @@ class BarVerticalChartBuilder extends PcacChart {
858
1049
  if (!config?.data?.length) {
859
1050
  return;
860
1051
  }
861
- if (config.colorOverride && config.colorOverride.colors) {
862
- this.colors = config.colorOverride.colors;
863
- }
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();
864
1056
  if (config.hideAxis) {
865
1057
  this.adjustForHiddenAxis(config);
866
1058
  }
867
1059
  if (!this.initializeChartState(chartElm, config)) {
868
1060
  return;
869
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).
870
1064
  if (config.colorOverride && config.colorOverride.colors) {
871
- this.colors = config.colorOverride.colors.reverse();
1065
+ this.colors = [...config.colorOverride.colors].reverse();
872
1066
  }
873
1067
  this.buildScales(config);
874
1068
  this.drawChart(chartElm, config);
@@ -894,8 +1088,10 @@ class BarVerticalChartBuilder extends PcacChart {
894
1088
  return hasGroupLabel;
895
1089
  }
896
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.
897
1093
  this.yScale = scaleLinear()
898
- .rangeRound([0, config.height])
1094
+ .rangeRound([0, this.height])
899
1095
  .domain([config.domainMax, 0]);
900
1096
  this.xScaleStacked = scaleBand()
901
1097
  .domain(config.data.map((d) => d.key))
@@ -967,6 +1163,11 @@ class BarVerticalChartBuilder extends PcacChart {
967
1163
  }
968
1164
  drawBarsPerGroup(group, config) {
969
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);
970
1171
  group.enter().append('rect')
971
1172
  .attr('class', 'pcac-bar')
972
1173
  .attr('x', (d) => {
@@ -1004,11 +1205,12 @@ class BarVerticalChartBuilder extends PcacChart {
1004
1205
  return ct;
1005
1206
  });
1006
1207
  })
1007
- .on('mousemove', (event, d) => {
1008
- self.tooltipBuilder.showBarTooltip(event, d, config.tickFormat || PcacFormatEnum.None);
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 });
1009
1211
  })
1010
1212
  .on('mouseout', function () {
1011
- self.tooltipBuilder.hideTooltip();
1213
+ self.hideTooltip();
1012
1214
  select$1(this)
1013
1215
  .transition()
1014
1216
  .duration(self.transitionService.getTransitionDuration() / 5)
@@ -1031,10 +1233,10 @@ class BarVerticalChartBuilder extends PcacChart {
1031
1233
  // )
1032
1234
  .attr('width', !config.isStacked ? this.xScaleGrouped.bandwidth() : this.xScaleStacked.bandwidth())
1033
1235
  .attr('y', (d) => {
1034
- return this.yScale(d.value);
1236
+ return this.yScale(endOf(d));
1035
1237
  })
1036
1238
  .attr('height', (d) => {
1037
- return this.height - this.yScale(d.value);
1239
+ return this.yScale(startOf(d)) - this.yScale(endOf(d));
1038
1240
  });
1039
1241
  }
1040
1242
  drawThresholdAcrossChart(config) {
@@ -1044,7 +1246,7 @@ class BarVerticalChartBuilder extends PcacChart {
1044
1246
  return i;
1045
1247
  })
1046
1248
  .on('mousemove', (event) => {
1047
- this.tooltipBuilder.showBarTooltip(event, config.thresholds[0], config.tickFormat || PcacFormatEnum.None);
1249
+ this.showTooltip(event, config.thresholds[0], { isThreshold: true, valueFormat: config.tickFormat || PcacFormatEnum.None });
1048
1250
  })
1049
1251
  .transition()
1050
1252
  .duration(this.transitionService.getTransitionDuration())
@@ -1061,9 +1263,10 @@ class BarVerticalChartBuilder extends PcacChart {
1061
1263
  })
1062
1264
  .on('mousemove', function (event) {
1063
1265
  const index = Number(this.parentElement.dataset['groupId']);
1064
- self.tooltipBuilder.showBarTooltip(event, config.isStacked ?
1065
- config.thresholds[index].data[0] :
1066
- config.thresholds[index], config.tickFormat || PcacFormatEnum.None);
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 });
1067
1270
  })
1068
1271
  .transition()
1069
1272
  .duration(this.transitionService.getTransitionDuration())
@@ -1077,10 +1280,12 @@ class BarVerticalChartBuilder extends PcacChart {
1077
1280
  .attr('data-group-threshold-id', (_, i) => {
1078
1281
  return i;
1079
1282
  })
1080
- .on('mousemove', function (event, _) {
1283
+ .on('mousemove', function (event) {
1081
1284
  const target = event.target;
1082
1285
  const index = Number(target.getAttribute("data-group-threshold-id"));
1083
- self.tooltipBuilder.showBarTooltip(event, config.thresholds[Number(this.parentElement.dataset['groupId'])].data[index], config.tickFormat || PcacFormatEnum.None);
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 });
1084
1289
  })
1085
1290
  .attr('width', this.xScaleGrouped.bandwidth())
1086
1291
  .transition()
@@ -1112,7 +1317,7 @@ class BarVerticalChartBuilder extends PcacChart {
1112
1317
  return 2;
1113
1318
  })
1114
1319
  .on('mouseout', () => {
1115
- this.tooltipBuilder.hideTooltip();
1320
+ this.hideTooltip();
1116
1321
  })
1117
1322
  .attr('height', () => {
1118
1323
  return '3px';
@@ -1132,11 +1337,20 @@ class PcacBarVerticalChartComponent {
1132
1337
  chartElm = viewChild.required('chart', /* @ts-ignore */
1133
1338
  ...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
1134
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 */ []));
1135
1346
  constructor() {
1136
1347
  // Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
1137
1348
  // lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
1138
1349
  // reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
1139
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;
1140
1354
  inject(PcacChartResizeService).observe(this.chartElm, () => {
1141
1355
  // Skip the ResizeObserver's routine initial callback when it lands after the effect above
1142
1356
  // already built successfully at this same width — only a real size change (or a build
@@ -1153,12 +1367,12 @@ class PcacBarVerticalChartComponent {
1153
1367
  }
1154
1368
  }
1155
1369
  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 });
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 });
1157
1371
  }
1158
1372
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacBarVerticalChartComponent, decorators: [{
1159
1373
  type: Component,
1160
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"] }]
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"] }] } });
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 }] }] } });
1162
1376
 
1163
1377
  class PcacBarVerticalChartConfig extends PcacChartConfig {
1164
1378
  domainMax = 100;
@@ -1197,11 +1411,11 @@ class PcacLegend {
1197
1411
  this.itemClicked.emit(items);
1198
1412
  }
1199
1413
  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"] });
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"] });
1201
1415
  }
1202
1416
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLegend, decorators: [{
1203
1417
  type: Component,
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"] }]
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"] }]
1205
1419
  }], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }, { type: i0.Output, args: ["configChange"] }], itemClicked: [{ type: i0.Output, args: ["itemClicked"] }] } });
1206
1420
 
1207
1421
  var PcacLineAreaPlotChartConfigType;
@@ -1261,7 +1475,13 @@ class PlaChartEffectsBuilder {
1261
1475
  buildEffects(config) {
1262
1476
  this.config = config;
1263
1477
  this.lines = [];
1264
- this.config.svg.selectAll('.line, .area').each((d, i, n) => {
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) => {
1265
1485
  this.lines.push(n[i]);
1266
1486
  });
1267
1487
  this.buildCollection();
@@ -1505,6 +1725,7 @@ class PlaChartBuilder extends PcacChart {
1505
1725
  hide: false,
1506
1726
  data: []
1507
1727
  }));
1728
+ this.resetMargin();
1508
1729
  if (this.config.hideAxis) {
1509
1730
  this.config.height = this.config.height + 12;
1510
1731
  this.margin.top = 8;
@@ -1525,9 +1746,9 @@ class PlaChartBuilder extends PcacChart {
1525
1746
  this.clipBuffer = this.config.data.some((series) => series.data.some((point) => !!point.image))
1526
1747
  ? Math.max(10, Math.ceil(this.pointImage.maxWidth / 2), Math.ceil(this.pointImage.maxHeight / 2))
1527
1748
  : 10;
1528
- this.scales = new PlaChartScalesBuilder().build(config, this.width, this.height);
1529
- this.lineGenerator = buildLineGenerator(config.xFormat, this.scales);
1530
- this.areaGenerator = buildAreaGenerator(config.xFormat, this.scales, this.height);
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);
1531
1752
  if (this.config.enableZoom) {
1532
1753
  this.zoomBehavior = buildZoomBehavior(this.width, this.height, (event) => {
1533
1754
  // Rescale x
@@ -1542,11 +1763,16 @@ class PlaChartBuilder extends PcacChart {
1542
1763
  yFormat: this.config.yFormat,
1543
1764
  xFormat: this.config.xFormat
1544
1765
  });
1545
- // Update lines/areas
1546
- this.svg.selectAll('.line')
1547
- .attr('d', (d) => this.lineGenerator.x((_, i) => newX(i))(d));
1548
- this.svg.selectAll('.area')
1549
- .attr('d', (d) => this.areaGenerator.x((_, i) => newX(i))(d));
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));
1550
1776
  // Update dots / point images. Nested selectAll (not a flat svg.selectAll('.point')) so
1551
1777
  // that `i` is the point's index *within its own series* - the xFormat default
1552
1778
  // (DatasetLength) positions by index, and a flat selection would number every series'
@@ -1634,7 +1860,7 @@ class PlaChartBuilder extends PcacChart {
1634
1860
  drawLineArea(config, type) {
1635
1861
  for (let i = 0; i < config.data.length; i++) {
1636
1862
  if (type === PcacLineAreaPlotChartConfigType.Area) {
1637
- this.drawArea(config.data[i].data, i);
1863
+ this.drawArea(config.data[i].data, i, config.data[i].hide);
1638
1864
  }
1639
1865
  else if (type === PcacLineAreaPlotChartConfigType.Line) {
1640
1866
  this.drawLine(config.data[i].data, i, config.data[i].hide);
@@ -1658,13 +1884,16 @@ class PlaChartBuilder extends PcacChart {
1658
1884
  .attr('fill', 'none')
1659
1885
  .attr('style', () => hide ? 'display: none' : null);
1660
1886
  }
1661
- drawArea(lineData, index) {
1887
+ drawArea(lineData, index, hide = false) {
1662
1888
  this.svg.append('g')
1663
1889
  .attr('class', 'areas')
1664
1890
  .attr('clip-path', `url(#${this.clipPathId})`) // <-- apply clip
1665
1891
  .append('path')
1666
1892
  .datum(lineData)
1667
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)
1668
1897
  .style('opacity', 0.5)
1669
1898
  .style('fill', () => {
1670
1899
  return this.colors[index];
@@ -1698,7 +1927,7 @@ class PlaChartBuilder extends PcacChart {
1698
1927
  .attr('class', 'point')
1699
1928
  .attr('transform', (d, i) => this.pointTransform(d, i, this.scales.x))
1700
1929
  .on('mouseover', function (event, d) {
1701
- self.tooltipBuilder.showBarTooltip(event, d, self.config.yFormat, self.config.xFormat);
1930
+ self.showTooltip(event, d, { parent: series, valueFormat: self.config.yFormat, keyFormat: self.config.xFormat });
1702
1931
  // No-op for an image point (no circle inside to grow).
1703
1932
  select$1(this).select('.dot')
1704
1933
  .transition()
@@ -1707,7 +1936,7 @@ class PlaChartBuilder extends PcacChart {
1707
1936
  .attr('fill', self.colors[index]);
1708
1937
  })
1709
1938
  .on('mouseout', function () {
1710
- self.tooltipBuilder.hideTooltip();
1939
+ self.hideTooltip();
1711
1940
  select$1(this).select('.dot')
1712
1941
  .transition()
1713
1942
  .duration(duration / 3)
@@ -1764,6 +1993,15 @@ class PcacLineAreaChartComponent {
1764
1993
  chartElm = viewChild.required('chart', /* @ts-ignore */
1765
1994
  ...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
1766
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 */ []));
1767
2005
  constructor() {
1768
2006
  // Reacts to config()/type() the same way ngOnChanges used to — reading them here (rather
1769
2007
  // than a lifecycle hook) is what makes this an effect: it tracks whichever signals
@@ -1772,6 +2010,9 @@ class PcacLineAreaChartComponent {
1772
2010
  // is always bound to a constant per wrapper (PcacLineChart/PcacAreaChart/PcacPlotChart), so
1773
2011
  // this is unreachable today, but reacting to it is the more correct behavior regardless.
1774
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();
1775
2016
  inject(PcacChartResizeService).observe(this.chartElm, () => {
1776
2017
  // Skip the ResizeObserver's routine initial callback when it lands after the effect above
1777
2018
  // already built successfully at this same width — only a real size change (or a build
@@ -1788,25 +2029,31 @@ class PcacLineAreaChartComponent {
1788
2029
  }
1789
2030
  }
1790
2031
  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 });
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 });
1792
2033
  }
1793
2034
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, decorators: [{
1794
2035
  type: Component,
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"] }]
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"] }] } });
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 }] }] } });
1797
2038
 
1798
2039
  class PcacPlotChart {
1799
2040
  config = input.required(/* @ts-ignore */
1800
2041
  ...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
1801
2042
  types = PcacLineAreaPlotChartConfigType;
1802
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 */ []));
1803
2050
  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"] }] });
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"] }] });
1805
2052
  }
1806
2053
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPlotChart, decorators: [{
1807
2054
  type: Component,
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)\"/>" }]
1809
- }], 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 }] }] } });
1810
2057
 
1811
2058
  class PcacPlotChartConfig extends PcacLineAreaChartConfig {
1812
2059
  }
@@ -1816,13 +2063,19 @@ class PcacLineChart {
1816
2063
  ...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
1817
2064
  types = PcacLineAreaPlotChartConfigType;
1818
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 */ []));
1819
2072
  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"] }] });
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"] }] });
1821
2074
  }
1822
2075
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineChart, decorators: [{
1823
2076
  type: Component,
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\" />" }]
1825
- }], 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 }] }] } });
1826
2079
 
1827
2080
  class PcacLineChartConfig extends PcacLineAreaChartConfig {
1828
2081
  }
@@ -1832,13 +2085,19 @@ class PcacAreaChart {
1832
2085
  ...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
1833
2086
  types = PcacLineAreaPlotChartConfigType;
1834
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 */ []));
1835
2094
  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"] }] });
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"] }] });
1837
2096
  }
1838
2097
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacAreaChart, decorators: [{
1839
2098
  type: Component,
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\" />" }]
1841
- }], 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 }] }] } });
1842
2101
 
1843
2102
  class PcacAreaChartConfig extends PcacLineAreaChartConfig {
1844
2103
  }
@@ -1911,10 +2170,10 @@ class PieChartBuilder extends PcacChart {
1911
2170
  .style('fill', ct);
1912
2171
  })
1913
2172
  .on('mousemove', (event, d) => {
1914
- self.tooltipBuilder.showBarTooltip(event, d.data);
2173
+ self.showTooltip(event, d.data);
1915
2174
  })
1916
2175
  .on('mouseout', function (_, d) {
1917
- self.tooltipBuilder.hideTooltip();
2176
+ self.hideTooltip();
1918
2177
  select$1(this)
1919
2178
  .transition()
1920
2179
  .duration(self.transitionService.getTransitionDuration() / 3)
@@ -1951,11 +2210,20 @@ class PcacPieChartComponent {
1951
2210
  chartElm = viewChild.required('chart', /* @ts-ignore */
1952
2211
  ...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
1953
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 */ []));
1954
2219
  constructor() {
1955
2220
  // Reacts to config() the same way ngOnChanges used to — reading it here (rather than a
1956
2221
  // lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
1957
2222
  // reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
1958
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;
1959
2227
  inject(PcacChartResizeService).observe(this.chartElm, () => {
1960
2228
  // Skip the ResizeObserver's routine initial callback when it lands after the effect above
1961
2229
  // already built successfully at this same width — only a real size change (or a build
@@ -1972,12 +2240,12 @@ class PcacPieChartComponent {
1972
2240
  }
1973
2241
  }
1974
2242
  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 });
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 });
1976
2244
  }
1977
2245
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacPieChartComponent, decorators: [{
1978
2246
  type: Component,
1979
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"] }]
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"] }] } });
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 }] }] } });
1981
2249
 
1982
2250
  class PcacPieChartConfig extends PcacChartConfig {
1983
2251
  numberOfTicks = 5;
@@ -1991,5 +2259,5 @@ class PcacPieChartConfig extends PcacChartConfig {
1991
2259
  * Generated bundle index. Do not edit.
1992
2260
  */
1993
2261
 
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 };
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 };
1995
2263
  //# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map