@tectra-ng/charts 0.0.1 → 0.2.0
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/LICENSE +21 -0
- package/README.md +44 -1
- package/bar-list/README.md +30 -0
- package/boxplot/README.md +62 -0
- package/bullet/README.md +53 -0
- package/candlestick/README.md +57 -0
- package/column/README.md +73 -0
- package/combo/README.md +83 -0
- package/core/README.md +62 -0
- package/fesm2022/tectra-ng-charts-bar-list.mjs +299 -0
- package/fesm2022/tectra-ng-charts-bar-list.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-boxplot.mjs +887 -0
- package/fesm2022/tectra-ng-charts-boxplot.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-bullet.mjs +666 -0
- package/fesm2022/tectra-ng-charts-bullet.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-candlestick.mjs +778 -0
- package/fesm2022/tectra-ng-charts-candlestick.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-column.mjs +1166 -0
- package/fesm2022/tectra-ng-charts-column.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-combo.mjs +1218 -0
- package/fesm2022/tectra-ng-charts-combo.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-core.mjs +3679 -0
- package/fesm2022/tectra-ng-charts-core.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-funnel.mjs +694 -0
- package/fesm2022/tectra-ng-charts-funnel.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-gantt.mjs +947 -0
- package/fesm2022/tectra-ng-charts-gantt.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-gauge.mjs +693 -0
- package/fesm2022/tectra-ng-charts-gauge.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-heatmap.mjs +935 -0
- package/fesm2022/tectra-ng-charts-heatmap.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-line.mjs +1541 -0
- package/fesm2022/tectra-ng-charts-line.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-org-chart.mjs +2341 -0
- package/fesm2022/tectra-ng-charts-org-chart.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-pie.mjs +1059 -0
- package/fesm2022/tectra-ng-charts-pie.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-radar.mjs +924 -0
- package/fesm2022/tectra-ng-charts-radar.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-radial-bar.mjs +802 -0
- package/fesm2022/tectra-ng-charts-radial-bar.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-range-area.mjs +933 -0
- package/fesm2022/tectra-ng-charts-range-area.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-rank-line.mjs +660 -0
- package/fesm2022/tectra-ng-charts-rank-line.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-sankey.mjs +837 -0
- package/fesm2022/tectra-ng-charts-sankey.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-scatter.mjs +1174 -0
- package/fesm2022/tectra-ng-charts-scatter.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-segmented-bar.mjs +328 -0
- package/fesm2022/tectra-ng-charts-segmented-bar.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-sunburst.mjs +733 -0
- package/fesm2022/tectra-ng-charts-sunburst.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-treemap.mjs +674 -0
- package/fesm2022/tectra-ng-charts-treemap.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts-waterfall.mjs +809 -0
- package/fesm2022/tectra-ng-charts-waterfall.mjs.map +1 -0
- package/fesm2022/tectra-ng-charts.mjs +4 -0
- package/fesm2022/tectra-ng-charts.mjs.map +1 -0
- package/funnel/README.md +53 -0
- package/gantt/README.md +53 -0
- package/gauge/README.md +41 -0
- package/heatmap/README.md +47 -0
- package/line/README.md +86 -0
- package/org-chart/README.md +57 -0
- package/package.json +173 -4
- package/pie/README.md +66 -0
- package/radar/README.md +64 -0
- package/radial-bar/README.md +62 -0
- package/range-area/README.md +66 -0
- package/rank-line/README.md +51 -0
- package/sankey/README.md +52 -0
- package/scatter/README.md +71 -0
- package/segmented-bar/README.md +35 -0
- package/sunburst/README.md +55 -0
- package/treemap/README.md +47 -0
- package/types/tectra-ng-charts-bar-list.d.ts +724 -0
- package/types/tectra-ng-charts-bar-list.d.ts.map +1 -0
- package/types/tectra-ng-charts-boxplot.d.ts +882 -0
- package/types/tectra-ng-charts-boxplot.d.ts.map +1 -0
- package/types/tectra-ng-charts-bullet.d.ts +833 -0
- package/types/tectra-ng-charts-bullet.d.ts.map +1 -0
- package/types/tectra-ng-charts-candlestick.d.ts +854 -0
- package/types/tectra-ng-charts-candlestick.d.ts.map +1 -0
- package/types/tectra-ng-charts-column.d.ts +951 -0
- package/types/tectra-ng-charts-column.d.ts.map +1 -0
- package/types/tectra-ng-charts-combo.d.ts +987 -0
- package/types/tectra-ng-charts-combo.d.ts.map +1 -0
- package/types/tectra-ng-charts-core.d.ts +859 -0
- package/types/tectra-ng-charts-core.d.ts.map +1 -0
- package/types/tectra-ng-charts-funnel.d.ts +857 -0
- package/types/tectra-ng-charts-funnel.d.ts.map +1 -0
- package/types/tectra-ng-charts-gantt.d.ts +884 -0
- package/types/tectra-ng-charts-gantt.d.ts.map +1 -0
- package/types/tectra-ng-charts-gauge.d.ts +859 -0
- package/types/tectra-ng-charts-gauge.d.ts.map +1 -0
- package/types/tectra-ng-charts-heatmap.d.ts +914 -0
- package/types/tectra-ng-charts-heatmap.d.ts.map +1 -0
- package/types/tectra-ng-charts-line.d.ts +1023 -0
- package/types/tectra-ng-charts-line.d.ts.map +1 -0
- package/types/tectra-ng-charts-org-chart.d.ts +1017 -0
- package/types/tectra-ng-charts-org-chart.d.ts.map +1 -0
- package/types/tectra-ng-charts-pie.d.ts +983 -0
- package/types/tectra-ng-charts-pie.d.ts.map +1 -0
- package/types/tectra-ng-charts-radar.d.ts +903 -0
- package/types/tectra-ng-charts-radar.d.ts.map +1 -0
- package/types/tectra-ng-charts-radial-bar.d.ts +886 -0
- package/types/tectra-ng-charts-radial-bar.d.ts.map +1 -0
- package/types/tectra-ng-charts-range-area.d.ts +897 -0
- package/types/tectra-ng-charts-range-area.d.ts.map +1 -0
- package/types/tectra-ng-charts-rank-line.d.ts +839 -0
- package/types/tectra-ng-charts-rank-line.d.ts.map +1 -0
- package/types/tectra-ng-charts-sankey.d.ts +866 -0
- package/types/tectra-ng-charts-sankey.d.ts.map +1 -0
- package/types/tectra-ng-charts-scatter.d.ts +987 -0
- package/types/tectra-ng-charts-scatter.d.ts.map +1 -0
- package/types/tectra-ng-charts-segmented-bar.d.ts +751 -0
- package/types/tectra-ng-charts-segmented-bar.d.ts.map +1 -0
- package/types/tectra-ng-charts-sunburst.d.ts +864 -0
- package/types/tectra-ng-charts-sunburst.d.ts.map +1 -0
- package/types/tectra-ng-charts-treemap.d.ts +847 -0
- package/types/tectra-ng-charts-treemap.d.ts.map +1 -0
- package/types/tectra-ng-charts-waterfall.d.ts +869 -0
- package/types/tectra-ng-charts-waterfall.d.ts.map +1 -0
- package/types/tectra-ng-charts.d.ts +2 -0
- package/types/tectra-ng-charts.d.ts.map +1 -0
- package/waterfall/README.md +60 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { TX_FULL_CIRCLE, TxChartFrame, TxChartTooltipTemplate, arcPath, chartNumberFormatter, initialChartSize, injectChartEntrance, polar, readTokenNumber, seriesColor, textWidth } from "@tectra-ng/charts/core";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, ElementRef, afterRenderEffect, booleanAttribute, computed, contentChild, inject, input, linkedSignal, output, signal, viewChild } from "@angular/core";
|
|
4
|
+
import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
|
|
5
|
+
import { TxLocaleService, injectTranslations } from "@tectra-ng/core/i18n";
|
|
6
|
+
import { optionalBoolean } from "@tectra-ng/core/utils";
|
|
7
|
+
import { toStyleObject } from "@tectra-ng/themes";
|
|
8
|
+
function sunburstValue(item) {
|
|
9
|
+
const own = item.value !== null && item.value !== void 0 && Number.isFinite(item.value) ? Math.max(0, item.value) : null;
|
|
10
|
+
const children = (item.children ?? []).reduce((sum, child) => sum + sunburstValue(child), 0);
|
|
11
|
+
return own ?? children;
|
|
12
|
+
}
|
|
13
|
+
function sunburstFocus(roots, path) {
|
|
14
|
+
let items = roots;
|
|
15
|
+
const trail = [];
|
|
16
|
+
for (const index of path) {
|
|
17
|
+
const item = items[index];
|
|
18
|
+
if (!item) break;
|
|
19
|
+
trail.push(item);
|
|
20
|
+
items = item.children ?? [];
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
items,
|
|
24
|
+
trail
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function sunburstArcs(roots, options) {
|
|
28
|
+
const { items, trail } = sunburstFocus(roots, options.focus);
|
|
29
|
+
const levels = Math.max(1, Math.floor(options.levels));
|
|
30
|
+
const inner = options.radius * Math.min(.9, Math.max(0, options.hole));
|
|
31
|
+
const ring = (options.radius - inner) / levels;
|
|
32
|
+
const sum = items.reduce((acc, item) => acc + sunburstValue(item), 0);
|
|
33
|
+
const focused = trail[trail.length - 1];
|
|
34
|
+
const total = focused ? Math.max(sunburstValue(focused), sum) : sum;
|
|
35
|
+
const arcs = [];
|
|
36
|
+
const topIndex = options.focus[0];
|
|
37
|
+
const inherited = trail.reduce((color, item) => item.color ?? color, void 0);
|
|
38
|
+
const walk = (list, path, start, span, depth, parentValue, color) => {
|
|
39
|
+
let cursor = start;
|
|
40
|
+
list.forEach((item, index) => {
|
|
41
|
+
const value = sunburstValue(item);
|
|
42
|
+
if (value <= 0) return;
|
|
43
|
+
const sweep = parentValue > 0 ? value / parentValue * span : 0;
|
|
44
|
+
const itemPath = [...path, index];
|
|
45
|
+
const base = item.color ?? color ?? seriesColor(void 0, topIndex ?? itemPath[0]);
|
|
46
|
+
arcs.push({
|
|
47
|
+
key: itemPath.join("."),
|
|
48
|
+
path: itemPath,
|
|
49
|
+
item,
|
|
50
|
+
label: item.label,
|
|
51
|
+
value,
|
|
52
|
+
depth,
|
|
53
|
+
start: cursor,
|
|
54
|
+
end: cursor + sweep,
|
|
55
|
+
inner: inner + (depth - 1) * ring,
|
|
56
|
+
outer: inner + depth * ring,
|
|
57
|
+
base,
|
|
58
|
+
share: total ? value / total : 0,
|
|
59
|
+
parentShare: parentValue ? value / parentValue : 0,
|
|
60
|
+
hasChildren: !!item.children?.some((child) => sunburstValue(child) > 0)
|
|
61
|
+
});
|
|
62
|
+
if (depth < levels && item.children?.length) walk(item.children, itemPath, cursor, sweep, depth + 1, Math.max(value, (item.children ?? []).reduce((sum, child) => sum + sunburstValue(child), 0)), item.color ?? color ?? base);
|
|
63
|
+
cursor += sweep;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
walk(items, [...options.focus], 0, TX_FULL_CIRCLE, 1, total, inherited);
|
|
67
|
+
return arcs;
|
|
68
|
+
}
|
|
69
|
+
function sunburstArcAt(arcs, x, y, cx, cy) {
|
|
70
|
+
const distance = Math.hypot(x - cx, y - cy);
|
|
71
|
+
let angle = Math.atan2(x - cx, -(y - cy));
|
|
72
|
+
if (angle < 0) angle += TX_FULL_CIRCLE;
|
|
73
|
+
return arcs.find((arc) => distance >= arc.inner && distance <= arc.outer && angle >= arc.start && angle < arc.end) ?? null;
|
|
74
|
+
}
|
|
75
|
+
const DEFAULTS = {
|
|
76
|
+
hole: .3,
|
|
77
|
+
corner: 3,
|
|
78
|
+
fontSize: 11
|
|
79
|
+
};
|
|
80
|
+
const PADDING = 6;
|
|
81
|
+
const CENTER = "center";
|
|
82
|
+
var TxSunburstChart = class TxSunburstChart {
|
|
83
|
+
locale = inject(TxLocaleService);
|
|
84
|
+
host = inject(ElementRef);
|
|
85
|
+
translations = injectTranslations();
|
|
86
|
+
data = input([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
87
|
+
levels = input(3, ...ngDevMode ? [{ debugName: "levels" }] : /* istanbul ignore next */ []);
|
|
88
|
+
height = input(380, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
|
|
89
|
+
showLabels = input(true, {
|
|
90
|
+
...ngDevMode ? { debugName: "showLabels" } : /* istanbul ignore next */ {},
|
|
91
|
+
transform: booleanAttribute
|
|
92
|
+
});
|
|
93
|
+
showTooltip = input(true, {
|
|
94
|
+
...ngDevMode ? { debugName: "showTooltip" } : /* istanbul ignore next */ {},
|
|
95
|
+
transform: booleanAttribute
|
|
96
|
+
});
|
|
97
|
+
drill = input(true, {
|
|
98
|
+
...ngDevMode ? { debugName: "drill" } : /* istanbul ignore next */ {},
|
|
99
|
+
transform: booleanAttribute
|
|
100
|
+
});
|
|
101
|
+
totalLabel = input("", ...ngDevMode ? [{ debugName: "totalLabel" }] : /* istanbul ignore next */ []);
|
|
102
|
+
valueFormat = input("number", ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
|
|
103
|
+
toolbar = input(true, {
|
|
104
|
+
...ngDevMode ? { debugName: "toolbar" } : /* istanbul ignore next */ {},
|
|
105
|
+
transform: booleanAttribute
|
|
106
|
+
});
|
|
107
|
+
loading = input(false, {
|
|
108
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
109
|
+
transform: booleanAttribute
|
|
110
|
+
});
|
|
111
|
+
ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
112
|
+
dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
|
|
113
|
+
pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
|
|
114
|
+
ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
|
|
115
|
+
unstyled = input(void 0, {
|
|
116
|
+
...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
|
|
117
|
+
transform: optionalBoolean
|
|
118
|
+
});
|
|
119
|
+
segmentClick = output();
|
|
120
|
+
focusChange = output();
|
|
121
|
+
tooltipTemplate = contentChild(TxChartTooltipTemplate, ...ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []);
|
|
122
|
+
frame = viewChild(TxChartFrame, ...ngDevMode ? [{ debugName: "frame" }] : /* istanbul ignore next */ []);
|
|
123
|
+
isUnstyled = injectUnstyled(this.unstyled);
|
|
124
|
+
passThrough = injectPassThrough("sunburstChart", this, this.pt, this.ptOptions);
|
|
125
|
+
tokenStyle = computed(() => toStyleObject(this.dt(), "--tx-chart"), ...ngDevMode ? [{ debugName: "tokenStyle" }] : /* istanbul ignore next */ []);
|
|
126
|
+
hostStyle = computed(() => ({
|
|
127
|
+
...this.tokenStyle(),
|
|
128
|
+
...this.passThrough().root?.style
|
|
129
|
+
}), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
|
|
130
|
+
entrance = injectChartEntrance();
|
|
131
|
+
geometry = signal(DEFAULTS, ...ngDevMode ? [{ debugName: "geometry" }] : /* istanbul ignore next */ []);
|
|
132
|
+
intl = computed(() => this.locale.locale().intl, ...ngDevMode ? [{ debugName: "intl" }] : /* istanbul ignore next */ []);
|
|
133
|
+
roots = computed(() => {
|
|
134
|
+
const data = this.data();
|
|
135
|
+
return !data ? [] : Array.isArray(data) ? data : [data];
|
|
136
|
+
}, ...ngDevMode ? [{ debugName: "roots" }] : /* istanbul ignore next */ []);
|
|
137
|
+
focus = linkedSignal({
|
|
138
|
+
...ngDevMode ? { debugName: "focus" } : /* istanbul ignore next */ {},
|
|
139
|
+
source: this.roots,
|
|
140
|
+
computation: () => []
|
|
141
|
+
});
|
|
142
|
+
active = signal(null, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
|
|
143
|
+
size = linkedSignal(() => initialChartSize(this.height(), null, void 0, this.toolbar()), ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
144
|
+
isEmpty = computed(() => !this.roots().some((item) => sunburstValue(item) > 0), ...ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []);
|
|
145
|
+
fit = computed(() => {
|
|
146
|
+
const { width, height } = this.size();
|
|
147
|
+
return {
|
|
148
|
+
cx: width / 2,
|
|
149
|
+
cy: height / 2,
|
|
150
|
+
radius: Math.max(10, Math.min(width, height) / 2 - PADDING)
|
|
151
|
+
};
|
|
152
|
+
}, ...ngDevMode ? [{ debugName: "fit" }] : /* istanbul ignore next */ []);
|
|
153
|
+
arcs = computed(() => sunburstArcs(this.roots(), {
|
|
154
|
+
levels: this.levels(),
|
|
155
|
+
radius: this.fit().radius,
|
|
156
|
+
hole: this.geometry().hole,
|
|
157
|
+
focus: this.focus()
|
|
158
|
+
}), ...ngDevMode ? [{ debugName: "arcs" }] : /* istanbul ignore next */ []);
|
|
159
|
+
inner = computed(() => this.fit().radius * Math.min(.9, Math.max(0, this.geometry().hole)), ...ngDevMode ? [{ debugName: "inner" }] : /* istanbul ignore next */ []);
|
|
160
|
+
holeRadius = computed(() => Math.max(0, this.inner() - 2), ...ngDevMode ? [{ debugName: "holeRadius" }] : /* istanbul ignore next */ []);
|
|
161
|
+
trail = computed(() => sunburstFocus(this.roots(), this.focus()).trail, ...ngDevMode ? [{ debugName: "trail" }] : /* istanbul ignore next */ []);
|
|
162
|
+
activeArc = computed(() => {
|
|
163
|
+
const key = this.active();
|
|
164
|
+
return key && key !== CENTER ? this.arcs().find((arc) => arc.key === key) ?? null : null;
|
|
165
|
+
}, ...ngDevMode ? [{ debugName: "activeArc" }] : /* istanbul ignore next */ []);
|
|
166
|
+
valueFormatter = computed(() => chartNumberFormatter(this.intl(), this.valueFormat()), ...ngDevMode ? [{ debugName: "valueFormatter" }] : /* istanbul ignore next */ []);
|
|
167
|
+
percentFormatter = computed(() => {
|
|
168
|
+
const format = chartNumberFormatter(this.intl(), "percent");
|
|
169
|
+
return (share) => format(Number((share * 100).toFixed(1)));
|
|
170
|
+
}, ...ngDevMode ? [{ debugName: "percentFormatter" }] : /* istanbul ignore next */ []);
|
|
171
|
+
segments = computed(() => {
|
|
172
|
+
const { cx, cy } = this.fit();
|
|
173
|
+
const corner = this.geometry().corner;
|
|
174
|
+
const fontSize = this.geometry().fontSize;
|
|
175
|
+
return this.arcs().map((arc) => {
|
|
176
|
+
const middle = (arc.start + arc.end) / 2;
|
|
177
|
+
const radius = (arc.inner + arc.outer) / 2;
|
|
178
|
+
const at = polar(cx, cy, radius, middle);
|
|
179
|
+
const room = (arc.end - arc.start) * radius;
|
|
180
|
+
const fits = this.showLabels() && room >= textWidth(arc.label, fontSize) + 8 && arc.outer - arc.inner >= fontSize + 6;
|
|
181
|
+
return {
|
|
182
|
+
...arc,
|
|
183
|
+
d: arcPath(cx, cy, arc.inner, arc.outer, arc.start, arc.end, corner),
|
|
184
|
+
fill: arc.depth > 1 ? `color-mix(in srgb, ${arc.base} calc(100% - ${arc.depth - 1} * var(--tx-chart-sunburst-level-fade, 22%)), var(--tx-chart-sunburst-fade-base, transparent))` : arc.base,
|
|
185
|
+
labelX: at.x,
|
|
186
|
+
labelY: at.y,
|
|
187
|
+
text: fits ? arc.label : null
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
}, ...ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []);
|
|
191
|
+
center = computed(() => {
|
|
192
|
+
const t = this.translations();
|
|
193
|
+
const trail = this.trail();
|
|
194
|
+
const focused = trail[trail.length - 1];
|
|
195
|
+
const value = focused ? sunburstValue(focused) : this.roots().reduce((sum, item) => sum + sunburstValue(item), 0);
|
|
196
|
+
return {
|
|
197
|
+
label: focused?.label ?? (this.totalLabel() || t.chartTotal),
|
|
198
|
+
value: this.valueFormatter()(value),
|
|
199
|
+
canGoUp: trail.length > 0 && this.drill()
|
|
200
|
+
};
|
|
201
|
+
}, ...ngDevMode ? [{ debugName: "center" }] : /* istanbul ignore next */ []);
|
|
202
|
+
centerFont = computed(() => {
|
|
203
|
+
const inner = this.inner();
|
|
204
|
+
return {
|
|
205
|
+
value: Math.max(12, Math.min(24, inner * .32)),
|
|
206
|
+
label: Math.max(10, Math.min(13, inner * .17))
|
|
207
|
+
};
|
|
208
|
+
}, ...ngDevMode ? [{ debugName: "centerFont" }] : /* istanbul ignore next */ []);
|
|
209
|
+
tooltip = computed(() => {
|
|
210
|
+
const arc = this.activeArc();
|
|
211
|
+
if (!arc || !this.showTooltip()) return null;
|
|
212
|
+
const t = this.translations();
|
|
213
|
+
const { cx, cy } = this.fit();
|
|
214
|
+
const middle = (arc.start + arc.end) / 2;
|
|
215
|
+
const at = polar(cx, cy, arc.outer + 2, middle);
|
|
216
|
+
const sin = Math.sin(middle);
|
|
217
|
+
const placement = Math.abs(sin) >= Math.SQRT1_2 ? sin > 0 ? "right" : "left" : Math.cos(middle) > 0 ? "top" : "bottom";
|
|
218
|
+
return {
|
|
219
|
+
title: this.names(arc.path).slice(0, -1).join(" / "),
|
|
220
|
+
rows: [
|
|
221
|
+
{
|
|
222
|
+
label: arc.label,
|
|
223
|
+
value: this.valueFormatter()(arc.value),
|
|
224
|
+
color: arc.base,
|
|
225
|
+
raw: arc.value,
|
|
226
|
+
seriesIndex: 0,
|
|
227
|
+
active: true
|
|
228
|
+
},
|
|
229
|
+
...arc.depth > 1 || this.focus().length ? [{
|
|
230
|
+
label: t.chartOfParent,
|
|
231
|
+
value: this.percentFormatter()(arc.parentShare),
|
|
232
|
+
color: "transparent",
|
|
233
|
+
raw: arc.parentShare,
|
|
234
|
+
seriesIndex: 1
|
|
235
|
+
}] : [],
|
|
236
|
+
{
|
|
237
|
+
label: t.chartOfTotal,
|
|
238
|
+
value: this.percentFormatter()(arc.share),
|
|
239
|
+
color: "transparent",
|
|
240
|
+
raw: arc.share,
|
|
241
|
+
seriesIndex: 2
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
index: 0,
|
|
245
|
+
x: at.x,
|
|
246
|
+
y: at.y,
|
|
247
|
+
placement
|
|
248
|
+
};
|
|
249
|
+
}, ...ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []);
|
|
250
|
+
summary = computed(() => {
|
|
251
|
+
const t = this.translations();
|
|
252
|
+
const parts = this.arcs().filter((arc) => arc.depth === 1).map((arc) => `${arc.label} ${this.percentFormatter()(arc.share)}`);
|
|
253
|
+
const text = `${t.chartSunburst}, ${this.center().label} ${this.center().value}: ${parts.join(", ")}`;
|
|
254
|
+
return this.ariaLabel() ? `${this.ariaLabel()}. ${text}` : text;
|
|
255
|
+
}, ...ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []);
|
|
256
|
+
dataTable = computed(() => {
|
|
257
|
+
const t = this.translations();
|
|
258
|
+
return {
|
|
259
|
+
columns: [{
|
|
260
|
+
key: "value",
|
|
261
|
+
label: t.chartValue
|
|
262
|
+
}, {
|
|
263
|
+
key: "share",
|
|
264
|
+
label: t.chartOfTotal
|
|
265
|
+
}],
|
|
266
|
+
rows: this.arcs().map((arc) => ({
|
|
267
|
+
label: this.names(arc.path).join(" / "),
|
|
268
|
+
cells: [this.valueFormatter()(arc.value), this.percentFormatter()(arc.share)]
|
|
269
|
+
}))
|
|
270
|
+
};
|
|
271
|
+
}, ...ngDevMode ? [{ debugName: "dataTable" }] : /* istanbul ignore next */ []);
|
|
272
|
+
constructor() {
|
|
273
|
+
afterRenderEffect(() => {
|
|
274
|
+
this.dt();
|
|
275
|
+
this.readGeometry();
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
isLit(key) {
|
|
279
|
+
const active = this.activeArc();
|
|
280
|
+
return !active || active.key === key || active.key.startsWith(`${key}.`);
|
|
281
|
+
}
|
|
282
|
+
onPointer(event) {
|
|
283
|
+
if (event.type === "leave") {
|
|
284
|
+
this.active.set(null);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const { cx, cy } = this.fit();
|
|
288
|
+
const inCenter = Math.hypot(event.x - cx, event.y - cy) < this.inner();
|
|
289
|
+
const arc = inCenter ? null : sunburstArcAt(this.arcs(), event.x, event.y, cx, cy);
|
|
290
|
+
this.active.set(inCenter && this.center().canGoUp ? CENTER : arc?.key ?? null);
|
|
291
|
+
if (event.type !== "click") return;
|
|
292
|
+
if (inCenter) this.up();
|
|
293
|
+
else if (arc) this.select(arc);
|
|
294
|
+
}
|
|
295
|
+
onNavigate(event) {
|
|
296
|
+
const arcs = this.arcs();
|
|
297
|
+
if (!arcs.length) return;
|
|
298
|
+
const current = this.activeArc();
|
|
299
|
+
if (event.key === "Escape" || event.key === "Backspace") {
|
|
300
|
+
if (current) this.active.set(null);
|
|
301
|
+
else this.up();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
305
|
+
if (current) this.select(current);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
let next;
|
|
309
|
+
if (!current) next = arcs.find((arc) => arc.depth === 1);
|
|
310
|
+
else if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
311
|
+
const siblings = arcs.filter((arc) => arc.depth === current.depth && arc.path.slice(0, -1).join(".") === current.path.slice(0, -1).join("."));
|
|
312
|
+
next = siblings[(siblings.indexOf(current) + (event.key === "ArrowRight" ? 1 : -1) + siblings.length) % siblings.length];
|
|
313
|
+
} else if (event.key === "ArrowDown") next = arcs.find((arc) => arc.depth === current.depth + 1 && arc.key.startsWith(`${current.key}.`)) ?? current;
|
|
314
|
+
else if (event.key === "ArrowUp") next = arcs.find((arc) => arc.key === current.path.slice(0, -1).join(".")) ?? current;
|
|
315
|
+
else if (event.key === "Home" || event.key === "End") {
|
|
316
|
+
const top = arcs.filter((arc) => arc.depth === 1);
|
|
317
|
+
next = event.key === "Home" ? top[0] : top[top.length - 1];
|
|
318
|
+
}
|
|
319
|
+
if (!next) return;
|
|
320
|
+
this.active.set(next.key);
|
|
321
|
+
this.frame()?.announce(`${this.names(next.path).join(" / ")}: ${this.valueFormatter()(next.value)}, ${this.percentFormatter()(next.share)}`);
|
|
322
|
+
}
|
|
323
|
+
up() {
|
|
324
|
+
if (!this.focus().length || !this.drill()) return;
|
|
325
|
+
this.focus.update((path) => path.slice(0, -1));
|
|
326
|
+
this.afterDrill();
|
|
327
|
+
}
|
|
328
|
+
select(arc) {
|
|
329
|
+
this.segmentClick.emit({
|
|
330
|
+
path: this.names(arc.path),
|
|
331
|
+
value: arc.value,
|
|
332
|
+
item: arc.item
|
|
333
|
+
});
|
|
334
|
+
if (!this.drill() || !arc.hasChildren) return;
|
|
335
|
+
this.focus.set(arc.path);
|
|
336
|
+
this.afterDrill();
|
|
337
|
+
}
|
|
338
|
+
afterDrill() {
|
|
339
|
+
this.active.set(null);
|
|
340
|
+
this.entrance.play();
|
|
341
|
+
const names = this.names(this.focus());
|
|
342
|
+
this.focusChange.emit(names);
|
|
343
|
+
this.frame()?.announce(names.length ? names.join(" / ") : this.center().label);
|
|
344
|
+
}
|
|
345
|
+
names(path) {
|
|
346
|
+
const names = [];
|
|
347
|
+
let items = this.roots();
|
|
348
|
+
for (const index of path) {
|
|
349
|
+
const item = items[index];
|
|
350
|
+
if (!item) break;
|
|
351
|
+
names.push(item.label);
|
|
352
|
+
items = item.children ?? [];
|
|
353
|
+
}
|
|
354
|
+
return names;
|
|
355
|
+
}
|
|
356
|
+
readGeometry() {
|
|
357
|
+
const element = this.host.nativeElement;
|
|
358
|
+
const next = {
|
|
359
|
+
hole: readTokenNumber(element, "--tx-chart-sunburst-hole", DEFAULTS.hole),
|
|
360
|
+
corner: this.isUnstyled() ? 0 : readTokenNumber(element, "--tx-chart-sunburst-corner-radius", DEFAULTS.corner),
|
|
361
|
+
fontSize: readTokenNumber(element, "--tx-chart-sunburst-label-font-size", DEFAULTS.fontSize)
|
|
362
|
+
};
|
|
363
|
+
const current = this.geometry();
|
|
364
|
+
if (current.hole !== next.hole || current.corner !== next.corner || current.fontSize !== next.fontSize) this.geometry.set(next);
|
|
365
|
+
}
|
|
366
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
367
|
+
minVersion: "12.0.0",
|
|
368
|
+
version: "22.2.3",
|
|
369
|
+
ngImport: i0,
|
|
370
|
+
type: TxSunburstChart,
|
|
371
|
+
deps: [],
|
|
372
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
373
|
+
});
|
|
374
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
375
|
+
minVersion: "17.0.0",
|
|
376
|
+
version: "22.2.3",
|
|
377
|
+
type: TxSunburstChart,
|
|
378
|
+
isStandalone: true,
|
|
379
|
+
selector: "tx-sunburst-chart",
|
|
380
|
+
inputs: {
|
|
381
|
+
data: {
|
|
382
|
+
classPropertyName: "data",
|
|
383
|
+
publicName: "data",
|
|
384
|
+
isSignal: true,
|
|
385
|
+
isRequired: false,
|
|
386
|
+
transformFunction: null
|
|
387
|
+
},
|
|
388
|
+
levels: {
|
|
389
|
+
classPropertyName: "levels",
|
|
390
|
+
publicName: "levels",
|
|
391
|
+
isSignal: true,
|
|
392
|
+
isRequired: false,
|
|
393
|
+
transformFunction: null
|
|
394
|
+
},
|
|
395
|
+
height: {
|
|
396
|
+
classPropertyName: "height",
|
|
397
|
+
publicName: "height",
|
|
398
|
+
isSignal: true,
|
|
399
|
+
isRequired: false,
|
|
400
|
+
transformFunction: null
|
|
401
|
+
},
|
|
402
|
+
showLabels: {
|
|
403
|
+
classPropertyName: "showLabels",
|
|
404
|
+
publicName: "showLabels",
|
|
405
|
+
isSignal: true,
|
|
406
|
+
isRequired: false,
|
|
407
|
+
transformFunction: null
|
|
408
|
+
},
|
|
409
|
+
showTooltip: {
|
|
410
|
+
classPropertyName: "showTooltip",
|
|
411
|
+
publicName: "showTooltip",
|
|
412
|
+
isSignal: true,
|
|
413
|
+
isRequired: false,
|
|
414
|
+
transformFunction: null
|
|
415
|
+
},
|
|
416
|
+
drill: {
|
|
417
|
+
classPropertyName: "drill",
|
|
418
|
+
publicName: "drill",
|
|
419
|
+
isSignal: true,
|
|
420
|
+
isRequired: false,
|
|
421
|
+
transformFunction: null
|
|
422
|
+
},
|
|
423
|
+
totalLabel: {
|
|
424
|
+
classPropertyName: "totalLabel",
|
|
425
|
+
publicName: "totalLabel",
|
|
426
|
+
isSignal: true,
|
|
427
|
+
isRequired: false,
|
|
428
|
+
transformFunction: null
|
|
429
|
+
},
|
|
430
|
+
valueFormat: {
|
|
431
|
+
classPropertyName: "valueFormat",
|
|
432
|
+
publicName: "valueFormat",
|
|
433
|
+
isSignal: true,
|
|
434
|
+
isRequired: false,
|
|
435
|
+
transformFunction: null
|
|
436
|
+
},
|
|
437
|
+
toolbar: {
|
|
438
|
+
classPropertyName: "toolbar",
|
|
439
|
+
publicName: "toolbar",
|
|
440
|
+
isSignal: true,
|
|
441
|
+
isRequired: false,
|
|
442
|
+
transformFunction: null
|
|
443
|
+
},
|
|
444
|
+
loading: {
|
|
445
|
+
classPropertyName: "loading",
|
|
446
|
+
publicName: "loading",
|
|
447
|
+
isSignal: true,
|
|
448
|
+
isRequired: false,
|
|
449
|
+
transformFunction: null
|
|
450
|
+
},
|
|
451
|
+
ariaLabel: {
|
|
452
|
+
classPropertyName: "ariaLabel",
|
|
453
|
+
publicName: "ariaLabel",
|
|
454
|
+
isSignal: true,
|
|
455
|
+
isRequired: false,
|
|
456
|
+
transformFunction: null
|
|
457
|
+
},
|
|
458
|
+
dt: {
|
|
459
|
+
classPropertyName: "dt",
|
|
460
|
+
publicName: "dt",
|
|
461
|
+
isSignal: true,
|
|
462
|
+
isRequired: false,
|
|
463
|
+
transformFunction: null
|
|
464
|
+
},
|
|
465
|
+
pt: {
|
|
466
|
+
classPropertyName: "pt",
|
|
467
|
+
publicName: "pt",
|
|
468
|
+
isSignal: true,
|
|
469
|
+
isRequired: false,
|
|
470
|
+
transformFunction: null
|
|
471
|
+
},
|
|
472
|
+
ptOptions: {
|
|
473
|
+
classPropertyName: "ptOptions",
|
|
474
|
+
publicName: "ptOptions",
|
|
475
|
+
isSignal: true,
|
|
476
|
+
isRequired: false,
|
|
477
|
+
transformFunction: null
|
|
478
|
+
},
|
|
479
|
+
unstyled: {
|
|
480
|
+
classPropertyName: "unstyled",
|
|
481
|
+
publicName: "unstyled",
|
|
482
|
+
isSignal: true,
|
|
483
|
+
isRequired: false,
|
|
484
|
+
transformFunction: null
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
outputs: {
|
|
488
|
+
segmentClick: "segmentClick",
|
|
489
|
+
focusChange: "focusChange"
|
|
490
|
+
},
|
|
491
|
+
host: {
|
|
492
|
+
properties: {
|
|
493
|
+
"class": "passThrough().root?.class",
|
|
494
|
+
"style": "hostStyle()",
|
|
495
|
+
"attr.data-styled": "!isUnstyled() || null",
|
|
496
|
+
"class.tx-sunburst-chart--fill": "typeof height() === \"string\"",
|
|
497
|
+
"class.tx-sunburst-chart--entering": "entrance.active()",
|
|
498
|
+
"class.tx-sunburst-chart--active": "activeArc() !== null"
|
|
499
|
+
},
|
|
500
|
+
classAttribute: "tx-sunburst-chart"
|
|
501
|
+
},
|
|
502
|
+
queries: [{
|
|
503
|
+
propertyName: "tooltipTemplate",
|
|
504
|
+
first: true,
|
|
505
|
+
predicate: TxChartTooltipTemplate,
|
|
506
|
+
descendants: true,
|
|
507
|
+
isSignal: true
|
|
508
|
+
}],
|
|
509
|
+
viewQueries: [{
|
|
510
|
+
propertyName: "frame",
|
|
511
|
+
first: true,
|
|
512
|
+
predicate: TxChartFrame,
|
|
513
|
+
descendants: true,
|
|
514
|
+
isSignal: true
|
|
515
|
+
}],
|
|
516
|
+
ngImport: i0,
|
|
517
|
+
template: "<tx-chart-frame\n [height]=\"height()\"\n [(size)]=\"size\"\n [showLegend]=\"false\"\n actionKeys\n [empty]=\"isEmpty()\"\n [loading]=\"loading()\"\n [toolbar]=\"toolbar()\"\n [exportName]=\"ariaLabel()\"\n emptyIcon=\"chart-pie\"\n [summary]=\"summary()\"\n [table]=\"dataTable()\"\n [tooltip]=\"tooltip()\"\n [tooltipTemplate]=\"tooltipTemplate()?.template\"\n [panelStyle]=\"tokenStyle()\"\n [parts]=\"passThrough()\"\n [styled]=\"!isUnstyled()\"\n (pointer)=\"onPointer($event)\"\n (navigate)=\"onNavigate($event)\"\n (tooltipClosed)=\"active.set(null)\"\n>\n <svg:g class=\"tx-sunburst-chart__segments\" [style.transform-origin]=\"fit().cx + 'px ' + fit().cy + 'px'\">\n @for (segment of segments(); track segment.key) {\n <svg:path\n class=\"tx-sunburst-chart__segment\"\n [class.tx-sunburst-chart__segment--lit]=\"isLit(segment.key)\"\n [class.tx-sunburst-chart__segment--drill]=\"segment.hasChildren && drill()\"\n [class]=\"passThrough().segment?.class\"\n [style]=\"passThrough().segment?.style\"\n [attr.data-key]=\"segment.key\"\n [attr.data-depth]=\"segment.depth\"\n [attr.d]=\"segment.d\"\n [style.fill]=\"segment.fill\"\n />\n }\n </svg:g>\n @if (showLabels()) {\n <svg:g class=\"tx-sunburst-chart__labels\">\n @for (segment of segments(); track segment.key) {\n @if (segment.text) {\n <svg:text\n class=\"tx-sunburst-chart__label\"\n [class]=\"passThrough().label?.class\"\n [style]=\"passThrough().label?.style\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [attr.x]=\"segment.labelX\"\n [attr.y]=\"segment.labelY\"\n >\n {{ segment.text }}\n </svg:text>\n }\n }\n </svg:g>\n }\n <svg:g\n class=\"tx-sunburst-chart__center\"\n [class.tx-sunburst-chart__center--up]=\"center().canGoUp\"\n [class.tx-sunburst-chart__center--hover]=\"active() === 'center'\"\n [class]=\"passThrough().center?.class\"\n [style]=\"passThrough().center?.style\"\n >\n <svg:circle class=\"tx-sunburst-chart__hole\" [attr.cx]=\"fit().cx\" [attr.cy]=\"fit().cy\" [attr.r]=\"holeRadius()\" />\n @if (center().canGoUp) {\n <svg:path\n class=\"tx-sunburst-chart__back\"\n [attr.d]=\"'M' + (fit().cx - 4) + ',' + (fit().cy - centerFont().value * 0.95 - 4) + 'l4,-4l4,4'\"\n />\n }\n <svg:text\n class=\"tx-sunburst-chart__center-value\"\n text-anchor=\"middle\"\n [attr.x]=\"fit().cx\"\n [attr.y]=\"fit().cy + centerFont().value * 0.3 - centerFont().label * 0.55\"\n [style.font-size.px]=\"centerFont().value\"\n >\n {{ center().value }}\n </svg:text>\n <svg:text\n class=\"tx-sunburst-chart__center-label\"\n text-anchor=\"middle\"\n dominant-baseline=\"hanging\"\n [attr.x]=\"fit().cx\"\n [attr.y]=\"fit().cy + centerFont().value * 0.3 - centerFont().label * 0.55 + 6\"\n [style.font-size.px]=\"centerFont().label\"\n >\n {{ center().label }}\n </svg:text>\n </svg:g>\n</tx-chart-frame>\n",
|
|
518
|
+
styles: [":host{display:block;min-width:0}:host(.tx-sunburst-chart--fill){height:100%}.tx-sunburst-chart__segments{transform-box:view-box}.tx-sunburst-chart__segment{stroke:transparent}.tx-sunburst-chart__labels,.tx-sunburst-chart__center text,.tx-sunburst-chart__back{pointer-events:none}.tx-sunburst-chart__hole{fill:transparent}.tx-sunburst-chart__back{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round}.tx-sunburst-chart__center--up,.tx-sunburst-chart__segment--drill{cursor:pointer}:host([data-styled]) .tx-sunburst-chart__segment{stroke:var(--tx-chart-sunburst-gap-color);stroke-width:var(--tx-chart-sunburst-gap);stroke-linejoin:round;transition:opacity var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sunburst-chart__label{fill:var(--tx-chart-sunburst-label-color);font-size:var(--tx-chart-sunburst-label-font-size);font-weight:var(--tx-chart-sunburst-label-font-weight);filter:var(--tx-chart-sunburst-label-shadow)}:host([data-styled]) .tx-sunburst-chart__hole{transition:fill var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sunburst-chart__center--hover .tx-sunburst-chart__hole{fill:var(--tx-chart-sunburst-center-hover-background)}:host([data-styled]) .tx-sunburst-chart__back{stroke:var(--tx-chart-sunburst-center-label-color);stroke-width:var(--tx-chart-marker-stroke-width)}:host([data-styled]) .tx-sunburst-chart__center-value{fill:var(--tx-chart-sunburst-center-value-color);font-weight:var(--tx-chart-sunburst-center-value-font-weight);font-variant-numeric:tabular-nums}:host([data-styled]) .tx-sunburst-chart__center-label{fill:var(--tx-chart-sunburst-center-label-color)}:host([data-styled].tx-sunburst-chart--active) .tx-sunburst-chart__segment:not(.tx-sunburst-chart__segment--lit){opacity:var(--tx-chart-sunburst-dimmed-opacity)}:host([data-styled].tx-sunburst-chart--entering) .tx-sunburst-chart__segments{animation:tx-sunburst-chart-grow var(--tx-chart-motion-enter-duration) var(--tx-chart-motion-easing) both}:host([data-styled].tx-sunburst-chart--entering) .tx-sunburst-chart__labels{animation:tx-sunburst-chart-fade var(--tx-chart-motion-enter-duration) ease both}@keyframes tx-sunburst-chart-grow{0%{transform:scale(.82) rotate(-25deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}@keyframes tx-sunburst-chart-fade{0%,50%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-sunburst-chart__segment,:host([data-styled]) .tx-sunburst-chart__segments,:host([data-styled]) .tx-sunburst-chart__labels,:host([data-styled]) .tx-sunburst-chart__hole{transition:none;animation:none}}\n"],
|
|
519
|
+
dependencies: [{
|
|
520
|
+
kind: "component",
|
|
521
|
+
type: TxChartFrame,
|
|
522
|
+
selector: "tx-chart-frame",
|
|
523
|
+
inputs: [
|
|
524
|
+
"height",
|
|
525
|
+
"size",
|
|
526
|
+
"legendItems",
|
|
527
|
+
"showLegend",
|
|
528
|
+
"legendPosition",
|
|
529
|
+
"legendAlign",
|
|
530
|
+
"legendVariant",
|
|
531
|
+
"legendToggle",
|
|
532
|
+
"legendTemplate",
|
|
533
|
+
"empty",
|
|
534
|
+
"loading",
|
|
535
|
+
"emptyIcon",
|
|
536
|
+
"summary",
|
|
537
|
+
"table",
|
|
538
|
+
"tooltip",
|
|
539
|
+
"tooltipTemplate",
|
|
540
|
+
"tooltipPlacement",
|
|
541
|
+
"panelStyle",
|
|
542
|
+
"parts",
|
|
543
|
+
"styled",
|
|
544
|
+
"interactive",
|
|
545
|
+
"actionKeys",
|
|
546
|
+
"zoomable",
|
|
547
|
+
"zoomedIn",
|
|
548
|
+
"plotHeight",
|
|
549
|
+
"toolbar",
|
|
550
|
+
"exportName"
|
|
551
|
+
],
|
|
552
|
+
outputs: [
|
|
553
|
+
"sizeChange",
|
|
554
|
+
"pointer",
|
|
555
|
+
"navigate",
|
|
556
|
+
"legendToggled",
|
|
557
|
+
"legendHovered",
|
|
558
|
+
"tooltipClosed",
|
|
559
|
+
"zoomed",
|
|
560
|
+
"panned",
|
|
561
|
+
"zoomReset"
|
|
562
|
+
]
|
|
563
|
+
}],
|
|
564
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
568
|
+
minVersion: "12.0.0",
|
|
569
|
+
version: "22.2.3",
|
|
570
|
+
ngImport: i0,
|
|
571
|
+
type: TxSunburstChart,
|
|
572
|
+
decorators: [{
|
|
573
|
+
type: Component,
|
|
574
|
+
args: [{
|
|
575
|
+
selector: "tx-sunburst-chart",
|
|
576
|
+
imports: [TxChartFrame],
|
|
577
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
578
|
+
host: {
|
|
579
|
+
class: "tx-sunburst-chart",
|
|
580
|
+
"[class]": "passThrough().root?.class",
|
|
581
|
+
"[style]": "hostStyle()",
|
|
582
|
+
"[attr.data-styled]": "!isUnstyled() || null",
|
|
583
|
+
"[class.tx-sunburst-chart--fill]": "typeof height() === \"string\"",
|
|
584
|
+
"[class.tx-sunburst-chart--entering]": "entrance.active()",
|
|
585
|
+
"[class.tx-sunburst-chart--active]": "activeArc() !== null"
|
|
586
|
+
},
|
|
587
|
+
template: "<tx-chart-frame\n [height]=\"height()\"\n [(size)]=\"size\"\n [showLegend]=\"false\"\n actionKeys\n [empty]=\"isEmpty()\"\n [loading]=\"loading()\"\n [toolbar]=\"toolbar()\"\n [exportName]=\"ariaLabel()\"\n emptyIcon=\"chart-pie\"\n [summary]=\"summary()\"\n [table]=\"dataTable()\"\n [tooltip]=\"tooltip()\"\n [tooltipTemplate]=\"tooltipTemplate()?.template\"\n [panelStyle]=\"tokenStyle()\"\n [parts]=\"passThrough()\"\n [styled]=\"!isUnstyled()\"\n (pointer)=\"onPointer($event)\"\n (navigate)=\"onNavigate($event)\"\n (tooltipClosed)=\"active.set(null)\"\n>\n <svg:g class=\"tx-sunburst-chart__segments\" [style.transform-origin]=\"fit().cx + 'px ' + fit().cy + 'px'\">\n @for (segment of segments(); track segment.key) {\n <svg:path\n class=\"tx-sunburst-chart__segment\"\n [class.tx-sunburst-chart__segment--lit]=\"isLit(segment.key)\"\n [class.tx-sunburst-chart__segment--drill]=\"segment.hasChildren && drill()\"\n [class]=\"passThrough().segment?.class\"\n [style]=\"passThrough().segment?.style\"\n [attr.data-key]=\"segment.key\"\n [attr.data-depth]=\"segment.depth\"\n [attr.d]=\"segment.d\"\n [style.fill]=\"segment.fill\"\n />\n }\n </svg:g>\n @if (showLabels()) {\n <svg:g class=\"tx-sunburst-chart__labels\">\n @for (segment of segments(); track segment.key) {\n @if (segment.text) {\n <svg:text\n class=\"tx-sunburst-chart__label\"\n [class]=\"passThrough().label?.class\"\n [style]=\"passThrough().label?.style\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [attr.x]=\"segment.labelX\"\n [attr.y]=\"segment.labelY\"\n >\n {{ segment.text }}\n </svg:text>\n }\n }\n </svg:g>\n }\n <svg:g\n class=\"tx-sunburst-chart__center\"\n [class.tx-sunburst-chart__center--up]=\"center().canGoUp\"\n [class.tx-sunburst-chart__center--hover]=\"active() === 'center'\"\n [class]=\"passThrough().center?.class\"\n [style]=\"passThrough().center?.style\"\n >\n <svg:circle class=\"tx-sunburst-chart__hole\" [attr.cx]=\"fit().cx\" [attr.cy]=\"fit().cy\" [attr.r]=\"holeRadius()\" />\n @if (center().canGoUp) {\n <svg:path\n class=\"tx-sunburst-chart__back\"\n [attr.d]=\"'M' + (fit().cx - 4) + ',' + (fit().cy - centerFont().value * 0.95 - 4) + 'l4,-4l4,4'\"\n />\n }\n <svg:text\n class=\"tx-sunburst-chart__center-value\"\n text-anchor=\"middle\"\n [attr.x]=\"fit().cx\"\n [attr.y]=\"fit().cy + centerFont().value * 0.3 - centerFont().label * 0.55\"\n [style.font-size.px]=\"centerFont().value\"\n >\n {{ center().value }}\n </svg:text>\n <svg:text\n class=\"tx-sunburst-chart__center-label\"\n text-anchor=\"middle\"\n dominant-baseline=\"hanging\"\n [attr.x]=\"fit().cx\"\n [attr.y]=\"fit().cy + centerFont().value * 0.3 - centerFont().label * 0.55 + 6\"\n [style.font-size.px]=\"centerFont().label\"\n >\n {{ center().label }}\n </svg:text>\n </svg:g>\n</tx-chart-frame>\n",
|
|
588
|
+
styles: [":host{display:block;min-width:0}:host(.tx-sunburst-chart--fill){height:100%}.tx-sunburst-chart__segments{transform-box:view-box}.tx-sunburst-chart__segment{stroke:transparent}.tx-sunburst-chart__labels,.tx-sunburst-chart__center text,.tx-sunburst-chart__back{pointer-events:none}.tx-sunburst-chart__hole{fill:transparent}.tx-sunburst-chart__back{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round}.tx-sunburst-chart__center--up,.tx-sunburst-chart__segment--drill{cursor:pointer}:host([data-styled]) .tx-sunburst-chart__segment{stroke:var(--tx-chart-sunburst-gap-color);stroke-width:var(--tx-chart-sunburst-gap);stroke-linejoin:round;transition:opacity var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sunburst-chart__label{fill:var(--tx-chart-sunburst-label-color);font-size:var(--tx-chart-sunburst-label-font-size);font-weight:var(--tx-chart-sunburst-label-font-weight);filter:var(--tx-chart-sunburst-label-shadow)}:host([data-styled]) .tx-sunburst-chart__hole{transition:fill var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sunburst-chart__center--hover .tx-sunburst-chart__hole{fill:var(--tx-chart-sunburst-center-hover-background)}:host([data-styled]) .tx-sunburst-chart__back{stroke:var(--tx-chart-sunburst-center-label-color);stroke-width:var(--tx-chart-marker-stroke-width)}:host([data-styled]) .tx-sunburst-chart__center-value{fill:var(--tx-chart-sunburst-center-value-color);font-weight:var(--tx-chart-sunburst-center-value-font-weight);font-variant-numeric:tabular-nums}:host([data-styled]) .tx-sunburst-chart__center-label{fill:var(--tx-chart-sunburst-center-label-color)}:host([data-styled].tx-sunburst-chart--active) .tx-sunburst-chart__segment:not(.tx-sunburst-chart__segment--lit){opacity:var(--tx-chart-sunburst-dimmed-opacity)}:host([data-styled].tx-sunburst-chart--entering) .tx-sunburst-chart__segments{animation:tx-sunburst-chart-grow var(--tx-chart-motion-enter-duration) var(--tx-chart-motion-easing) both}:host([data-styled].tx-sunburst-chart--entering) .tx-sunburst-chart__labels{animation:tx-sunburst-chart-fade var(--tx-chart-motion-enter-duration) ease both}@keyframes tx-sunburst-chart-grow{0%{transform:scale(.82) rotate(-25deg);opacity:0}to{transform:scale(1) rotate(0);opacity:1}}@keyframes tx-sunburst-chart-fade{0%,50%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-sunburst-chart__segment,:host([data-styled]) .tx-sunburst-chart__segments,:host([data-styled]) .tx-sunburst-chart__labels,:host([data-styled]) .tx-sunburst-chart__hole{transition:none;animation:none}}\n"]
|
|
589
|
+
}]
|
|
590
|
+
}],
|
|
591
|
+
ctorParameters: () => [],
|
|
592
|
+
propDecorators: {
|
|
593
|
+
data: [{
|
|
594
|
+
type: i0.Input,
|
|
595
|
+
args: [{
|
|
596
|
+
isSignal: true,
|
|
597
|
+
alias: "data",
|
|
598
|
+
required: false
|
|
599
|
+
}]
|
|
600
|
+
}],
|
|
601
|
+
levels: [{
|
|
602
|
+
type: i0.Input,
|
|
603
|
+
args: [{
|
|
604
|
+
isSignal: true,
|
|
605
|
+
alias: "levels",
|
|
606
|
+
required: false
|
|
607
|
+
}]
|
|
608
|
+
}],
|
|
609
|
+
height: [{
|
|
610
|
+
type: i0.Input,
|
|
611
|
+
args: [{
|
|
612
|
+
isSignal: true,
|
|
613
|
+
alias: "height",
|
|
614
|
+
required: false
|
|
615
|
+
}]
|
|
616
|
+
}],
|
|
617
|
+
showLabels: [{
|
|
618
|
+
type: i0.Input,
|
|
619
|
+
args: [{
|
|
620
|
+
isSignal: true,
|
|
621
|
+
alias: "showLabels",
|
|
622
|
+
required: false
|
|
623
|
+
}]
|
|
624
|
+
}],
|
|
625
|
+
showTooltip: [{
|
|
626
|
+
type: i0.Input,
|
|
627
|
+
args: [{
|
|
628
|
+
isSignal: true,
|
|
629
|
+
alias: "showTooltip",
|
|
630
|
+
required: false
|
|
631
|
+
}]
|
|
632
|
+
}],
|
|
633
|
+
drill: [{
|
|
634
|
+
type: i0.Input,
|
|
635
|
+
args: [{
|
|
636
|
+
isSignal: true,
|
|
637
|
+
alias: "drill",
|
|
638
|
+
required: false
|
|
639
|
+
}]
|
|
640
|
+
}],
|
|
641
|
+
totalLabel: [{
|
|
642
|
+
type: i0.Input,
|
|
643
|
+
args: [{
|
|
644
|
+
isSignal: true,
|
|
645
|
+
alias: "totalLabel",
|
|
646
|
+
required: false
|
|
647
|
+
}]
|
|
648
|
+
}],
|
|
649
|
+
valueFormat: [{
|
|
650
|
+
type: i0.Input,
|
|
651
|
+
args: [{
|
|
652
|
+
isSignal: true,
|
|
653
|
+
alias: "valueFormat",
|
|
654
|
+
required: false
|
|
655
|
+
}]
|
|
656
|
+
}],
|
|
657
|
+
toolbar: [{
|
|
658
|
+
type: i0.Input,
|
|
659
|
+
args: [{
|
|
660
|
+
isSignal: true,
|
|
661
|
+
alias: "toolbar",
|
|
662
|
+
required: false
|
|
663
|
+
}]
|
|
664
|
+
}],
|
|
665
|
+
loading: [{
|
|
666
|
+
type: i0.Input,
|
|
667
|
+
args: [{
|
|
668
|
+
isSignal: true,
|
|
669
|
+
alias: "loading",
|
|
670
|
+
required: false
|
|
671
|
+
}]
|
|
672
|
+
}],
|
|
673
|
+
ariaLabel: [{
|
|
674
|
+
type: i0.Input,
|
|
675
|
+
args: [{
|
|
676
|
+
isSignal: true,
|
|
677
|
+
alias: "ariaLabel",
|
|
678
|
+
required: false
|
|
679
|
+
}]
|
|
680
|
+
}],
|
|
681
|
+
dt: [{
|
|
682
|
+
type: i0.Input,
|
|
683
|
+
args: [{
|
|
684
|
+
isSignal: true,
|
|
685
|
+
alias: "dt",
|
|
686
|
+
required: false
|
|
687
|
+
}]
|
|
688
|
+
}],
|
|
689
|
+
pt: [{
|
|
690
|
+
type: i0.Input,
|
|
691
|
+
args: [{
|
|
692
|
+
isSignal: true,
|
|
693
|
+
alias: "pt",
|
|
694
|
+
required: false
|
|
695
|
+
}]
|
|
696
|
+
}],
|
|
697
|
+
ptOptions: [{
|
|
698
|
+
type: i0.Input,
|
|
699
|
+
args: [{
|
|
700
|
+
isSignal: true,
|
|
701
|
+
alias: "ptOptions",
|
|
702
|
+
required: false
|
|
703
|
+
}]
|
|
704
|
+
}],
|
|
705
|
+
unstyled: [{
|
|
706
|
+
type: i0.Input,
|
|
707
|
+
args: [{
|
|
708
|
+
isSignal: true,
|
|
709
|
+
alias: "unstyled",
|
|
710
|
+
required: false
|
|
711
|
+
}]
|
|
712
|
+
}],
|
|
713
|
+
segmentClick: [{
|
|
714
|
+
type: i0.Output,
|
|
715
|
+
args: ["segmentClick"]
|
|
716
|
+
}],
|
|
717
|
+
focusChange: [{
|
|
718
|
+
type: i0.Output,
|
|
719
|
+
args: ["focusChange"]
|
|
720
|
+
}],
|
|
721
|
+
tooltipTemplate: [{
|
|
722
|
+
type: i0.ContentChild,
|
|
723
|
+
args: [i0.forwardRef(() => TxChartTooltipTemplate), { isSignal: true }]
|
|
724
|
+
}],
|
|
725
|
+
frame: [{
|
|
726
|
+
type: i0.ViewChild,
|
|
727
|
+
args: [i0.forwardRef(() => TxChartFrame), { isSignal: true }]
|
|
728
|
+
}]
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
export { TxSunburstChart, sunburstArcAt, sunburstArcs, sunburstFocus, sunburstValue };
|
|
732
|
+
|
|
733
|
+
//# sourceMappingURL=tectra-ng-charts-sunburst.mjs.map
|