@pioneer-code/pioneer-charts 22.2.7 → 22.2.11

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.
@@ -222,6 +222,34 @@ class PcacData {
222
222
  * existing object-literal / JSON data doesn't have to declare it.
223
223
  */
224
224
  image;
225
+ /**
226
+ * The span this point's `key` / `value` stands for, when the point is really the middle of a
227
+ * range: `x` for the key, `y` for the value, either or both. Currently honored by the
228
+ * line/area/plot charts only, on the innermost (point-level) `PcacData`, and only drawn when
229
+ * the chart config turns `pointRange` on (see `PcacPointRangeConfig`). Nothing is labeled on
230
+ * the chart; a custom tooltip can read it off the point.
231
+ *
232
+ * Optional for the same reason as `image`.
233
+ */
234
+ range;
235
+ }
236
+ /**
237
+ * One side of a `PcacDataRange`. `min` above `max` is read as the other way round; `min` equal to
238
+ * `max` (or either missing) as no range on that axis.
239
+ */
240
+ class PcacRangeBounds {
241
+ min;
242
+ max;
243
+ }
244
+ /**
245
+ * `PcacData.range`. `x` is read the way the point's `key` is, per the chart's `xAxis.format`: a
246
+ * number for `Decimal`, anything `new Date()` accepts for `DateTime`, and for every index-based
247
+ * format a (possibly fractional) index - `{ min: 2.5, max: 3.5 }` is half a slot either side of
248
+ * the fourth point. `y` is on the value axis.
249
+ */
250
+ class PcacDataRange {
251
+ x;
252
+ y;
225
253
  }
226
254
  var PcacFormatEnum;
227
255
  (function (PcacFormatEnum) {
@@ -561,19 +589,27 @@ class PcacTooltipBuilder {
561
589
  */
562
590
  view = null;
563
591
  viewTemplate = null;
592
+ /** Space left between the tooltip and whatever it's placed next to (the cursor or an anchor). */
593
+ static GAP = 8;
564
594
  /**
565
- * Shows the tooltip for a hovered datum at the event's position. Renders `template` when the
566
- * chart has one projected; otherwise falls back to the default key/value content, formatted per
567
- * `valueFormat`/`keyFormat`.
595
+ * Shows the tooltip for a hovered datum. Renders `template` when the chart has one projected;
596
+ * otherwise falls back to the default key/value content, formatted per `valueFormat`/`keyFormat`.
597
+ * Placed beside `anchor` when one is given (see `positionBeside`), else above the event's position.
568
598
  */
569
- showTooltip(event, template, context, valueFormat, keyFormat) {
599
+ showTooltip(event, template, context, valueFormat, keyFormat, anchor) {
570
600
  if (template) {
571
601
  this.renderTemplate(template, context);
572
602
  }
573
603
  else {
574
604
  this.renderDefault(context.$implicit, valueFormat, keyFormat);
575
605
  }
576
- this.position(event);
606
+ const shell = this.measurable();
607
+ if (anchor) {
608
+ this.positionBeside(shell, anchor);
609
+ }
610
+ else {
611
+ this.positionAbove(shell, event);
612
+ }
577
613
  }
578
614
  /**
579
615
  * @deprecated Builders should call `PcacChart.showTooltip()`, which routes through a chart's
@@ -630,14 +666,52 @@ class PcacTooltipBuilder {
630
666
  this.tooltip.html(null);
631
667
  }
632
668
  /**
633
- * Centers the (already rendered) tooltip horizontally on the cursor and sits it just above.
634
- * Measured from the real box rather than fixed offsets so it works for content of any size.
669
+ * Shows the (already rendered) shell at the page's top-left so it can be measured. Left where the
670
+ * last hover put it, a shell near the right edge would be squeezed by its containing block and
671
+ * measure narrower (wrapped) than the content really is once it's moved somewhere with room.
672
+ */
673
+ measurable() {
674
+ return this.tooltip
675
+ .style('left', '0px')
676
+ .style('top', '0px')
677
+ .style('display', 'inline-block')
678
+ .node();
679
+ }
680
+ /**
681
+ * Centers the tooltip horizontally on the cursor and sits it just above. Measured from the real
682
+ * box rather than fixed offsets so it works for content of any size.
635
683
  */
636
- position(event) {
637
- const shell = this.tooltip.style('display', 'inline-block').node();
684
+ positionAbove(shell, event) {
638
685
  this.tooltip
639
686
  .style('left', event.pageX - shell.offsetWidth / 2 + 'px')
640
- .style('top', event.pageY - shell.offsetHeight - 8 + 'px');
687
+ .style('top', event.pageY - shell.offsetHeight - PcacTooltipBuilder.GAP + 'px');
688
+ }
689
+ /**
690
+ * Places the tooltip diagonally off one corner of `anchor`'s rendered box, so it never covers
691
+ * the anchor itself (e.g. a point's image). Prefers above-right - the tooltip's bottom-left
692
+ * corner at the anchor's top-right - and flips each axis independently when the tooltip wouldn't
693
+ * fit in the viewport that way: to the left when there's no room on the right, below when there's
694
+ * no room above. When neither side of an axis fits, it takes whichever side has more room.
695
+ */
696
+ positionBeside(shell, anchor) {
697
+ const gap = PcacTooltipBuilder.GAP;
698
+ const box = anchor.getBoundingClientRect();
699
+ const width = shell.offsetWidth;
700
+ const height = shell.offsetHeight;
701
+ // `clientWidth`/`clientHeight` of the root, unlike `innerWidth`/`innerHeight`, exclude scrollbars.
702
+ const viewport = document.documentElement;
703
+ const right = viewport.clientWidth - box.right - gap;
704
+ const left = box.left - gap;
705
+ const above = box.top - gap;
706
+ const below = viewport.clientHeight - box.bottom - gap;
707
+ const toRight = width <= right || (width > left && right >= left);
708
+ const toTop = height <= above || (height > below && above >= below);
709
+ const x = toRight ? box.right + gap : box.left - gap - width;
710
+ const y = toTop ? box.top - gap - height : box.bottom + gap;
711
+ // The rect is in viewport coordinates; the shell is absolutely positioned against the page.
712
+ this.tooltip
713
+ .style('left', x + window.scrollX + 'px')
714
+ .style('top', y + window.scrollY + 'px');
641
715
  }
642
716
  getBarTipData(data, valueFormat, keyFormat) {
643
717
  let value = data.value;
@@ -898,7 +972,7 @@ class PcacChart {
898
972
  index: options.index,
899
973
  parentIndex: options.parentIndex ?? null,
900
974
  coincident: options.coincident ?? [],
901
- }, options.valueFormat, options.keyFormat);
975
+ }, options.valueFormat, options.keyFormat, options.anchor);
902
976
  }
903
977
  hideTooltip() {
904
978
  this.tooltipBuilder.hideTooltip();
@@ -1835,6 +1909,47 @@ class PcacPointImageConfig {
1835
1909
  maxWidth = 16;
1836
1910
  maxHeight = 16;
1837
1911
  }
1912
+ /** How a point's `range` is drawn (see `PcacPointRangeConfig.style`). */
1913
+ var PcacPointRangeStyle;
1914
+ (function (PcacPointRangeStyle) {
1915
+ /** Error bars: a line across each range, capped at both ends. */
1916
+ PcacPointRangeStyle["Whiskers"] = "whiskers";
1917
+ /** A rectangle spanning the x range by the y range; a thin strip when only one is set. */
1918
+ PcacPointRangeStyle["Box"] = "box";
1919
+ /**
1920
+ * A fill strongest at the point's value and fading out to the range's edges: an oval glow
1921
+ * with both ranges (brightest on the value, even off-center), a fading bar with one.
1922
+ */
1923
+ PcacPointRangeStyle["Fade"] = "fade";
1924
+ })(PcacPointRangeStyle || (PcacPointRangeStyle = {}));
1925
+ /** When a point's `range` shows (see `PcacPointRangeConfig.show`). */
1926
+ var PcacPointRangeShow;
1927
+ (function (PcacPointRangeShow) {
1928
+ /** Only the hovered point's range. */
1929
+ PcacPointRangeShow["Hover"] = "hover";
1930
+ /** Every range at `faintOpacity`, the hovered point's at full strength. */
1931
+ PcacPointRangeShow["Faint"] = "faint";
1932
+ /** Every range at full strength; the others dim while a point is hovered. */
1933
+ PcacPointRangeShow["Always"] = "always";
1934
+ })(PcacPointRangeShow || (PcacPointRangeShow = {}));
1935
+ /**
1936
+ * Drawing for `PcacData.range` on the line/area/plot charts. Ranges sit above the lines/areas and
1937
+ * below the points, on the point's true coordinate (a fanned-out point's range stays on its
1938
+ * anchor), clipped to the plot area and following zoom. The chart draws no numbers for them; a
1939
+ * custom tooltip gets the point, `range` included.
1940
+ */
1941
+ class PcacPointRangeConfig {
1942
+ style = PcacPointRangeStyle.Whiskers;
1943
+ show = PcacPointRangeShow.Faint;
1944
+ /** Opacity of the ranges at rest under `show: Faint`, 0 - 1. */
1945
+ faintOpacity = 0.2;
1946
+ /**
1947
+ * Any CSS color for every range on the chart. Unset, each takes its series' color. Applied as
1948
+ * `--pcac-point-range-color` on the chart's `.point-ranges` group, so a stylesheet can set it
1949
+ * on an ancestor instead (a config value wins).
1950
+ */
1951
+ color;
1952
+ }
1838
1953
  /**
1839
1954
  * The axes' `format` and `domainMin`/`domainMax` (`PcacAxisConfig`) do more here than on the bar
1840
1955
  * charts. `yAxis.domainMin`/`domainMax` are the y scale's domain (default 0..100). `xAxis.format`
@@ -1863,6 +1978,11 @@ class PcacLineAreaChartConfig extends PcacAxisChartConfig {
1863
1978
  * on their data still gets a sensibly-sized result.
1864
1979
  */
1865
1980
  pointImage;
1981
+ /**
1982
+ * Draw each point's `range` (see `PcacData.range`). Off when not set; `{}` turns it on with
1983
+ * every `PcacPointRangeConfig` default. Points without a `range` draw nothing extra.
1984
+ */
1985
+ pointRange;
1866
1986
  }
1867
1987
 
1868
1988
  /**
@@ -2170,6 +2290,161 @@ function buildZoomBehavior(width, height, zoomedFn) {
2170
2290
  .on("zoom", zoomedFn);
2171
2291
  }
2172
2292
 
2293
+ /** Half the length of a whisker's end cap, in px. */
2294
+ const RANGE_CAP = 5;
2295
+ /** How thick a box is drawn along an axis the point has no range on, in px. */
2296
+ const RANGE_STRIP = 4;
2297
+ /** How thick a fade is drawn along an axis the point has no range on, in px. */
2298
+ const RANGE_FADE_BAR = 10;
2299
+ /**
2300
+ * Where an x range bound lands, read the way `getXFormat` reads a key: a date for `DateTime`, a
2301
+ * number for `Decimal`, and a (possibly fractional) index for every index-based format. `NaN`
2302
+ * for anything that doesn't parse.
2303
+ */
2304
+ function xBound(value, format, scales) {
2305
+ if (value === null || value === undefined || value === '') {
2306
+ return NaN;
2307
+ }
2308
+ if (format === PcacFormatEnum.DateTime) {
2309
+ return scales.x(new Date(value));
2310
+ }
2311
+ return scales.x(Number(value));
2312
+ }
2313
+ /**
2314
+ * Sorts a pair of pixel bounds, or returns nothing if either isn't a real number - or if they're
2315
+ * the same, since a range that doesn't span anything has nothing to draw (whiskers would be a
2316
+ * stray pair of caps, a box or fade zero-sized).
2317
+ */
2318
+ function span(a, b) {
2319
+ if (!Number.isFinite(a) || !Number.isFinite(b) || a === b) {
2320
+ return undefined;
2321
+ }
2322
+ return a <= b ? [a, b] : [b, a];
2323
+ }
2324
+ /**
2325
+ * `d`'s range at these scales, drawn around `(cx, cy)` - the point's true coordinate - or `null`
2326
+ * when it has no range on either axis that can be placed.
2327
+ */
2328
+ function rangeExtent(d, cx, cy, format, scales) {
2329
+ const range = d.range;
2330
+ if (!range) {
2331
+ return null;
2332
+ }
2333
+ const xs = range.x ? span(xBound(range.x.min, format, scales), xBound(range.x.max, format, scales)) : undefined;
2334
+ const ys = range.y ? span(scales.y(Number(range.y.min)), scales.y(Number(range.y.max))) : undefined;
2335
+ if (!xs && !ys) {
2336
+ return null;
2337
+ }
2338
+ const extent = { cx, cy };
2339
+ if (xs) {
2340
+ [extent.x0, extent.x1] = xs;
2341
+ }
2342
+ if (ys) {
2343
+ [extent.y0, extent.y1] = ys;
2344
+ }
2345
+ return extent;
2346
+ }
2347
+ /**
2348
+ * Where the point sits within its range's box, as 0 - 1 fractions: the fade's brightest spot.
2349
+ * An axis without a range has the point in the middle.
2350
+ */
2351
+ function rangeFocus(extent) {
2352
+ const fraction = (v, lo, hi) => lo === undefined || hi === undefined || hi === lo ? 0.5 : Math.min(1, Math.max(0, (v - lo) / (hi - lo)));
2353
+ return { fx: fraction(extent.cx, extent.x0, extent.x1), fy: fraction(extent.cy, extent.y0, extent.y1) };
2354
+ }
2355
+ /**
2356
+ * (Re)draws one point's range into `group`, in plot coordinates, replacing whatever was there -
2357
+ * the same call serves the first draw and every zoom. `gradientId` must be unique in the page;
2358
+ * only the fade uses it. Colors, stroke widths and opacity all come from the theme (see
2359
+ * plot-line-area-chart.component.scss), so nothing here depends on the series.
2360
+ */
2361
+ function drawRange(group, extent, style, gradientId) {
2362
+ group.selectAll('*').remove();
2363
+ const { cx, cy, x0, x1, y0, y1 } = extent;
2364
+ switch (style) {
2365
+ case PcacPointRangeStyle.Box: {
2366
+ const left = x0 ?? cx - RANGE_STRIP / 2;
2367
+ const right = x1 ?? cx + RANGE_STRIP / 2;
2368
+ const top = y0 ?? cy - RANGE_STRIP / 2;
2369
+ const bottom = y1 ?? cy + RANGE_STRIP / 2;
2370
+ group.append('rect')
2371
+ .attr('class', 'point-range-box')
2372
+ .attr('x', left)
2373
+ .attr('y', top)
2374
+ .attr('width', right - left)
2375
+ .attr('height', bottom - top)
2376
+ .attr('rx', 2);
2377
+ return;
2378
+ }
2379
+ case PcacPointRangeStyle.Fade: {
2380
+ const { fx, fy } = rangeFocus(extent);
2381
+ const stops = (gradient, offsets) => {
2382
+ for (const [offset, opacity] of offsets) {
2383
+ gradient.append('stop')
2384
+ .attr('class', 'point-range-stop')
2385
+ .attr('offset', offset)
2386
+ .attr('stop-opacity', opacity);
2387
+ }
2388
+ };
2389
+ // The gradient lives inside the point's own group, not the chart's <defs>, so its stops
2390
+ // inherit the color custom properties set on the series group above it. Sized in
2391
+ // objectBoundingBox units, so the brightest spot stays on the point as zoom stretches it.
2392
+ const defs = group.append('defs');
2393
+ if (x0 !== undefined && x1 !== undefined && y0 !== undefined && y1 !== undefined) {
2394
+ const gradient = defs.append('radialGradient')
2395
+ .attr('id', gradientId)
2396
+ .attr('cx', 0.5).attr('cy', 0.5).attr('r', 0.5)
2397
+ .attr('fx', fx).attr('fy', fy);
2398
+ stops(gradient, [[0, 0.8], [0.5, 0.35], [1, 0]]);
2399
+ group.append('ellipse')
2400
+ .attr('class', 'point-range-fade')
2401
+ .attr('cx', (x0 + x1) / 2)
2402
+ .attr('cy', (y0 + y1) / 2)
2403
+ .attr('rx', (x1 - x0) / 2)
2404
+ .attr('ry', (y1 - y0) / 2)
2405
+ .attr('fill', `url(#${gradientId})`);
2406
+ return;
2407
+ }
2408
+ const vertical = y0 !== undefined && y1 !== undefined;
2409
+ const gradient = defs.append('linearGradient')
2410
+ .attr('id', gradientId)
2411
+ .attr('x1', 0).attr('y1', 0)
2412
+ .attr('x2', vertical ? 0 : 1).attr('y2', vertical ? 1 : 0);
2413
+ stops(gradient, [[0, 0.05], [vertical ? fy : fx, 0.8], [1, 0.05]]);
2414
+ const left = x0 ?? cx - RANGE_FADE_BAR / 2;
2415
+ const right = x1 ?? cx + RANGE_FADE_BAR / 2;
2416
+ const top = y0 ?? cy - RANGE_FADE_BAR / 2;
2417
+ const bottom = y1 ?? cy + RANGE_FADE_BAR / 2;
2418
+ group.append('rect')
2419
+ .attr('class', 'point-range-fade')
2420
+ .attr('x', left)
2421
+ .attr('y', top)
2422
+ .attr('width', right - left)
2423
+ .attr('height', bottom - top)
2424
+ .attr('rx', RANGE_FADE_BAR / 2)
2425
+ .attr('fill', `url(#${gradientId})`);
2426
+ return;
2427
+ }
2428
+ default: {
2429
+ // Whiskers
2430
+ const line = (xa, ya, xb, yb, cls) => group.append('line')
2431
+ .attr('class', cls)
2432
+ .attr('x1', xa).attr('y1', ya)
2433
+ .attr('x2', xb).attr('y2', yb);
2434
+ if (y0 !== undefined && y1 !== undefined) {
2435
+ line(cx, y0, cx, y1, 'point-range-whisker');
2436
+ line(cx - RANGE_CAP, y0, cx + RANGE_CAP, y0, 'point-range-cap');
2437
+ line(cx - RANGE_CAP, y1, cx + RANGE_CAP, y1, 'point-range-cap');
2438
+ }
2439
+ if (x0 !== undefined && x1 !== undefined) {
2440
+ line(x0, cy, x1, cy, 'point-range-whisker');
2441
+ line(x0, cy - RANGE_CAP, x0, cy + RANGE_CAP, 'point-range-cap');
2442
+ line(x1, cy - RANGE_CAP, x1, cy + RANGE_CAP, 'point-range-cap');
2443
+ }
2444
+ }
2445
+ }
2446
+ }
2447
+
2173
2448
  /**
2174
2449
  * Finds every set of points that share a coordinate across all of the chart's visible series.
2175
2450
  * Coincidence is decided from the data rather than from scaled pixels, so this can run before
@@ -2286,6 +2561,17 @@ function clamp(value, min, max) {
2286
2561
  */
2287
2562
  /** Half the theme's 2px line stroke: how far the lines/areas/fan-outs clip-path reaches past the plot. */
2288
2563
  const PLOT_CLIP_ALLOWANCE = 1;
2564
+ /**
2565
+ * Names for the dot's transitions. d3 lets only one transition *per name* run on an element: a
2566
+ * new one cancels the old. The enter rise (`cy`) keeps the default name; the hover grow/shrink
2567
+ * and the entry's size-in (`r`) each get their own, so hovering a dot while the chart is still
2568
+ * animating in no longer cancels its rise and strands it short of its value. Hover interrupts
2569
+ * the size-in explicitly instead, since both tween `r`.
2570
+ */
2571
+ const DOT_GROW_TRANSITION = 'pcac-dot-grow';
2572
+ const DOT_HOVER_TRANSITION = 'pcac-dot-hover';
2573
+ /** See `revealAfterEntry`. */
2574
+ const REVEAL_TRANSITION = 'pcac-reveal';
2289
2575
  class PlaChartBuilder extends PcacChart {
2290
2576
  effectsBuilder = inject(PlaChartEffectsBuilder);
2291
2577
  scales;
@@ -2326,6 +2612,10 @@ class PlaChartBuilder extends PcacChart {
2326
2612
  fanOutOffsets = new Map();
2327
2613
  /** The `.point` group under the cursor, between its mouseover and mouseout (see `leavePoint`). */
2328
2614
  hoveredPoint = null;
2615
+ /** `config.pointRange` with its defaults applied, or `null` while ranges are off. */
2616
+ pointRange = null;
2617
+ /** Each drawn range's `.point-range` group, by its point, so hover can find the one to focus. */
2618
+ rangeGroupOf = new Map();
2329
2619
  dotClicked$ = this.dotClickedSource.asObservable();
2330
2620
  buildChart(chartElm, config, type) {
2331
2621
  if (!config?.data?.length) {
@@ -2345,6 +2635,7 @@ class PlaChartBuilder extends PcacChart {
2345
2635
  this.initializeAxisState(this.config, 'y', 8);
2346
2636
  this.resolvePointLayout(type);
2347
2637
  this.reservePointSpace();
2638
+ this.pointRange = this.config.pointRange ? { ...new PcacPointRangeConfig(), ...this.config.pointRange } : null;
2348
2639
  if (!this.initializeChartState(chartElm, this.config)) {
2349
2640
  return;
2350
2641
  }
@@ -2412,8 +2703,12 @@ class PlaChartBuilder extends PcacChart {
2412
2703
  if (this.config.enableEffects) {
2413
2704
  this.effectsBuilder.updateScales(newX, newY);
2414
2705
  }
2706
+ // Ranges are drawn in plot coordinates rather than hung off a translate, so every one is
2707
+ // redrawn against the zoomed scales.
2708
+ this.updatePointRanges(zoomedScales);
2415
2709
  // Redrawing an axis appends it at the end of the group, above the dots; put them back
2416
2710
  // on top so a point on the baseline isn't covered (see drawChart's draw order).
2711
+ this.svg.selectAll('.point-ranges').raise();
2417
2712
  this.svg.selectAll('.fan-outs').raise();
2418
2713
  this.svg.selectAll('.dots').raise();
2419
2714
  });
@@ -2440,8 +2735,10 @@ class PlaChartBuilder extends PcacChart {
2440
2735
  }
2441
2736
  // Axes above the lines/areas (so an axis line isn't covered by a series sitting at x = 0),
2442
2737
  // but the dots above the axes: a point on the baseline or the y axis stays whole. Fan-out
2443
- // spokes go between the two so they run underneath the points they lead to.
2738
+ // spokes go between the two so they run underneath the points they lead to, and point
2739
+ // ranges under those.
2444
2740
  this.axisBuilder.raiseAxes(this.svg);
2741
+ this.drawPointRanges();
2445
2742
  this.drawFanOuts();
2446
2743
  this.drawDots(config);
2447
2744
  }
@@ -2592,6 +2889,80 @@ class PlaChartBuilder extends PcacChart {
2592
2889
  .duration(this.transitionService.getTransitionDuration())
2593
2890
  .attr('d', this.areaGenerator);
2594
2891
  }
2892
+ /**
2893
+ * Draws one `<g class="point-ranges">` holding a group per series and, inside it, a
2894
+ * `<g class="point-range">` per point that has a `range` - only while `pointRange` is on. Clipped
2895
+ * to the plot area and deaf to the pointer, so it never gets in the way of hover or zoom. When
2896
+ * each range shows is entirely the theme's business, driven by classes: `pcac-range-<show>` on
2897
+ * the outer group sets the resting opacity, and hover (`focusPointRange`) marks the hovered
2898
+ * point's range `is-focused` and the outer group `has-focus`. The colors are custom properties
2899
+ * - the series' own on its group, `color` (when set) on the outer one, which wins - see
2900
+ * plot-line-area-chart.component.scss.
2901
+ */
2902
+ drawPointRanges() {
2903
+ this.rangeGroupOf = new Map();
2904
+ if (!this.pointRange) {
2905
+ return;
2906
+ }
2907
+ const { show, faintOpacity, color } = this.pointRange;
2908
+ const layer = this.svg.append('g')
2909
+ .attr('class', `point-ranges pcac-range-${show}`)
2910
+ .attr('clip-path', `url(#${this.plotClipPathId})`)
2911
+ .attr('pointer-events', 'none')
2912
+ .style('--pcac-point-range-color', () => color ?? null)
2913
+ .style('--pcac-point-range-faint-opacity', () => faintOpacity);
2914
+ this.config.data.forEach((series, seriesIndex) => {
2915
+ const seriesGroup = layer.append('g')
2916
+ .attr('class', 'point-range-series')
2917
+ .style('--pcac-point-range-series-color', () => this.colors[seriesIndex])
2918
+ .style('display', () => series.hide ? 'none' : null);
2919
+ series.data.forEach((point) => {
2920
+ if (point.range) {
2921
+ this.rangeGroupOf.set(point, seriesGroup.append('g').attr('class', 'point-range').node());
2922
+ }
2923
+ });
2924
+ });
2925
+ this.updatePointRanges(this.scales);
2926
+ this.revealAfterEntry(layer);
2927
+ }
2928
+ /**
2929
+ * Draws every range against `scales`, around its point's true coordinate - a fanned-out point's
2930
+ * range stays on the anchor, not on the ring. A range with nothing placeable is left empty.
2931
+ */
2932
+ updatePointRanges(scales) {
2933
+ if (!this.pointRange) {
2934
+ return;
2935
+ }
2936
+ const style = this.pointRange.style;
2937
+ this.config.data.forEach((series, seriesIndex) => {
2938
+ series.data.forEach((point, index) => {
2939
+ const node = this.rangeGroupOf.get(point);
2940
+ if (!node) {
2941
+ return;
2942
+ }
2943
+ const group = select$1(node);
2944
+ const { x, y } = this.pointPosition(point, index, scales);
2945
+ const extent = rangeExtent(point, x, y, this.xAxis.format, scales);
2946
+ if (!extent) {
2947
+ group.selectAll('*').remove();
2948
+ return;
2949
+ }
2950
+ drawRange(group, extent, style, `${this.plotClipPathId}-range-${seriesIndex}-${index}`);
2951
+ });
2952
+ });
2953
+ }
2954
+ /** Brings `d`'s range forward (see `drawPointRanges`), or with `null` puts every range back to rest. */
2955
+ focusPointRange(d) {
2956
+ if (!this.pointRange || !this.svg) {
2957
+ return;
2958
+ }
2959
+ this.svg.selectAll('.point-range.is-focused').classed('is-focused', false);
2960
+ const node = d ? this.rangeGroupOf.get(d) : undefined;
2961
+ if (node) {
2962
+ select$1(node).classed('is-focused', true);
2963
+ }
2964
+ this.svg.select('.point-ranges').classed('has-focus', !!node);
2965
+ }
2595
2966
  /**
2596
2967
  * Draws one `<g class="fan-outs">` holding a `<g class="fan-out">` per group of coincident
2597
2968
  * points: a spoke from the shared coordinate to where each member is drawn, and an anchor dot
@@ -2629,9 +3000,20 @@ class PlaChartBuilder extends PcacChart {
2629
3000
  groups.append('circle')
2630
3001
  .attr('class', 'fan-out-anchor')
2631
3002
  .attr('r', 3);
2632
- groups.attr('opacity', 0)
2633
- .transition()
2634
- .duration(this.transitionService.getTransitionDuration())
3003
+ this.revealAfterEntry(groups);
3004
+ }
3005
+ /**
3006
+ * Keeps `selection` hidden while the points rise in from the baseline, then fades it in. For
3007
+ * the guides drawn around the points (fan-out spokes and anchors, point ranges): they're drawn
3008
+ * where the points end up, so showing them during the rise has them pointing at empty space.
3009
+ * Its own transition name so that nothing else animating the same element cancels it.
3010
+ */
3011
+ revealAfterEntry(selection) {
3012
+ const duration = this.transitionService.getTransitionDuration();
3013
+ selection.attr('opacity', 0)
3014
+ .transition(REVEAL_TRANSITION)
3015
+ .delay(duration)
3016
+ .duration(duration / 3)
2635
3017
  .attr('opacity', 1);
2636
3018
  }
2637
3019
  /**
@@ -2665,6 +3047,7 @@ class PlaChartBuilder extends PcacChart {
2665
3047
  .attr('display', (d, i) => this.pointDisplay(d, i, this.scales))
2666
3048
  .on('mouseover', function (event, d) {
2667
3049
  self.hoveredPoint = this;
3050
+ self.focusPointRange(d);
2668
3051
  // `d` is the very element bound from `series.data` above, so identity lookup is exact.
2669
3052
  self.showTooltip(event, d, {
2670
3053
  index: series.data.indexOf(d),
@@ -2673,10 +3056,15 @@ class PlaChartBuilder extends PcacChart {
2673
3056
  coincident: self.coincidentWith(d),
2674
3057
  valueFormat: self.yAxis.format,
2675
3058
  keyFormat: self.xAxis.format,
3059
+ // The dot or image itself rather than the group, so the tooltip clears what's drawn.
3060
+ anchor: select$1(this).select('.dot, .dot-image').node(),
2676
3061
  });
2677
- // No-op for an image point (no circle inside to grow).
3062
+ // No-op for an image point (no circle inside to grow). Its own transition name, so it
3063
+ // runs alongside the enter rise rather than cancelling it (see DOT_HOVER_TRANSITION);
3064
+ // it only takes over the entry's size tween, which it would otherwise fight over `r`.
2678
3065
  select$1(this).select('.dot')
2679
- .transition()
3066
+ .interrupt(DOT_GROW_TRANSITION)
3067
+ .transition(DOT_HOVER_TRANSITION)
2680
3068
  .duration(duration / 3)
2681
3069
  .attr('r', 6)
2682
3070
  .attr('fill', self.colors[index]);
@@ -2692,9 +3080,11 @@ class PlaChartBuilder extends PcacChart {
2692
3080
  .attr('cx', (d) => this.offsetOf(d).dx)
2693
3081
  .attr('cy', rise)
2694
3082
  .attr('fill', '#fff')
2695
- .transition()
3083
+ .call((dots) => dots.transition()
3084
+ .duration(duration)
3085
+ .attr('cy', (d) => this.offsetOf(d).dy))
3086
+ .transition(DOT_GROW_TRANSITION)
2696
3087
  .duration(duration)
2697
- .attr('cy', (d) => this.offsetOf(d).dy)
2698
3088
  .attr('r', 4);
2699
3089
  // `preserveAspectRatio="xMidYMid meet"` is what does the "resize to fit" - the image is
2700
3090
  // scaled uniformly to fit inside the maxWidth x maxHeight box and centered within it, so
@@ -2727,8 +3117,10 @@ class PlaChartBuilder extends PcacChart {
2727
3117
  const point = this.hoveredPoint;
2728
3118
  this.hoveredPoint = null;
2729
3119
  this.hideTooltip();
3120
+ this.focusPointRange(null);
2730
3121
  select$1(point).select('.dot')
2731
- .transition()
3122
+ .interrupt(DOT_GROW_TRANSITION)
3123
+ .transition(DOT_HOVER_TRANSITION)
2732
3124
  .duration(this.transitionService.getTransitionDuration() / 3)
2733
3125
  .attr('r', 4)
2734
3126
  .attr('fill', '#fff');
@@ -2865,11 +3257,11 @@ class PcacLineAreaChartComponent {
2865
3257
  }
2866
3258
  }
2867
3259
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PcacLineAreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2868
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.7", 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 .fan-out-spoke{stroke:var(--pcac-fan-out-spoke-color, #ced4da);stroke-width:1px}.pcac-line-area-chart .fan-out-anchor{fill:var(--pcac-fan-out-anchor-color, #6c757d)}.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 });
3260
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.7", 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 .fan-out-spoke{stroke:var(--pcac-fan-out-spoke-color, #ced4da);stroke-width:1px}.pcac-line-area-chart .fan-out-anchor{fill:var(--pcac-fan-out-anchor-color, #6c757d)}.pcac-line-area-chart .point-ranges .point-range-series{--pcac-point-range-resolved-color: var(--pcac-point-range-color, var(--pcac-point-range-series-color))}.pcac-line-area-chart .point-ranges .point-range{opacity:var(--pcac-point-range-resting-opacity, 1);transition:opacity .15s ease-out}.pcac-line-area-chart .point-ranges .point-range.is-focused{opacity:1}.pcac-line-area-chart .point-ranges.pcac-range-hover{--pcac-point-range-resting-opacity: 0}.pcac-line-area-chart .point-ranges.pcac-range-faint{--pcac-point-range-resting-opacity: var(--pcac-point-range-faint-opacity, .2)}.pcac-line-area-chart .point-ranges.pcac-range-always.has-focus .point-range:not(.is-focused){opacity:.5}.pcac-line-area-chart .point-ranges .point-range-whisker,.pcac-line-area-chart .point-ranges .point-range-cap{stroke:var(--pcac-point-range-resolved-color);stroke-width:1.25px}.pcac-line-area-chart .point-ranges .point-range-box{fill:var(--pcac-point-range-resolved-color);fill-opacity:.1;stroke:var(--pcac-point-range-resolved-color);stroke-opacity:.7;stroke-width:1.25px}.pcac-line-area-chart .point-ranges .point-range-stop{stop-color:var(--pcac-point-range-resolved-color)}.pcac-line-area-chart .point-ranges .is-focused .point-range-whisker,.pcac-line-area-chart .point-ranges .is-focused .point-range-cap,.pcac-line-area-chart .point-ranges .is-focused .point-range-box{stroke-width:1.75px}.pcac-line-area-chart .point-ranges .is-focused .point-range-box{fill-opacity:.18}@media(prefers-reduced-motion:reduce){.pcac-line-area-chart .point-ranges .point-range{transition:none}}.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 });
2869
3261
  }
2870
3262
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PcacLineAreaChartComponent, decorators: [{
2871
3263
  type: Component,
2872
- 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 .fan-out-spoke{stroke:var(--pcac-fan-out-spoke-color, #ced4da);stroke-width:1px}.pcac-line-area-chart .fan-out-anchor{fill:var(--pcac-fan-out-anchor-color, #6c757d)}.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"] }]
3264
+ 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 .fan-out-spoke{stroke:var(--pcac-fan-out-spoke-color, #ced4da);stroke-width:1px}.pcac-line-area-chart .fan-out-anchor{fill:var(--pcac-fan-out-anchor-color, #6c757d)}.pcac-line-area-chart .point-ranges .point-range-series{--pcac-point-range-resolved-color: var(--pcac-point-range-color, var(--pcac-point-range-series-color))}.pcac-line-area-chart .point-ranges .point-range{opacity:var(--pcac-point-range-resting-opacity, 1);transition:opacity .15s ease-out}.pcac-line-area-chart .point-ranges .point-range.is-focused{opacity:1}.pcac-line-area-chart .point-ranges.pcac-range-hover{--pcac-point-range-resting-opacity: 0}.pcac-line-area-chart .point-ranges.pcac-range-faint{--pcac-point-range-resting-opacity: var(--pcac-point-range-faint-opacity, .2)}.pcac-line-area-chart .point-ranges.pcac-range-always.has-focus .point-range:not(.is-focused){opacity:.5}.pcac-line-area-chart .point-ranges .point-range-whisker,.pcac-line-area-chart .point-ranges .point-range-cap{stroke:var(--pcac-point-range-resolved-color);stroke-width:1.25px}.pcac-line-area-chart .point-ranges .point-range-box{fill:var(--pcac-point-range-resolved-color);fill-opacity:.1;stroke:var(--pcac-point-range-resolved-color);stroke-opacity:.7;stroke-width:1.25px}.pcac-line-area-chart .point-ranges .point-range-stop{stop-color:var(--pcac-point-range-resolved-color)}.pcac-line-area-chart .point-ranges .is-focused .point-range-whisker,.pcac-line-area-chart .point-ranges .is-focused .point-range-cap,.pcac-line-area-chart .point-ranges .is-focused .point-range-box{stroke-width:1.75px}.pcac-line-area-chart .point-ranges .is-focused .point-range-box{fill-opacity:.18}@media(prefers-reduced-motion:reduce){.pcac-line-area-chart .point-ranges .point-range{transition:none}}.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"] }]
2873
3265
  }], 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 }] }] } });
2874
3266
 
2875
3267
  class PcacPlotChart {
@@ -2940,7 +3332,8 @@ class PcacAreaChartConfig extends PcacLineAreaChartConfig {
2940
3332
  // export * from './plot-line-area-chart.model';
2941
3333
  // The rest of that model stays internal (the shared PcacLineAreaChartConfig is reached through
2942
3334
  // the per-chart PcacLineChartConfig/PcacAreaChartConfig/PcacPlotChartConfig subclasses), but
2943
- // the point-image sizing type is part of those configs' public shape, so it's exported alone.
3335
+ // the point-image and point-range types are part of those configs' public shape, so they're
3336
+ // exported alone.
2944
3337
 
2945
3338
  /**
2946
3339
  * Provided per-component (see PcacPieChartComponent's `providers`), not root-scoped:
@@ -3091,5 +3484,5 @@ class PcacPieChartConfig extends PcacChartConfig {
3091
3484
  * Generated bundle index. Do not edit.
3092
3485
  */
3093
3486
 
3094
- export { BarHorizontalChartBuilder, BarVerticalChartBuilder, PCAC_AXIS_LABEL_SPACE, PCAC_AXIS_SUB_LABEL_SPACE, PcacAreaChart, PcacAreaChartConfig, PcacAxisBuilder, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChart, PcacChartConfig, PcacChartResizeService, PcacColorService, PcacData, PcacFormatEnum, PcacGridBuilder, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointImageConfig, PcacTooltipBuilder, PcacTooltipDirective, PcacTransitionService, PieChartBuilder, axisLabelSpace, hasAxisSubLabels, resolveAxisConfig };
3487
+ export { BarHorizontalChartBuilder, BarVerticalChartBuilder, PCAC_AXIS_LABEL_SPACE, PCAC_AXIS_SUB_LABEL_SPACE, PcacAreaChart, PcacAreaChartConfig, PcacAxisBuilder, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChart, PcacChartConfig, PcacChartResizeService, PcacColorService, PcacData, PcacDataRange, PcacFormatEnum, PcacGridBuilder, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointImageConfig, PcacPointRangeConfig, PcacPointRangeShow, PcacPointRangeStyle, PcacRangeBounds, PcacTooltipBuilder, PcacTooltipDirective, PcacTransitionService, PieChartBuilder, axisLabelSpace, hasAxisSubLabels, resolveAxisConfig };
3095
3488
  //# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map