@pioneer-code/pioneer-charts 22.2.15 → 22.2.16
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 +2 -2
- package/fesm2022/pioneer-code-pioneer-charts.mjs +157 -62
- package/fesm2022/pioneer-code-pioneer-charts.mjs.map +1 -1
- package/package.json +10 -2
- package/scss/legend/legend.component.scss +7 -5
- package/scss/{pie-chart/pie-chart.component.scss → pie-donut-chart/pie-donut-chart.component.scss} +1 -1
- package/scss/pioneer-charts.scss +6 -6
- package/themes/pioneer-charts.css +4 -4
- package/themes/pioneer-charts.min.css +1 -1
- package/types/pioneer-code-pioneer-charts.d.ts +53 -34
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@pioneer-code/pioneer-charts)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
Pioneer Charts is an Angular library for building beautiful, customizable, and responsive data visualizations. It leverages [D3.js](https://d3js.org/) for rendering and provides bar, line/area,
|
|
7
|
+
Pioneer Charts is an Angular library for building beautiful, customizable, and responsive data visualizations. It leverages [D3.js](https://d3js.org/) for rendering and provides bar, line/area, plot, pie and donut charts, plus a legend component.
|
|
8
8
|
|
|
9
9
|
## Documentation
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ Guides, the API reference, live examples, and theming instructions all live on t
|
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
|
-
- Bar (vertical and horizontal), line, area, plot, and
|
|
17
|
+
- Bar (vertical and horizontal), line, area, plot, pie and donut charts, plus a legend.
|
|
18
18
|
- Beautiful default theme, customizable via CSS or by overriding the source Sass variables.
|
|
19
19
|
- Strongly typed configuration contracts.
|
|
20
20
|
- Outputs for user interaction (bar, slice, dot, and legend clicks).
|
|
@@ -1202,7 +1202,10 @@ class PcacChart {
|
|
|
1202
1202
|
const container = chartElm.nativeElement.parentNode;
|
|
1203
1203
|
const containerWidth = container.clientWidth;
|
|
1204
1204
|
const measuredWidth = containerWidth - this.margin.left - this.margin.right;
|
|
1205
|
-
|
|
1205
|
+
// `!(> 0)` rather than `<= 0`, so a width that can't be measured at all - `NaN`, as when a page
|
|
1206
|
+
// is rendered on the server, where there's no layout and `clientWidth` is undefined - also
|
|
1207
|
+
// draws nothing, rather than drawing a chart `NaN` pixels wide.
|
|
1208
|
+
if (!(measuredWidth > 0)) {
|
|
1206
1209
|
// The previous drawing was just removed above, so nothing is on screen any more. Forget the
|
|
1207
1210
|
// size it was drawn at, or a container that comes back at that same width (a hidden tab
|
|
1208
1211
|
// shown again) would read as unchanged to `containerSizeChanged()` and never be redrawn.
|
|
@@ -2282,11 +2285,11 @@ class PcacLegend {
|
|
|
2282
2285
|
this.itemClicked.emit(items);
|
|
2283
2286
|
}
|
|
2284
2287
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacLegend, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2285
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", 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
|
|
2288
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", 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) {\n<div class=\"pcac-legend-item\" [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;flex-wrap:wrap;column-gap:8px}.pcac-legend-label{margin-bottom:2.5px}.pcac-legend-item{cursor:pointer;display:flex;align-items:center;min-height:24px}.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:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n"] });
|
|
2286
2289
|
}
|
|
2287
2290
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacLegend, decorators: [{
|
|
2288
2291
|
type: Component,
|
|
2289
|
-
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
|
|
2292
|
+
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) {\n<div class=\"pcac-legend-item\" [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;flex-wrap:wrap;column-gap:8px}.pcac-legend-label{margin-bottom:2.5px}.pcac-legend-item{cursor:pointer;display:flex;align-items:center;min-height:24px}.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:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n"] }]
|
|
2290
2293
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }, { type: i0.Output, args: ["configChange"] }], itemClicked: [{ type: i0.Output, args: ["itemClicked"] }] } });
|
|
2291
2294
|
|
|
2292
2295
|
var PcacLineAreaPlotChartConfigType;
|
|
@@ -3811,14 +3814,34 @@ class PcacAreaChartConfig extends PcacLineAreaChartConfig {
|
|
|
3811
3814
|
// the point-image and point-range types are part of those configs' public shape, so they're
|
|
3812
3815
|
// exported alone.
|
|
3813
3816
|
|
|
3817
|
+
/** Which chart the shared `<pcac-pie-donut-chart>` draws; each wrapper binds its own. */
|
|
3818
|
+
var PcacPieDonutChartType;
|
|
3819
|
+
(function (PcacPieDonutChartType) {
|
|
3820
|
+
PcacPieDonutChartType["Pie"] = "pie";
|
|
3821
|
+
PcacPieDonutChartType["Donut"] = "donut";
|
|
3822
|
+
})(PcacPieDonutChartType || (PcacPieDonutChartType = {}));
|
|
3814
3823
|
/**
|
|
3815
|
-
*
|
|
3816
|
-
*
|
|
3824
|
+
* What the pie and donut charts share. Internal: consumers configure `PcacPieChartConfig` or
|
|
3825
|
+
* `PcacDonutChartConfig`, the same way the line, area and plot charts share
|
|
3826
|
+
* `PcacLineAreaChartConfig`.
|
|
3817
3827
|
*/
|
|
3818
|
-
class
|
|
3828
|
+
class PcacPieDonutChartConfig extends PcacChartConfig {
|
|
3819
3829
|
/**
|
|
3820
|
-
*
|
|
3821
|
-
*
|
|
3830
|
+
* Slice colors, any CSS color, in data order - the first slice takes the first color - in place
|
|
3831
|
+
* of the theme palette. Repeated when there are more slices than colors. Omitted or empty, the
|
|
3832
|
+
* theme palette is used. Match a `<pcac-legend>` to it with each item's `colorOverride`.
|
|
3833
|
+
*/
|
|
3834
|
+
colorOverride;
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
/**
|
|
3838
|
+
* A pie with its slices drawn as a ring around an empty center, which can hold a short label -
|
|
3839
|
+
* typically the total the slices add up to.
|
|
3840
|
+
*/
|
|
3841
|
+
class PcacDonutChartConfig extends PcacPieDonutChartConfig {
|
|
3842
|
+
/**
|
|
3843
|
+
* Radius of the hole as a fraction of the chart's radius, from 0 (no hole - a pie) to 0.9.
|
|
3844
|
+
* Values outside that range are clamped.
|
|
3822
3845
|
*/
|
|
3823
3846
|
innerRadius = 0.6;
|
|
3824
3847
|
/**
|
|
@@ -3830,28 +3853,15 @@ class PcacPieDonutConfig {
|
|
|
3830
3853
|
subLabel;
|
|
3831
3854
|
/**
|
|
3832
3855
|
* `label` color, any CSS color; theme default `$gray-800`. Applied as
|
|
3833
|
-
* `--pcac-
|
|
3834
|
-
* set it on an ancestor instead (a config value wins).
|
|
3856
|
+
* `--pcac-donut-center-label-color` on the chart's `.pcac-donut-center` group, so a stylesheet
|
|
3857
|
+
* can set it on an ancestor instead (a config value wins).
|
|
3835
3858
|
*/
|
|
3836
3859
|
labelColor;
|
|
3837
|
-
/** `subLabel` color, likewise (`--pcac-
|
|
3860
|
+
/** `subLabel` color, likewise (`--pcac-donut-center-sub-label-color`); theme default `$gray-600`. */
|
|
3838
3861
|
subLabelColor;
|
|
3839
3862
|
}
|
|
3840
|
-
class PcacPieChartConfig extends PcacChartConfig {
|
|
3841
|
-
/**
|
|
3842
|
-
* Draw the pie as a donut. Off when not set; `{}` turns it on with every `PcacPieDonutConfig`
|
|
3843
|
-
* default. Slices, hover and `sliceClicked` behave the same either way.
|
|
3844
|
-
*/
|
|
3845
|
-
donut;
|
|
3846
|
-
/**
|
|
3847
|
-
* Slice colors, any CSS color, in data order - the first slice takes the first color - in place
|
|
3848
|
-
* of the theme palette. Repeated when there are more slices than colors. Omitted or empty, the
|
|
3849
|
-
* theme palette is used. Match a `<pcac-legend>` to it with each item's `colorOverride`.
|
|
3850
|
-
*/
|
|
3851
|
-
colorOverride;
|
|
3852
|
-
}
|
|
3853
3863
|
|
|
3854
|
-
/** The largest `
|
|
3864
|
+
/** The largest `PcacDonutChartConfig.innerRadius` honored, so a ring is always left to draw. */
|
|
3855
3865
|
const MAX_DONUT_INNER_RADIUS = 0.9;
|
|
3856
3866
|
/** Smallest font a center line is drawn at; a line that can't fit the hole at this size is left out. */
|
|
3857
3867
|
const MIN_CENTER_FONT_SIZE = 8;
|
|
@@ -3863,12 +3873,12 @@ const CENTER_TEXT_WIDTH = 1.6;
|
|
|
3863
3873
|
*/
|
|
3864
3874
|
const ESTIMATED_GLYPH_WIDTH = 0.6;
|
|
3865
3875
|
/**
|
|
3866
|
-
* Provided per-component (see
|
|
3876
|
+
* Provided per-component (see PcacPieDonutChartComponent's `providers`), not root-scoped:
|
|
3867
3877
|
* this builder extends PcacChart, which holds mutable per-chart-instance state (margin, width,
|
|
3868
3878
|
* height, colors, svg). A root singleton would be shared and clobbered by every
|
|
3869
|
-
* <pcac-pie-chart> rendered at once.
|
|
3879
|
+
* <pcac-pie-donut-chart> rendered at once.
|
|
3870
3880
|
*/
|
|
3871
|
-
class
|
|
3881
|
+
class PieDonutChartBuilder extends PcacChart {
|
|
3872
3882
|
radius;
|
|
3873
3883
|
innerRadius = 0;
|
|
3874
3884
|
arcShape;
|
|
@@ -3877,32 +3887,59 @@ class PieChartBuilder extends PcacChart {
|
|
|
3877
3887
|
sliceClickedSource = new Subject();
|
|
3878
3888
|
sliceClicked$ = this.sliceClickedSource.asObservable();
|
|
3879
3889
|
chartTypeLabel = 'Pie chart';
|
|
3880
|
-
|
|
3890
|
+
/**
|
|
3891
|
+
* Draws `config` as a pie, or - for `PcacPieDonutChartType.Donut` - as a donut, reading the ring
|
|
3892
|
+
* settings off the config (`PcacDonutChartConfig`), with its defaults for any left unset.
|
|
3893
|
+
*/
|
|
3894
|
+
buildChart(chartElm, config, type) {
|
|
3881
3895
|
if (!config?.data?.length) {
|
|
3882
3896
|
this.clearChart(chartElm);
|
|
3883
3897
|
return;
|
|
3884
3898
|
}
|
|
3885
3899
|
// The pie deliberately opts out of `heightFull`: `height` here feeds the radius rather than a
|
|
3886
3900
|
// drawing area, so growing into a tall container would silently change the size of the pie
|
|
3887
|
-
// itself. `
|
|
3888
|
-
// here rather than being absent from the type. (`<pcac-pie-chart>` also never gets the
|
|
3901
|
+
// itself. `PcacPieDonutChartConfig` inherits the property from PcacChartConfig, so it's neutralized
|
|
3902
|
+
// here rather than being absent from the type. (`<pcac-pie-donut-chart>` also never gets the
|
|
3889
3903
|
// `pcac-height-full` class the other charts use to stretch their host.)
|
|
3904
|
+
const donut = type === PcacPieDonutChartType.Donut ? donutSettings(config) : null;
|
|
3905
|
+
if (type === PcacPieDonutChartType.Pie) {
|
|
3906
|
+
this.warnOfDonutOnPie(config);
|
|
3907
|
+
}
|
|
3908
|
+
// Announced for what it draws: a ring, or - a donut with no hole included - a pie (see
|
|
3909
|
+
// PcacChart.chartTypeLabel).
|
|
3910
|
+
this.chartTypeLabel = donut && donut.innerRadius > 0 ? 'Donut chart' : 'Pie chart';
|
|
3890
3911
|
if (!this.initializeChartState(chartElm, { ...config, heightFull: false })) {
|
|
3891
3912
|
return;
|
|
3892
3913
|
}
|
|
3893
3914
|
this.applyColorOverride(config.colorOverride);
|
|
3894
3915
|
this.radius = Math.min(this.height, this.width) / 2;
|
|
3895
|
-
this.buildShapes(
|
|
3916
|
+
this.buildShapes(donut?.innerRadius ?? 0);
|
|
3896
3917
|
this.drawChart(chartElm, config);
|
|
3897
|
-
if (
|
|
3898
|
-
this.drawCenter(
|
|
3918
|
+
if (donut && this.innerRadius > 0) {
|
|
3919
|
+
this.drawCenter(donut);
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
warnedOfDonutOnPie = false;
|
|
3923
|
+
/**
|
|
3924
|
+
* Development builds only: a pie config still carrying 22.2's `donut` option. It isn't read any
|
|
3925
|
+
* more - the donut is PcacDonutChart now - and TypeScript doesn't always catch it (a config built
|
|
3926
|
+
* by spreading, or loaded as JSON, compiles fine), so the chart would quietly draw a plain pie.
|
|
3927
|
+
* Warned once per chart.
|
|
3928
|
+
*/
|
|
3929
|
+
warnOfDonutOnPie(config) {
|
|
3930
|
+
if (typeof ngDevMode === 'undefined' || !ngDevMode || this.warnedOfDonutOnPie || !('donut' in config)) {
|
|
3931
|
+
return;
|
|
3899
3932
|
}
|
|
3933
|
+
this.warnedOfDonutOnPie = true;
|
|
3934
|
+
console.warn('Pioneer Charts: <pcac-pie-chart> ignores `donut`. For a donut, use <pcac-donut-chart> with ' +
|
|
3935
|
+
'PcacDonutChartConfig, which takes innerRadius, label, subLabel, labelColor and subLabelColor ' +
|
|
3936
|
+
'directly - see the 22.3.0 CHANGELOG.');
|
|
3900
3937
|
}
|
|
3901
|
-
|
|
3938
|
+
/** `ratio` is the hole's radius as a share of the chart's: 0 for a pie. */
|
|
3939
|
+
buildShapes(ratio) {
|
|
3902
3940
|
const radiusOffset = 10;
|
|
3903
3941
|
// Never negative: in a container under 20px the offset would otherwise turn the pie inside out.
|
|
3904
3942
|
const outerRadius = Math.max(0, this.radius - radiusOffset);
|
|
3905
|
-
const ratio = donut ? (donut.innerRadius ?? new PcacPieDonutConfig().innerRadius) : 0;
|
|
3906
3943
|
// Sized against the resting slice, so the hole stays put when a hovered slice grows outward.
|
|
3907
3944
|
this.innerRadius = Math.max(0, outerRadius * Math.min(Math.max(ratio, 0), MAX_DONUT_INNER_RADIUS));
|
|
3908
3945
|
this.arcShape = arc()
|
|
@@ -3979,12 +4016,12 @@ class PieChartBuilder extends PcacChart {
|
|
|
3979
4016
|
}
|
|
3980
4017
|
const maxWidth = this.innerRadius * CENTER_TEXT_WIDTH;
|
|
3981
4018
|
const center = this.svg.append('g')
|
|
3982
|
-
.attr('class', 'pcac-
|
|
4019
|
+
.attr('class', 'pcac-donut-center')
|
|
3983
4020
|
.attr('pointer-events', 'none')
|
|
3984
|
-
.style('--pcac-
|
|
3985
|
-
.style('--pcac-
|
|
3986
|
-
const label = this.drawCenterLine(center, 'pcac-
|
|
3987
|
-
const subLabel = this.drawCenterLine(center, 'pcac-
|
|
4021
|
+
.style('--pcac-donut-center-label-color', () => donut.labelColor ?? null)
|
|
4022
|
+
.style('--pcac-donut-center-sub-label-color', () => donut.subLabelColor ?? null);
|
|
4023
|
+
const label = this.drawCenterLine(center, 'pcac-donut-center-label', donut.label, Math.min(this.innerRadius * 0.5, 40), maxWidth);
|
|
4024
|
+
const subLabel = this.drawCenterLine(center, 'pcac-donut-center-sub-label', donut.subLabel, Math.min(this.innerRadius * 0.2, 16), maxWidth);
|
|
3988
4025
|
if (!label && !subLabel) {
|
|
3989
4026
|
center.remove();
|
|
3990
4027
|
return;
|
|
@@ -4026,34 +4063,47 @@ class PieChartBuilder extends PcacChart {
|
|
|
4026
4063
|
const i = interpolate({ startAngle: 0, endAngle: 0 }, b);
|
|
4027
4064
|
return (t) => this.arcShape(i(t)) ?? '';
|
|
4028
4065
|
}
|
|
4029
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type:
|
|
4030
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type:
|
|
4066
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PieDonutChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
4067
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PieDonutChartBuilder });
|
|
4031
4068
|
}
|
|
4032
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type:
|
|
4069
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PieDonutChartBuilder, decorators: [{
|
|
4033
4070
|
type: Injectable
|
|
4034
4071
|
}] });
|
|
4072
|
+
/** A donut config with its defaults filled in for whatever the consumer left unset. */
|
|
4073
|
+
function donutSettings(config) {
|
|
4074
|
+
const defaults = new PcacDonutChartConfig();
|
|
4075
|
+
// Unset or not a number (NaN, say - an empty number input's value), the default: a NaN ratio
|
|
4076
|
+
// survived the clamp and made every slice's path NaN, so nothing drew.
|
|
4077
|
+
const innerRadius = Number.isFinite(config.innerRadius) ? config.innerRadius : defaults.innerRadius ?? 0;
|
|
4078
|
+
return { ...config, innerRadius };
|
|
4079
|
+
}
|
|
4035
4080
|
|
|
4036
|
-
|
|
4037
|
-
|
|
4081
|
+
/**
|
|
4082
|
+
* The chart the pie and donut charts share, drawn by `PcacPieChart` and `PcacDonutChart` with
|
|
4083
|
+
* their own `type`. Internal, like `<pcac-line-area-chart>` behind the line, area and plot charts.
|
|
4084
|
+
*/
|
|
4085
|
+
class PcacPieDonutChartComponent {
|
|
4086
|
+
chartBuilder = inject(PieDonutChartBuilder);
|
|
4038
4087
|
config = input.required(/* @ts-ignore */
|
|
4039
4088
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
4089
|
+
type = input.required(/* @ts-ignore */
|
|
4090
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
4040
4091
|
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
4041
4092
|
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
4042
4093
|
sliceClicked = outputFromObservable(this.chartBuilder.sliceClicked$);
|
|
4043
4094
|
/**
|
|
4044
|
-
*
|
|
4045
|
-
*
|
|
4095
|
+
* The consumer's `<ng-template pcacTooltip>`, forwarded by the wrapper it was projected into:
|
|
4096
|
+
* a content query here wouldn't see it through the wrapper's template (see
|
|
4097
|
+
* PcacLineAreaChartComponent.tooltipTemplate).
|
|
4046
4098
|
*/
|
|
4047
|
-
tooltipTemplate =
|
|
4048
|
-
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
4099
|
+
tooltipTemplate = input(/* @ts-ignore */
|
|
4100
|
+
...(ngDevMode ? [undefined, { debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
4049
4101
|
constructor() {
|
|
4050
|
-
//
|
|
4051
|
-
// lifecycle hook) is what makes this an effect: it tracks config() as its dependency and
|
|
4052
|
-
// reruns whenever a new value comes in, signal-input-changes-drive-behavior all the way down.
|
|
4102
|
+
// Tracks config() and type(), rebuilding whenever either changes.
|
|
4053
4103
|
effect(() => this.buildChart());
|
|
4054
|
-
// Handed over as a getter so the builder reads the
|
|
4104
|
+
// Handed over as a getter so the builder reads the input at hover time, not in the effect
|
|
4055
4105
|
// above (see PcacChart.tooltipTemplate).
|
|
4056
|
-
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate()
|
|
4106
|
+
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate();
|
|
4057
4107
|
inject(PcacChartResizeService).observe(this.chartElm, () => {
|
|
4058
4108
|
// Skip the ResizeObserver's routine initial callback when it lands after the effect above
|
|
4059
4109
|
// already built successfully at this same width — only a real size change (or a build
|
|
@@ -4065,18 +4115,63 @@ class PcacPieChartComponent {
|
|
|
4065
4115
|
}
|
|
4066
4116
|
buildChart() {
|
|
4067
4117
|
const config = this.config();
|
|
4118
|
+
const type = this.type();
|
|
4068
4119
|
// Handed over even when empty: the builder clears what it last drew rather than leaving it.
|
|
4069
4120
|
if (config) {
|
|
4070
|
-
this.chartBuilder.buildChart(this.chartElm(), config);
|
|
4121
|
+
this.chartBuilder.buildChart(this.chartElm(), config, type);
|
|
4071
4122
|
}
|
|
4072
4123
|
}
|
|
4073
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type:
|
|
4074
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.0", type:
|
|
4124
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacPieDonutChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4125
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.0", type: PcacPieDonutChartComponent, isStandalone: true, selector: "pcac-pie-donut-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: { sliceClicked: "sliceClicked" }, providers: [PieDonutChartBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- pcac-pie-chart kept alongside for app CSS written against 22.2 and earlier, when this section\n belonged to the one pie component (the donut included). -->\n<section class=\"pcac-pie-donut-chart pcac-pie-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-pie-donut-chart svg{width:100%;display:block}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
4075
4126
|
}
|
|
4076
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type:
|
|
4127
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacPieDonutChartComponent, decorators: [{
|
|
4077
4128
|
type: Component,
|
|
4078
|
-
args: [{ selector: 'pcac-pie-chart', encapsulation: ViewEncapsulation.None, providers: [
|
|
4079
|
-
}], 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.
|
|
4129
|
+
args: [{ selector: 'pcac-pie-donut-chart', encapsulation: ViewEncapsulation.None, providers: [PieDonutChartBuilder], template: "<!-- pcac-pie-chart kept alongside for app CSS written against 22.2 and earlier, when this section\n belonged to the one pie component (the donut included). -->\n<section class=\"pcac-pie-donut-chart pcac-pie-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-pie-donut-chart svg{width:100%;display:block}\n"] }]
|
|
4130
|
+
}], 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 }] }], sliceClicked: [{ type: i0.Output, args: ["sliceClicked"] }], tooltipTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipTemplate", required: false }] }] } });
|
|
4131
|
+
|
|
4132
|
+
class PcacPieChart {
|
|
4133
|
+
config = input.required(/* @ts-ignore */
|
|
4134
|
+
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
4135
|
+
types = PcacPieDonutChartType;
|
|
4136
|
+
sliceClicked = output();
|
|
4137
|
+
/**
|
|
4138
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element, forwarded to the
|
|
4139
|
+
* inner chart (see PcacPieDonutChartComponent.tooltipTemplate).
|
|
4140
|
+
*/
|
|
4141
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
4142
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
4143
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacPieChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4144
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.0", type: PcacPieChart, isStandalone: true, selector: "pcac-pie-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { sliceClicked: "sliceClicked" }, queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<pcac-pie-donut-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Pie\" (sliceClicked)=\"sliceClicked.emit($event)\" />\n", dependencies: [{ kind: "component", type: PcacPieDonutChartComponent, selector: "pcac-pie-donut-chart", inputs: ["config", "type", "tooltipTemplate"], outputs: ["sliceClicked"] }] });
|
|
4145
|
+
}
|
|
4146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacPieChart, decorators: [{
|
|
4147
|
+
type: Component,
|
|
4148
|
+
args: [{ selector: 'pcac-pie-chart', imports: [PcacPieDonutChartComponent], template: "<pcac-pie-donut-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Pie\" (sliceClicked)=\"sliceClicked.emit($event)\" />\n" }]
|
|
4149
|
+
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], sliceClicked: [{ type: i0.Output, args: ["sliceClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
4150
|
+
|
|
4151
|
+
class PcacPieChartConfig extends PcacPieDonutChartConfig {
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
class PcacDonutChart {
|
|
4155
|
+
config = input.required(/* @ts-ignore */
|
|
4156
|
+
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
4157
|
+
types = PcacPieDonutChartType;
|
|
4158
|
+
sliceClicked = output();
|
|
4159
|
+
/**
|
|
4160
|
+
* Optional consumer `<ng-template pcacTooltip>` projected into this element, forwarded to the
|
|
4161
|
+
* inner chart (see PcacPieDonutChartComponent.tooltipTemplate).
|
|
4162
|
+
*/
|
|
4163
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
4164
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
4165
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacDonutChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4166
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.0", type: PcacDonutChart, isStandalone: true, selector: "pcac-donut-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { sliceClicked: "sliceClicked" }, queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<pcac-pie-donut-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Donut\" (sliceClicked)=\"sliceClicked.emit($event)\" />\n", dependencies: [{ kind: "component", type: PcacPieDonutChartComponent, selector: "pcac-pie-donut-chart", inputs: ["config", "type", "tooltipTemplate"], outputs: ["sliceClicked"] }] });
|
|
4167
|
+
}
|
|
4168
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PcacDonutChart, decorators: [{
|
|
4169
|
+
type: Component,
|
|
4170
|
+
args: [{ selector: 'pcac-donut-chart', imports: [PcacPieDonutChartComponent], template: "<pcac-pie-donut-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Donut\" (sliceClicked)=\"sliceClicked.emit($event)\" />\n" }]
|
|
4171
|
+
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], sliceClicked: [{ type: i0.Output, args: ["sliceClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
4172
|
+
|
|
4173
|
+
// The shared <pcac-pie-donut-chart> and its PcacPieDonutChartConfig stay internal, like the
|
|
4174
|
+
// line/area/plot charts' base: consumers use the pie and donut wrappers and their configs.
|
|
4080
4175
|
|
|
4081
4176
|
/*
|
|
4082
4177
|
* Public API Surface of pioneer-charts
|
|
@@ -4086,5 +4181,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
4086
4181
|
* Generated bundle index. Do not edit.
|
|
4087
4182
|
*/
|
|
4088
4183
|
|
|
4089
|
-
export { PcacAreaChart, PcacAreaChartConfig, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChartConfig, PcacColorService, PcacData, PcacDataRange, PcacFormatEnum, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig,
|
|
4184
|
+
export { PcacAreaChart, PcacAreaChartConfig, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChartConfig, PcacColorService, PcacData, PcacDataRange, PcacDonutChart, PcacDonutChartConfig, PcacFormatEnum, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChart, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointImageConfig, PcacPointRangeConfig, PcacPointRangeShow, PcacPointRangeStyle, PcacRangeBounds, PcacTooltipDirective };
|
|
4090
4185
|
//# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map
|