@pioneer-code/pioneer-charts 22.2.11 → 22.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/PioneerCode/pioneer-charts.git"
24
24
  },
25
- "version": "22.2.11",
25
+ "version": "22.2.13",
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
28
  "@angular/common": "^22.1.0",
@@ -27,12 +27,23 @@
27
27
 
28
28
  // Each color below is `var(--pcac-*-color, <theme color>)`. A builder sets the property on a
29
29
  // part's group only when the chart's config gives that color (`PcacAxisConfig`'s `*Color` fields,
30
- // `PcacPointFanOutConfig.spokeColor` / `anchorColor`), so a chart without one looks as before. A
30
+ // `PcacPointFanOutConfig.spokeColor` / `anchorColor`, `PcacPieDonutConfig.labelColor` /
31
+ // `subLabelColor`), so a chart without one looks as before. A
31
32
  // stylesheet can set the same property on any ancestor; a config value, on the group itself, wins.
32
33
  .pcac-grid-rule line {
33
34
  stroke: var(--pcac-grid-color, #{imports.$gray-200});
34
35
  }
35
36
 
37
+ // The donut's center text (`PcacPieDonutConfig.labelColor` / `subLabelColor`).
38
+ .pcac-pie-center-label {
39
+ fill: var(--pcac-pie-center-label-color, #{imports.$gray-800});
40
+ font-weight: 500;
41
+ }
42
+
43
+ .pcac-pie-center-sub-label {
44
+ fill: var(--pcac-pie-center-sub-label-color, #{imports.$gray-600});
45
+ }
46
+
36
47
  .pcac-x-axis,
37
48
  .pcac-y-axis {
38
49
 
@@ -18,6 +18,15 @@
18
18
  stroke: var(--pcac-grid-color, #e9ecef);
19
19
  }
20
20
 
21
+ .pcac-pie-center-label {
22
+ fill: var(--pcac-pie-center-label-color, #343a40);
23
+ font-weight: 500;
24
+ }
25
+
26
+ .pcac-pie-center-sub-label {
27
+ fill: var(--pcac-pie-center-sub-label-color, #6c757d);
28
+ }
29
+
21
30
  .pcac-x-axis path,
22
31
  .pcac-x-axis line,
23
32
  .pcac-y-axis path,
@@ -1 +1 @@
1
- .pcac-d3-tooltip{position:absolute;pointer-events:none;display:none;z-index:1000}.pcac-d3-tooltip-default{text-align:center;font-size:14px;padding:.5rem;background-color:rgba(52,58,64,.85);color:#fff;border-radius:2px}.pcac-grid-rule line{stroke:var(--pcac-grid-color, #e9ecef)}.pcac-x-axis path,.pcac-x-axis line,.pcac-y-axis path,.pcac-y-axis line{stroke:none}.pcac-x-axis.pcac-axis-tick-marks .tick line,.pcac-y-axis.pcac-axis-tick-marks .tick line{stroke:var(--pcac-axis-tick-color, #212529)}.pcac-x-axis.pcac-axis-line .domain,.pcac-y-axis.pcac-axis-line .domain{stroke:var(--pcac-axis-line-color, #212529)}.pcac-x-axis .pcac-axis-label,.pcac-y-axis .pcac-axis-label{font-size:12px;font-weight:600;fill:var(--pcac-axis-label-color, #495057)}.pcac-x-axis .pcac-axis-sub-label,.pcac-y-axis .pcac-axis-sub-label{font-size:11px;fill:var(--pcac-axis-sub-label-color, #6c757d)}:where(.pcac-x-axis,.pcac-y-axis) :where(.tick) text{fill:var(--pcac-axis-tick-label-color, currentColor)}
1
+ .pcac-d3-tooltip{position:absolute;pointer-events:none;display:none;z-index:1000}.pcac-d3-tooltip-default{text-align:center;font-size:14px;padding:.5rem;background-color:rgba(52,58,64,.85);color:#fff;border-radius:2px}.pcac-grid-rule line{stroke:var(--pcac-grid-color, #e9ecef)}.pcac-pie-center-label{fill:var(--pcac-pie-center-label-color, #343a40);font-weight:500}.pcac-pie-center-sub-label{fill:var(--pcac-pie-center-sub-label-color, #6c757d)}.pcac-x-axis path,.pcac-x-axis line,.pcac-y-axis path,.pcac-y-axis line{stroke:none}.pcac-x-axis.pcac-axis-tick-marks .tick line,.pcac-y-axis.pcac-axis-tick-marks .tick line{stroke:var(--pcac-axis-tick-color, #212529)}.pcac-x-axis.pcac-axis-line .domain,.pcac-y-axis.pcac-axis-line .domain{stroke:var(--pcac-axis-line-color, #212529)}.pcac-x-axis .pcac-axis-label,.pcac-y-axis .pcac-axis-label{font-size:12px;font-weight:600;fill:var(--pcac-axis-label-color, #495057)}.pcac-x-axis .pcac-axis-sub-label,.pcac-y-axis .pcac-axis-sub-label{font-size:11px;fill:var(--pcac-axis-sub-label-color, #6c757d)}:where(.pcac-x-axis,.pcac-y-axis) :where(.tick) text{fill:var(--pcac-axis-tick-label-color, currentColor)}
@@ -1,8 +1,7 @@
1
1
  import * as rxjs from 'rxjs';
2
2
  import * as i0 from '@angular/core';
3
- import { TemplateRef, ElementRef, Signal } from '@angular/core';
3
+ import { TemplateRef, OnDestroy, ElementRef, Signal } from '@angular/core';
4
4
  import { AxisDomain, AxisScale } from 'd3-axis';
5
- import * as d3_selection from 'd3-selection';
6
5
  import { Selection, BaseType } from 'd3-selection';
7
6
  import * as _pioneer_code_pioneer_charts from '@pioneer-code/pioneer-charts';
8
7
 
@@ -201,6 +200,12 @@ declare class PcacAxisChartConfig extends PcacChartConfig {
201
200
  declare class PcacData {
202
201
  key: string | number | null;
203
202
  value: string | number | null;
203
+ /**
204
+ * Hides the item while keeping its place in the color order, so a `<pcac-legend>` can toggle it
205
+ * without the other items changing color. A line/area/plot series draws no line, area, points or
206
+ * hover effects; a bar (or every bar of a group) is drawn at zero size, keeping its slot; a pie
207
+ * slice takes no angle.
208
+ */
204
209
  hide: boolean;
205
210
  data: PcacData[];
206
211
  /**
@@ -377,8 +382,15 @@ declare class PcacColorService {
377
382
  private warning;
378
383
  private orange;
379
384
  private blue;
380
- private scale;
381
385
  private alert;
386
+ /** A consumer's own scale from `setScale()`; replaces the default palette while set. */
387
+ private customScale;
388
+ /**
389
+ * The palette charts cycle through: the `setScale()` one when given, else the default colors
390
+ * built from the current fields - so a setter like `setSuccess()` changes the charts drawn after
391
+ * it, rather than a copy of the colors taken when the service was created.
392
+ */
393
+ private get scale();
382
394
  /**
383
395
  * Get a scale of colors dynamically
384
396
  * @param numberOfNodes Number of items in dynamically build collection of colors
@@ -386,14 +398,18 @@ declare class PcacColorService {
386
398
  getColorScale(numberOfNodes: number): string[];
387
399
  getAlert(): string;
388
400
  /**
389
- * Set the scale that charts use to set colors of data[x] on the UI.
401
+ * Set the scale that charts use to set colors of data[x] on the UI, in place of the default
402
+ * palette (and of the individual color setters below, which only shape the default). An empty
403
+ * array goes back to the default palette rather than leaving charts with no colors.
390
404
  * @param colors A collection of hex values
391
405
  */
392
406
  setScale(colors: string[]): void;
407
+ /** @deprecated No chart reads the primary color; it isn't part of the palette. */
393
408
  setPrimary(color: string): void;
394
409
  setPrimaryLight(color: string): void;
395
410
  setSuccess(color: string): void;
396
411
  setDanger(color: string): void;
412
+ setWarning(color: string): void;
397
413
  setOrange(color: string): void;
398
414
  setBlue(color: string): void;
399
415
  setAlert(color: string): void;
@@ -512,15 +528,22 @@ declare class PcacTooltipDirective {
512
528
  static ɵdir: i0.ɵɵDirectiveDeclaration<PcacTooltipDirective, "ng-template[pcacTooltip]", never, {}, {}, never, never, true, never>;
513
529
  }
514
530
 
515
- declare class PcacTooltipBuilder {
531
+ declare class PcacTooltipBuilder implements OnDestroy {
516
532
  private appRef;
533
+ private document;
534
+ private shell;
517
535
  /**
518
536
  * One tooltip element shared by every chart on the page, appended to `<body>` so it can float
519
537
  * over anything. It's only ever a positioning shell: the default look (`.pcac-d3-tooltip-default`)
520
538
  * is toggled on when the library renders its own key/value content and off when a consumer's
521
539
  * `<ng-template pcacTooltip>` is rendered into it instead, so a custom template owns the whole box.
540
+ *
541
+ * Created on first use rather than with the service, which every chart builder injects: that
542
+ * way nothing touches the DOM until a chart actually shows a tooltip, so building a chart
543
+ * where there's no browser `document` (server-side rendering) doesn't throw. Removed again in
544
+ * `ngOnDestroy()`, when the app that owns this root service is destroyed.
522
545
  */
523
- tooltip: d3_selection.Selection<HTMLDivElement, unknown, HTMLElement, any>;
546
+ get tooltip(): Selection<HTMLDivElement, unknown, null, undefined>;
524
547
  /**
525
548
  * The consumer template currently rendered into the shell, if any. Created on the first show
526
549
  * of a hover and torn down in `hideTooltip()` - not kept around between hovers - so a view is
@@ -543,6 +566,11 @@ declare class PcacTooltipBuilder {
543
566
  */
544
567
  showBarTooltip(event: MouseEvent, data: PcacData, valueFormat?: PcacFormatEnum, keyFormat?: PcacFormatEnum): void;
545
568
  hideTooltip(): void;
569
+ ngOnDestroy(): void;
570
+ /**
571
+ * The library's own key/value content. Built from text nodes, never parsed as HTML: `key` and
572
+ * `value` are consumer data, and markup in them must show as text rather than run.
573
+ */
546
574
  private renderDefault;
547
575
  private renderTemplate;
548
576
  private destroyView;
@@ -565,6 +593,7 @@ declare class PcacTooltipBuilder {
565
593
  * no room above. When neither side of an axis fits, it takes whichever side has more room.
566
594
  */
567
595
  private positionBeside;
596
+ /** The default tooltip's two lines as plain text; `key` is null when the datum has none. */
568
597
  private getBarTipData;
569
598
  static ɵfac: i0.ɵɵFactoryDeclaration<PcacTooltipBuilder, never>;
570
599
  static ɵprov: i0.ɵɵInjectableDeclaration<any>;
@@ -616,6 +645,15 @@ declare class PcacChart {
616
645
  height: number;
617
646
  colors: string[];
618
647
  startData: PcacData[];
648
+ /**
649
+ * Swaps a consumer's `colorOverride` in for the theme palette `initializeChartState` set, in
650
+ * order. Checks `length` rather than truthiness: every config class defaults its override to
651
+ * `[]`, and an empty array is truthy - taken as an override, it would leave every mark with no
652
+ * color. Cycled out to at least as many entries as the theme palette, the same way that palette
653
+ * cycles its own colors, so an override shorter than the data repeats rather than leaving the
654
+ * marks past its end with an `undefined` color. Call after `initializeChartState()`.
655
+ */
656
+ protected applyColorOverride(override: readonly string[] | undefined): void;
619
657
  /**
620
658
  * Raw, unadjusted container width measured by the last successful `initializeChartState()`
621
659
  * call, or `null` if none has succeeded yet. Deliberately tracked separately from `width`:
@@ -751,6 +789,12 @@ declare class PcacChart {
751
789
  * @param chartElm Reference to SVG on dom
752
790
  * @param config Chart specific configuration
753
791
  */
792
+ /**
793
+ * Removes whatever the chart last drew, for a build with no data to draw. Builders call it
794
+ * rather than just returning, which left the previous data on screen when a consumer emptied
795
+ * the chart (e.g. a filter that now matches nothing).
796
+ */
797
+ clearChart(chartElm: ElementRef): void;
754
798
  initializeChartState(chartElm: ElementRef, config: PcacChartConfig): boolean;
755
799
  /**
756
800
  * `config.height` normally *is* the height of the drawing area. With `config.heightFull` on it
@@ -823,7 +867,9 @@ declare class BarHorizontalChartBuilder extends PcacChart {
823
867
  private addGroups;
824
868
  private drawBarsPerGroup;
825
869
  private drawThresholdAcrossChart;
870
+ /** One threshold across each group that has one; groups without an entry are skipped. */
826
871
  private drawThresholdsPerGroup;
872
+ /** One threshold across each bar that has one; bars without an entry are skipped. */
827
873
  private drawThresholdsPerBarInGroup;
828
874
  private applyPreTransitionThresholdStyles;
829
875
  static ɵfac: i0.ɵɵFactoryDeclaration<BarHorizontalChartBuilder, never>;
@@ -874,7 +920,9 @@ declare class BarVerticalChartBuilder extends PcacChart {
874
920
  private addGroups;
875
921
  private drawBarsPerGroup;
876
922
  private drawThresholdAcrossChart;
923
+ /** One threshold across each group that has one; groups without an entry are skipped. */
877
924
  private drawThresholdsPerGroup;
925
+ /** One threshold across each bar that has one; bars without an entry are skipped. */
878
926
  private drawThresholdsPerBarInGroup;
879
927
  private applyPreTransitionThresholdStyles;
880
928
  static ɵfac: i0.ɵɵFactoryDeclaration<BarVerticalChartBuilder, never>;
@@ -1013,7 +1061,8 @@ declare class PcacLineAreaChartConfig extends PcacAxisChartConfig {
1013
1061
  enableZoomX: boolean;
1014
1062
  enableZoomY: boolean;
1015
1063
  /**
1016
- * Hex color codes to override the default colors
1064
+ * Hex color codes to override the default colors, one per series in order. Repeats from the
1065
+ * start when there are more series than colors, as the default palette does.
1017
1066
  */
1018
1067
  colorOverride: string[];
1019
1068
  /**
@@ -1123,7 +1172,44 @@ declare class PcacAreaChart {
1123
1172
  static ɵcmp: i0.ɵɵComponentDeclaration<PcacAreaChart, "pcac-area-chart", never, { "config": { "alias": "config"; "required": true; "isSignal": true; }; }, { "dotClicked": "dotClicked"; }, ["tooltipTemplate"], never, true, never>;
1124
1173
  }
1125
1174
 
1175
+ /**
1176
+ * Turns the pie into a donut: slices drawn as a ring around an empty center, which can hold a
1177
+ * short label - typically the total the slices add up to.
1178
+ */
1179
+ declare class PcacPieDonutConfig {
1180
+ /**
1181
+ * Radius of the hole as a fraction of the pie's radius, from 0 (a plain pie) to 0.9. Values
1182
+ * outside that range are clamped.
1183
+ */
1184
+ innerRadius: number;
1185
+ /**
1186
+ * Large text centered in the hole, e.g. `'67'`. Sized to the hole and shrunk to fit across it;
1187
+ * left out if it would have to go below 8px. Not drawn when not set.
1188
+ */
1189
+ label?: string;
1190
+ /** Smaller line under `label`, e.g. `'balls'`, fitted the same way. Not drawn when not set. */
1191
+ subLabel?: string;
1192
+ /**
1193
+ * `label` color, any CSS color; theme default `$gray-800`. Applied as
1194
+ * `--pcac-pie-center-label-color` on the chart's `.pcac-pie-center` group, so a stylesheet can
1195
+ * set it on an ancestor instead (a config value wins).
1196
+ */
1197
+ labelColor?: string;
1198
+ /** `subLabel` color, likewise (`--pcac-pie-center-sub-label-color`); theme default `$gray-600`. */
1199
+ subLabelColor?: string;
1200
+ }
1126
1201
  declare class PcacPieChartConfig extends PcacChartConfig {
1202
+ /**
1203
+ * Draw the pie as a donut. Off when not set; `{}` turns it on with every `PcacPieDonutConfig`
1204
+ * default. Slices, hover and `sliceClicked` behave the same either way.
1205
+ */
1206
+ donut?: Partial<PcacPieDonutConfig>;
1207
+ /**
1208
+ * Slice colors, any CSS color, in data order - the first slice takes the first color - in place
1209
+ * of the theme palette. Repeated when there are more slices than colors. Omitted or empty, the
1210
+ * theme palette is used. Match a `<pcac-legend>` to it with each item's `colorOverride`.
1211
+ */
1212
+ colorOverride?: string[];
1127
1213
  }
1128
1214
 
1129
1215
  /**
@@ -1134,6 +1220,7 @@ declare class PcacPieChartConfig extends PcacChartConfig {
1134
1220
  */
1135
1221
  declare class PieChartBuilder extends PcacChart {
1136
1222
  private radius;
1223
+ private innerRadius;
1137
1224
  private arcShape;
1138
1225
  private arcOverShape;
1139
1226
  private pieAngles;
@@ -1142,6 +1229,18 @@ declare class PieChartBuilder extends PcacChart {
1142
1229
  buildChart(chartElm: ElementRef, config: PcacPieChartConfig): void;
1143
1230
  private buildShapes;
1144
1231
  private drawChart;
1232
+ /**
1233
+ * The donut's `label` / `subLabel`, stacked around the center of the hole. Each line starts at a
1234
+ * size proportional to the hole and shrinks until it fits across it; a line that would have to
1235
+ * drop below `MIN_CENTER_FONT_SIZE` is left out rather than spill over the slices. Drawn after
1236
+ * the slices and ignoring the pointer, so it never blocks a slice's hover or click.
1237
+ */
1238
+ private drawCenter;
1239
+ /**
1240
+ * One centered line of the donut's center text at the largest size up to `preferredSize` that
1241
+ * fits `maxWidth`, or nothing (null) when there's no text or it can't fit at a readable size.
1242
+ */
1243
+ private drawCenterLine;
1145
1244
  private tweenChart;
1146
1245
  static ɵfac: i0.ɵɵFactoryDeclaration<PieChartBuilder, never>;
1147
1246
  static ɵprov: i0.ɵɵInjectableDeclaration<any>;
@@ -1163,5 +1262,5 @@ declare class PcacPieChartComponent {
1163
1262
  static ɵcmp: i0.ɵɵComponentDeclaration<PcacPieChartComponent, "pcac-pie-chart", never, { "config": { "alias": "config"; "required": true; "isSignal": true; }; }, { "sliceClicked": "sliceClicked"; }, ["tooltipTemplate"], never, true, never>;
1164
1263
  }
1165
1264
 
1166
- 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 };
1265
+ 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, PcacPieDonutConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointImageConfig, PcacPointRangeConfig, PcacPointRangeShow, PcacPointRangeStyle, PcacRangeBounds, PcacTooltipBuilder, PcacTooltipDirective, PcacTransitionService, PieChartBuilder, axisLabelSpace, hasAxisSubLabels, resolveAxisConfig };
1167
1266
  export type { IPcacAxisBuilderConfig, IPcacGridBuilderConfig, PcacChartMargin, PcacResolvedAxisConfig, PcacTooltipCoincident, PcacTooltipContext, PcacTooltipOptions };