@pioneer-code/pioneer-charts 22.2.13 → 22.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -26,8 +26,9 @@ Guides, the API reference, live examples, and theming instructions all live on t
|
|
|
26
26
|
|
|
27
27
|
## Requirements
|
|
28
28
|
|
|
29
|
-
- Angular ^22.0.0
|
|
30
|
-
|
|
29
|
+
- Angular ^22.1.0 (with RxJS ^7.4.0, which Angular itself needs)
|
|
30
|
+
|
|
31
|
+
The D3 modules the charts use are installed with the package, so there's nothing else to add.
|
|
31
32
|
|
|
32
33
|
## Installation
|
|
33
34
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, inject, ApplicationRef, DOCUMENT, DestroyRef, afterNextRender, TemplateRef, Directive, input, viewChild, contentChild, effect, ViewEncapsulation, Component, model, output, computed } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed, outputFromObservable } from '@angular/core/rxjs-interop';
|
|
3
4
|
import { color } from 'd3-color';
|
|
4
|
-
import { scaleLinear, scaleBand } from 'd3-scale';
|
|
5
|
+
import { scaleLinear, scaleBand, scaleTime } from 'd3-scale';
|
|
5
6
|
import { select } from 'd3-selection';
|
|
6
7
|
import { transition } from 'd3-transition';
|
|
7
8
|
import { Subject } from 'rxjs';
|
|
8
9
|
import { axisLeft, axisBottom } from 'd3-axis';
|
|
9
10
|
import { format } from 'd3-format';
|
|
10
|
-
import { takeUntilDestroyed, outputFromObservable } from '@angular/core/rxjs-interop';
|
|
11
11
|
import { debounceTime } from 'rxjs/operators';
|
|
12
12
|
import { range } from 'd3-array';
|
|
13
|
-
import { scaleTime, zoom } from 'd3';
|
|
14
13
|
import { line, area, arc, pie } from 'd3-shape';
|
|
14
|
+
import { zoom } from 'd3-zoom';
|
|
15
15
|
import { interpolate } from 'd3-interpolate';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -39,6 +39,12 @@ class PcacChartConfig {
|
|
|
39
39
|
* initializer still applies to anything constructed via `new`.
|
|
40
40
|
*/
|
|
41
41
|
heightFull = false;
|
|
42
|
+
/**
|
|
43
|
+
* What the chart shows, for screen readers - e.g. `'Sales by month, 2026'`. The chart's `<svg>` is
|
|
44
|
+
* announced as one image with this name; when it isn't set, the chart's type is used (`'Bar
|
|
45
|
+
* chart'`, `'Pie chart'`, ...). Optional for the same reason as `heightFull`.
|
|
46
|
+
*/
|
|
47
|
+
ariaLabel;
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
44
50
|
* Up to three short labels placed along an axis by position rather than by value: `min` at its
|
|
@@ -267,13 +273,58 @@ var PcacFormatEnum;
|
|
|
267
273
|
PcacFormatEnum["DateTime"] = "dateTime";
|
|
268
274
|
PcacFormatEnum["Fahrenheit"] = "fahrenheit";
|
|
269
275
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* e.g. 0 = 12am, 1 = 1am, 13 = 1pm, 23 = 11pm
|
|
276
|
+
* Hours of the day, 0-24, labelled on a 12 hour clock: 0 = 12am, 1 = 1am, 13 = 1pm, 24 = 12am.
|
|
277
|
+
* A value between hours shows its minutes (2.5 = 2:30am).
|
|
273
278
|
*/
|
|
274
279
|
PcacFormatEnum["OneDayHours"] = "oneDayHours";
|
|
275
280
|
})(PcacFormatEnum || (PcacFormatEnum = {}));
|
|
276
281
|
|
|
282
|
+
/**
|
|
283
|
+
* `Percentage` values are fractions - `0.25` is 25% - on the axis and in the tooltip alike.
|
|
284
|
+
* `~` trims trailing zeros, so 0.07 reads `7%` rather than `7.000000%`.
|
|
285
|
+
*/
|
|
286
|
+
const formatPercent = format('~%');
|
|
287
|
+
/**
|
|
288
|
+
* An hour of the day, 0-24, on a 12-hour clock: 0 and 24 are `12am`, 13 is `1pm`, and a
|
|
289
|
+
* fractional hour gets its minutes (`2.5` is `2:30am`) rather than reading `2.5am`.
|
|
290
|
+
*/
|
|
291
|
+
function formatHourOfDay(value) {
|
|
292
|
+
let totalMinutes = Math.round(value * 60);
|
|
293
|
+
totalMinutes = ((totalMinutes % 1440) + 1440) % 1440;
|
|
294
|
+
const hour24 = Math.floor(totalMinutes / 60);
|
|
295
|
+
const minutes = totalMinutes % 60;
|
|
296
|
+
const hour = hour24 % 12 === 0 ? 12 : hour24 % 12;
|
|
297
|
+
const period = hour24 < 12 ? 'am' : 'pm';
|
|
298
|
+
return minutes === 0 ? `${hour}${period}` : `${hour}:${String(minutes).padStart(2, '0')}${period}`;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The tick label format for an axis in `format`, shared by both axes (so a format means the same
|
|
302
|
+
* thing on x and y) and by anything that labels a value on that axis, like the line/area hover
|
|
303
|
+
* crosshair. Returns null for the formats that keep D3's default labels.
|
|
304
|
+
*
|
|
305
|
+
* Numeric formats take their precision from the scale's tick step where the scale has one: a
|
|
306
|
+
* fixed precision is fine for a whole domain but breaks down once zoom narrows it to a few units.
|
|
307
|
+
*/
|
|
308
|
+
function axisTickFormat(pcacFormat, scale, ticks) {
|
|
309
|
+
const withTicks = scale;
|
|
310
|
+
switch (pcacFormat) {
|
|
311
|
+
case PcacFormatEnum.Percentage:
|
|
312
|
+
return withTicks.tickFormat ? withTicks.tickFormat(ticks, '~%') : (d) => formatPercent(Number(d));
|
|
313
|
+
case PcacFormatEnum.Decimal:
|
|
314
|
+
// Plain numbers with thousands separators - `1,500`, `0.05` - rather than SI prefixes, which
|
|
315
|
+
// turned a differential of 0.05 into `50m` (reading as minutes, like the Minutes format).
|
|
316
|
+
return withTicks.tickFormat ? withTicks.tickFormat(ticks, ',~f') : (d) => format(',~f')(Number(d));
|
|
317
|
+
case PcacFormatEnum.Minutes:
|
|
318
|
+
return (d) => d + 'm';
|
|
319
|
+
case PcacFormatEnum.Fahrenheit:
|
|
320
|
+
return (d) => d + ' F';
|
|
321
|
+
case PcacFormatEnum.OneDayHours:
|
|
322
|
+
return (d) => formatHourOfDay(Number(d));
|
|
323
|
+
default:
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
277
328
|
class PcacAxisBuilder {
|
|
278
329
|
drawAxis(config) {
|
|
279
330
|
this.drawXAxis(config);
|
|
@@ -299,16 +350,9 @@ class PcacAxisBuilder {
|
|
|
299
350
|
if (config.yAxis.tickSize !== undefined) {
|
|
300
351
|
yAxis.tickSizeInner(config.yAxis.tickSize);
|
|
301
352
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
break;
|
|
306
|
-
case PcacFormatEnum.Minutes:
|
|
307
|
-
yAxis.tickFormat((d) => d + 'm');
|
|
308
|
-
break;
|
|
309
|
-
case PcacFormatEnum.Fahrenheit:
|
|
310
|
-
yAxis.tickFormat((d) => d + ' F');
|
|
311
|
-
break;
|
|
353
|
+
const yFormat = axisTickFormat(config.yAxis.format, config.yScale, config.yAxis.ticks);
|
|
354
|
+
if (yFormat) {
|
|
355
|
+
yAxis.tickFormat(yFormat);
|
|
312
356
|
}
|
|
313
357
|
const group = config.svg.append('g')
|
|
314
358
|
.attr('class', 'pcac-y-axis')
|
|
@@ -328,27 +372,9 @@ class PcacAxisBuilder {
|
|
|
328
372
|
if (config.xAxis.tickSize !== undefined) {
|
|
329
373
|
xAxis.tickSizeInner(config.xAxis.tickSize);
|
|
330
374
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
break;
|
|
335
|
-
case PcacFormatEnum.Minutes:
|
|
336
|
-
xAxis.tickFormat((d) => d + 'm');
|
|
337
|
-
break;
|
|
338
|
-
case PcacFormatEnum.Fahrenheit:
|
|
339
|
-
xAxis.tickFormat((d) => d + ' F');
|
|
340
|
-
break;
|
|
341
|
-
case PcacFormatEnum.OneDayHours:
|
|
342
|
-
xAxis.tickFormat((d) => {
|
|
343
|
-
const h = d;
|
|
344
|
-
const hour = h % 12 === 0 ? 12 : h % 12;
|
|
345
|
-
const period = h < 12 ? 'am' : 'pm';
|
|
346
|
-
return `${hour}${period}`;
|
|
347
|
-
});
|
|
348
|
-
break;
|
|
349
|
-
case PcacFormatEnum.Decimal:
|
|
350
|
-
xAxis.tickFormat(decimalTickFormat(config.xScale, config.xAxis.ticks));
|
|
351
|
-
break;
|
|
375
|
+
const xFormat = axisTickFormat(config.xAxis.format, config.xScale, config.xAxis.ticks);
|
|
376
|
+
if (xFormat) {
|
|
377
|
+
xAxis.tickFormat(xFormat);
|
|
352
378
|
}
|
|
353
379
|
const group = config.svg.append('g')
|
|
354
380
|
.attr('class', 'pcac-x-axis')
|
|
@@ -419,20 +445,6 @@ function applyColors(group, axis) {
|
|
|
419
445
|
.style('--pcac-axis-label-color', () => axis.labelColor ?? null)
|
|
420
446
|
.style('--pcac-axis-sub-label-color', () => axis.subLabelColor ?? null);
|
|
421
447
|
}
|
|
422
|
-
/**
|
|
423
|
-
* Tick labels for a `Decimal` axis: SI-prefixed (`1.5k`), with the precision taken from the
|
|
424
|
-
* scale's own tick step rather than fixed. A fixed two significant digits (`.2s`) is fine for a
|
|
425
|
-
* whole domain but breaks down once zoom narrows it to a few units - ticks at 10.5, 11, 11.5, 12
|
|
426
|
-
* all rounded to `10 11 12 12`. `~` trims trailing zeros so a coarse step still reads `5 10 15`,
|
|
427
|
-
* not `5.0 10.0 15.0`. Falls back to the fixed format for a scale without `tickFormat` (a
|
|
428
|
-
* `Decimal` axis is always linear in practice, but the config type only promises `AxisScale`).
|
|
429
|
-
*/
|
|
430
|
-
function decimalTickFormat(scale, ticks) {
|
|
431
|
-
const withTicks = scale;
|
|
432
|
-
const formatTick = withTicks.tickFormat ? withTicks.tickFormat(ticks, '~s') : (d) => format('.2s')(d);
|
|
433
|
-
// The prefix comes from the domain's largest value, which would label the origin `0k`.
|
|
434
|
-
return (d) => (Number(d) === 0 ? '0' : formatTick(d));
|
|
435
|
-
}
|
|
436
448
|
|
|
437
449
|
/** Where along its axis each grid line sits, in pixels. */
|
|
438
450
|
function gridLines(scale, numberOfTicks) {
|
|
@@ -609,7 +621,8 @@ class PcacTooltipBuilder {
|
|
|
609
621
|
get tooltip() {
|
|
610
622
|
this.shell ??= select(this.document.body)
|
|
611
623
|
.append('div')
|
|
612
|
-
.attr('class', 'pcac-d3-tooltip')
|
|
624
|
+
.attr('class', 'pcac-d3-tooltip')
|
|
625
|
+
.attr('role', 'tooltip');
|
|
613
626
|
return this.shell;
|
|
614
627
|
}
|
|
615
628
|
/**
|
|
@@ -620,14 +633,22 @@ class PcacTooltipBuilder {
|
|
|
620
633
|
*/
|
|
621
634
|
view = null;
|
|
622
635
|
viewTemplate = null;
|
|
636
|
+
/**
|
|
637
|
+
* Whatever showed the tooltip last (a chart passes itself), so `hideTooltip(owner)` from any
|
|
638
|
+
* other chart leaves it alone. The element is shared by every chart on the page: without this, a
|
|
639
|
+
* chart rebuilding or being destroyed would close the tooltip another chart is showing.
|
|
640
|
+
*/
|
|
641
|
+
owner = null;
|
|
623
642
|
/** Space left between the tooltip and whatever it's placed next to (the cursor or an anchor). */
|
|
624
643
|
static GAP = 8;
|
|
625
644
|
/**
|
|
626
645
|
* Shows the tooltip for a hovered datum. Renders `template` when the chart has one projected;
|
|
627
646
|
* otherwise falls back to the default key/value content, formatted per `valueFormat`/`keyFormat`.
|
|
628
647
|
* Placed beside `anchor` when one is given (see `positionBeside`), else above the event's position.
|
|
648
|
+
* `owner` is what's showing it (see `hideTooltip`).
|
|
629
649
|
*/
|
|
630
|
-
showTooltip(event, template, context, valueFormat, keyFormat, anchor) {
|
|
650
|
+
showTooltip(event, template, context, valueFormat, keyFormat, anchor, owner) {
|
|
651
|
+
this.owner = owner ?? null;
|
|
631
652
|
if (template) {
|
|
632
653
|
this.renderTemplate(template, context);
|
|
633
654
|
}
|
|
@@ -649,7 +670,16 @@ class PcacTooltipBuilder {
|
|
|
649
670
|
showBarTooltip(event, data, valueFormat, keyFormat) {
|
|
650
671
|
this.showTooltip(event, undefined, { $implicit: data, parent: null, isThreshold: false, index: 0, parentIndex: null, coincident: [] }, valueFormat, keyFormat);
|
|
651
672
|
}
|
|
652
|
-
|
|
673
|
+
/**
|
|
674
|
+
* Hides the tooltip. Given an `owner`, only if that owner is the one showing it - so a chart can
|
|
675
|
+
* release the tooltip on rebuild or destroy without closing one another chart has open. Without
|
|
676
|
+
* an owner it always hides.
|
|
677
|
+
*/
|
|
678
|
+
hideTooltip(owner) {
|
|
679
|
+
if (owner !== undefined && owner !== this.owner) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
this.owner = null;
|
|
653
683
|
if (!this.shell) {
|
|
654
684
|
// Never shown, so there's nothing to hide - and no reason to create the element just to.
|
|
655
685
|
return;
|
|
@@ -768,10 +798,12 @@ class PcacTooltipBuilder {
|
|
|
768
798
|
getBarTipData(data, valueFormat, keyFormat) {
|
|
769
799
|
let value = data.value;
|
|
770
800
|
let key = data.key;
|
|
771
|
-
|
|
801
|
+
// A missing value stays blank rather than being formatted as `0%` / `null F`.
|
|
802
|
+
if (valueFormat && value !== null && value !== undefined) {
|
|
772
803
|
switch (valueFormat) {
|
|
773
804
|
case PcacFormatEnum.Percentage:
|
|
774
|
-
|
|
805
|
+
// Same fraction rule, and the same formatting, as a Percentage axis's ticks.
|
|
806
|
+
value = formatPercent(Number(value));
|
|
775
807
|
break;
|
|
776
808
|
case PcacFormatEnum.Fahrenheit:
|
|
777
809
|
value = `${value} F`;
|
|
@@ -808,6 +840,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
|
|
|
808
840
|
}]
|
|
809
841
|
}] });
|
|
810
842
|
|
|
843
|
+
// Decorated only so Angular accepts its `ngOnDestroy` hook, which the builders extending it inherit;
|
|
844
|
+
// never provided itself - each builder is provided by its own chart component.
|
|
811
845
|
class PcacChart {
|
|
812
846
|
axisBuilder = inject(PcacAxisBuilder);
|
|
813
847
|
gridBuilder = inject(PcacGridBuilder);
|
|
@@ -833,6 +867,8 @@ class PcacChart {
|
|
|
833
867
|
height = 400;
|
|
834
868
|
colors = [];
|
|
835
869
|
startData = [];
|
|
870
|
+
/** The chart's accessible name when its config gives no `ariaLabel`; each builder names its type. */
|
|
871
|
+
chartTypeLabel = 'Chart';
|
|
836
872
|
/**
|
|
837
873
|
* Swaps a consumer's `colorOverride` in for the theme palette `initializeChartState` set, in
|
|
838
874
|
* order. Checks `length` rather than truthiness: every config class defaults its override to
|
|
@@ -1041,10 +1077,19 @@ class PcacChart {
|
|
|
1041
1077
|
index: options.index,
|
|
1042
1078
|
parentIndex: options.parentIndex ?? null,
|
|
1043
1079
|
coincident: options.coincident ?? [],
|
|
1044
|
-
}, options.valueFormat, options.keyFormat, options.anchor);
|
|
1080
|
+
}, options.valueFormat, options.keyFormat, options.anchor, this);
|
|
1045
1081
|
}
|
|
1082
|
+
/** Hides the tooltip if this chart is the one showing it; another chart's is left alone. */
|
|
1046
1083
|
hideTooltip() {
|
|
1047
|
-
this.tooltipBuilder.hideTooltip();
|
|
1084
|
+
this.tooltipBuilder.hideTooltip(this);
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Builders are provided per chart component, so Angular calls this when the component is
|
|
1088
|
+
* destroyed. A chart removed while hovered (an `@if` flip, a route change) gets no `mouseout`,
|
|
1089
|
+
* so without this its tooltip - and any consumer template view in it - would stay on screen.
|
|
1090
|
+
*/
|
|
1091
|
+
ngOnDestroy() {
|
|
1092
|
+
this.hideTooltip();
|
|
1048
1093
|
}
|
|
1049
1094
|
/**
|
|
1050
1095
|
* Prior to building a chart, we need to initialize the state of the chart.
|
|
@@ -1064,9 +1109,12 @@ class PcacChart {
|
|
|
1064
1109
|
* the chart (e.g. a filter that now matches nothing).
|
|
1065
1110
|
*/
|
|
1066
1111
|
clearChart(chartElm) {
|
|
1112
|
+
this.hideTooltip();
|
|
1067
1113
|
select(chartElm.nativeElement).select('g').remove();
|
|
1068
1114
|
}
|
|
1069
1115
|
initializeChartState(chartElm, config) {
|
|
1116
|
+
// The rebuild removes the hovered element, which gets no mouseout to close its tooltip.
|
|
1117
|
+
this.hideTooltip();
|
|
1070
1118
|
select(chartElm.nativeElement).select('g').remove();
|
|
1071
1119
|
const container = chartElm.nativeElement.parentNode;
|
|
1072
1120
|
const containerWidth = container.clientWidth;
|
|
@@ -1079,6 +1127,10 @@ class PcacChart {
|
|
|
1079
1127
|
return false;
|
|
1080
1128
|
}
|
|
1081
1129
|
this.width = measuredWidth;
|
|
1130
|
+
// Announced as a single image with a name, rather than as a pile of unlabelled shapes.
|
|
1131
|
+
select(chartElm.nativeElement)
|
|
1132
|
+
.attr('role', 'img')
|
|
1133
|
+
.attr('aria-label', config.ariaLabel || this.chartTypeLabel);
|
|
1082
1134
|
this.height = this.resolveHeight(container, config);
|
|
1083
1135
|
// One color per group or per series within a group, whichever needs more - sized by the
|
|
1084
1136
|
// largest group, since bars index colors by their position within their own group.
|
|
@@ -1202,7 +1254,12 @@ class PcacChart {
|
|
|
1202
1254
|
this.width = this.width + this.margin.left - left;
|
|
1203
1255
|
this.margin.left = left;
|
|
1204
1256
|
}
|
|
1257
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PcacChart, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1258
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PcacChart });
|
|
1205
1259
|
}
|
|
1260
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PcacChart, decorators: [{
|
|
1261
|
+
type: Injectable
|
|
1262
|
+
}] });
|
|
1206
1263
|
|
|
1207
1264
|
/**
|
|
1208
1265
|
* How long each bar is drawn: its value, or 0 when it can't be drawn - a null or non-numeric
|
|
@@ -1316,6 +1373,7 @@ class BarHorizontalChartBuilder extends PcacChart {
|
|
|
1316
1373
|
barClickedSource = new Subject();
|
|
1317
1374
|
config;
|
|
1318
1375
|
barClicked$ = this.barClickedSource.asObservable();
|
|
1376
|
+
chartTypeLabel = 'Bar chart';
|
|
1319
1377
|
buildChart(chartElm, config) {
|
|
1320
1378
|
if (!config?.data?.length) {
|
|
1321
1379
|
this.clearChart(chartElm);
|
|
@@ -1728,6 +1786,7 @@ class BarVerticalChartBuilder extends PcacChart {
|
|
|
1728
1786
|
yScale;
|
|
1729
1787
|
barClickedSource = new Subject();
|
|
1730
1788
|
barClicked$ = this.barClickedSource.asObservable();
|
|
1789
|
+
chartTypeLabel = 'Bar chart';
|
|
1731
1790
|
buildChart(chartElm, config) {
|
|
1732
1791
|
if (!config?.data?.length) {
|
|
1733
1792
|
this.clearChart(chartElm);
|
|
@@ -2039,6 +2098,10 @@ class PcacBarVerticalChartColorOverrideConfig {
|
|
|
2039
2098
|
colors = [];
|
|
2040
2099
|
}
|
|
2041
2100
|
|
|
2101
|
+
// Only what a consumer configures, binds or styles with. The chart plumbing - the `PcacChart`
|
|
2102
|
+
// base class and the builders, the axis/grid/tooltip/transition/resize services, and the
|
|
2103
|
+
// resolved-config helpers - is internal, so it can change without breaking anyone.
|
|
2104
|
+
|
|
2042
2105
|
class PcacLegendConfigItem {
|
|
2043
2106
|
label;
|
|
2044
2107
|
checked = true;
|
|
@@ -2301,12 +2364,22 @@ class PlaChartEffectsBuilder {
|
|
|
2301
2364
|
break;
|
|
2302
2365
|
}
|
|
2303
2366
|
}
|
|
2304
|
-
const
|
|
2367
|
+
const value = this.config.y.invert(pos.y);
|
|
2305
2368
|
select(nodes[index]).select('text')
|
|
2306
|
-
.text(
|
|
2369
|
+
.text(this.formatValue(value));
|
|
2307
2370
|
return 'translate(' + mousePos[0] + ',' + pos.y + ')';
|
|
2308
2371
|
});
|
|
2309
2372
|
}
|
|
2373
|
+
/**
|
|
2374
|
+
* The crosshair's value, formatted the way the y axis labels its ticks - same format, same
|
|
2375
|
+
* step-based precision - rather than rounded to a whole number, which read a 0-1 axis as 0 or 1.
|
|
2376
|
+
*/
|
|
2377
|
+
formatValue(value) {
|
|
2378
|
+
const y = this.config.y;
|
|
2379
|
+
const formatter = axisTickFormat(this.config.yFormat, y, this.config.yTicks)
|
|
2380
|
+
?? y.tickFormat(this.config.yTicks);
|
|
2381
|
+
return formatter(value);
|
|
2382
|
+
}
|
|
2310
2383
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PlaChartEffectsBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2311
2384
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: PlaChartEffectsBuilder });
|
|
2312
2385
|
}
|
|
@@ -2758,6 +2831,12 @@ const DOT_GROW_TRANSITION = 'pcac-dot-grow';
|
|
|
2758
2831
|
const DOT_HOVER_TRANSITION = 'pcac-dot-hover';
|
|
2759
2832
|
/** See `revealAfterEntry`. */
|
|
2760
2833
|
const REVEAL_TRANSITION = 'pcac-reveal';
|
|
2834
|
+
/** Each chart type's accessible name when its config gives no `ariaLabel`. */
|
|
2835
|
+
const CHART_TYPE_LABELS = {
|
|
2836
|
+
[PcacLineAreaPlotChartConfigType.Line]: 'Line chart',
|
|
2837
|
+
[PcacLineAreaPlotChartConfigType.Area]: 'Area chart',
|
|
2838
|
+
[PcacLineAreaPlotChartConfigType.Plot]: 'Plot chart',
|
|
2839
|
+
};
|
|
2761
2840
|
class PlaChartBuilder extends PcacChart {
|
|
2762
2841
|
effectsBuilder = inject(PlaChartEffectsBuilder);
|
|
2763
2842
|
scales;
|
|
@@ -2821,6 +2900,7 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2821
2900
|
}));
|
|
2822
2901
|
// A hidden axis keeps 8px rather than 0 so a dot on the edge of the plot isn't clipped
|
|
2823
2902
|
this.initializeAxisState(this.config, 'y', 8);
|
|
2903
|
+
this.chartTypeLabel = CHART_TYPE_LABELS[type];
|
|
2824
2904
|
this.resolvePointLayout(type);
|
|
2825
2905
|
this.reservePointSpace();
|
|
2826
2906
|
this.pointRange = this.config.pointRange ? { ...new PcacPointRangeConfig(), ...this.config.pointRange } : null;
|
|
@@ -2913,7 +2993,9 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2913
2993
|
data: config.data,
|
|
2914
2994
|
colors: this.colors,
|
|
2915
2995
|
x: this.scales.x,
|
|
2916
|
-
y: this.scales.y
|
|
2996
|
+
y: this.scales.y,
|
|
2997
|
+
yFormat: this.yAxis.format,
|
|
2998
|
+
yTicks: this.yAxis.ticks,
|
|
2917
2999
|
});
|
|
2918
3000
|
}
|
|
2919
3001
|
// Axes above the lines/areas (so an axis line isn't covered by a series sitting at x = 0),
|
|
@@ -3584,6 +3666,7 @@ class PieChartBuilder extends PcacChart {
|
|
|
3584
3666
|
pieAngles;
|
|
3585
3667
|
sliceClickedSource = new Subject();
|
|
3586
3668
|
sliceClicked$ = this.sliceClickedSource.asObservable();
|
|
3669
|
+
chartTypeLabel = 'Pie chart';
|
|
3587
3670
|
buildChart(chartElm, config) {
|
|
3588
3671
|
if (!config?.data?.length) {
|
|
3589
3672
|
this.clearChart(chartElm);
|
|
@@ -3781,5 +3864,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
|
|
|
3781
3864
|
* Generated bundle index. Do not edit.
|
|
3782
3865
|
*/
|
|
3783
3866
|
|
|
3784
|
-
export {
|
|
3867
|
+
export { PcacAreaChart, PcacAreaChartConfig, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChartConfig, PcacColorService, PcacData, PcacDataRange, PcacFormatEnum, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPieDonutConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointImageConfig, PcacPointRangeConfig, PcacPointRangeShow, PcacPointRangeStyle, PcacRangeBounds, PcacTooltipDirective };
|
|
3785
3868
|
//# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map
|