@tectra-ng/charts 0.0.1 → 0.1.9

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.
@@ -0,0 +1,1098 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, Directive, ElementRef, Pipe, TemplateRef, afterNextRender, afterRenderEffect, booleanAttribute, computed, contentChild, inject, input, linkedSignal, output, signal, viewChild } from "@angular/core";
3
+ import { TX_CHART_LEGEND_ROW, TX_CHART_LEGEND_SIDE, TxChartFrame, TxChartLegendTemplate, TxChartTooltipTemplate, chartHeightValue, chartNumberFormatter, chartSummary, injectChartEntrance, numberFormat, parseRatio, readTokenNumber, seriesColor, textWidth, toggleKey } from "@tectra-ng/charts/core";
4
+ import { NgTemplateOutlet } from "@angular/common";
5
+ import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
6
+ import { TxLocaleService, injectTranslations } from "@tectra-ng/core/i18n";
7
+ import { optionalBoolean } from "@tectra-ng/core/utils";
8
+ import { toStyleObject } from "@tectra-ng/themes";
9
+ const FULL = Math.PI * 2;
10
+ const round = (value) => Math.round(value * 100) / 100;
11
+ function toRadians(degrees) {
12
+ return degrees * Math.PI / 180;
13
+ }
14
+ function polar(cx, cy, radius, angle) {
15
+ return {
16
+ x: cx + radius * Math.sin(angle),
17
+ y: cy - radius * Math.cos(angle)
18
+ };
19
+ }
20
+ function pieAngles(values, startAngle = 0, endAngle = 360) {
21
+ const start = toRadians(startAngle);
22
+ const span = toRadians(Math.min(360, Math.max(0, endAngle - startAngle)));
23
+ const total = values.reduce((sum, value) => sum + (value > 0 ? value : 0), 0);
24
+ let cursor = start;
25
+ return values.map((raw, index) => {
26
+ const value = raw > 0 ? raw : 0;
27
+ const sweep = total ? value / total * span : 0;
28
+ const arc = {
29
+ start: cursor,
30
+ end: cursor + sweep,
31
+ value,
32
+ index
33
+ };
34
+ cursor += sweep;
35
+ return arc;
36
+ });
37
+ }
38
+ function maxCornerRadius(inner, outer, sweep) {
39
+ const half = Math.min(Math.PI / 2, sweep / 2);
40
+ const sin = Math.sin(half);
41
+ const byThickness = inner > 0 ? (outer - inner) / 2 : outer / 2;
42
+ const byOuter = outer * sin / (1 + sin);
43
+ const byInner = inner > 0 && sin < 1 ? inner * sin / (1 - sin) : Infinity;
44
+ return Math.max(0, Math.min(byThickness, byOuter, byInner));
45
+ }
46
+ function arcPath(cx, cy, inner, outer, start, end, corner = 0) {
47
+ const sweep = end - start;
48
+ if (sweep <= 0 || outer <= 0) return "";
49
+ if (sweep >= FULL - 1e-6) {
50
+ const middle = start + Math.PI;
51
+ return arcPath(cx, cy, inner, outer, start, middle) + arcPath(cx, cy, inner, outer, middle, start + FULL);
52
+ }
53
+ const radius = Math.min(Math.max(0, corner), maxCornerRadius(inner, outer, sweep));
54
+ if (radius < .5) {
55
+ const large = sweep > Math.PI ? 1 : 0;
56
+ const a = polar(cx, cy, outer, start);
57
+ const b = polar(cx, cy, outer, end);
58
+ const head = `M${round(a.x)},${round(a.y)}A${round(outer)},${round(outer)} 0 ${large} 1 ${round(b.x)},${round(b.y)}`;
59
+ if (inner <= 0) return `${head}L${round(cx)},${round(cy)}Z`;
60
+ const c = polar(cx, cy, inner, end);
61
+ const d = polar(cx, cy, inner, start);
62
+ return `${head}L${round(c.x)},${round(c.y)}A${round(inner)},${round(inner)} 0 ${large} 0 ${round(d.x)},${round(d.y)}Z`;
63
+ }
64
+ const r = round(radius);
65
+ const outerShift = Math.asin(radius / (outer - radius));
66
+ const outerReach = Math.sqrt((outer - radius) ** 2 - radius ** 2);
67
+ const p1 = polar(cx, cy, outerReach, start);
68
+ const p2 = polar(cx, cy, outer, start + outerShift);
69
+ const p3 = polar(cx, cy, outer, end - outerShift);
70
+ const p4 = polar(cx, cy, outerReach, end);
71
+ const outerLarge = end - start - outerShift * 2 > Math.PI ? 1 : 0;
72
+ const head = `M${round(p1.x)},${round(p1.y)}A${r},${r} 0 0 1 ${round(p2.x)},${round(p2.y)}A${round(outer)},${round(outer)} 0 ${outerLarge} 1 ${round(p3.x)},${round(p3.y)}A${r},${r} 0 0 1 ${round(p4.x)},${round(p4.y)}`;
73
+ if (inner <= 0) return `${head}L${round(cx)},${round(cy)}Z`;
74
+ const innerShift = Math.asin(radius / (inner + radius));
75
+ const innerReach = Math.sqrt((inner + radius) ** 2 - radius ** 2);
76
+ const p5 = polar(cx, cy, innerReach, end);
77
+ const p6 = polar(cx, cy, inner, end - innerShift);
78
+ const p7 = polar(cx, cy, inner, start + innerShift);
79
+ const p8 = polar(cx, cy, innerReach, start);
80
+ const innerLarge = end - start - innerShift * 2 > Math.PI ? 1 : 0;
81
+ return `${head}L${round(p5.x)},${round(p5.y)}A${r},${r} 0 0 1 ${round(p6.x)},${round(p6.y)}A${round(inner)},${round(inner)} 0 ${innerLarge} 0 ${round(p7.x)},${round(p7.y)}A${r},${r} 0 0 1 ${round(p8.x)},${round(p8.y)}Z`;
82
+ }
83
+ function arcBounds(start, end) {
84
+ const points = [
85
+ polar(0, 0, 1, start),
86
+ polar(0, 0, 1, end),
87
+ {
88
+ x: 0,
89
+ y: 0
90
+ }
91
+ ];
92
+ for (let quarter = Math.ceil(start / (Math.PI / 2)); quarter * (Math.PI / 2) <= end; quarter++) points.push(polar(0, 0, 1, quarter * (Math.PI / 2)));
93
+ return {
94
+ minX: Math.min(...points.map((point) => point.x)),
95
+ maxX: Math.max(...points.map((point) => point.x)),
96
+ minY: Math.min(...points.map((point) => point.y)),
97
+ maxY: Math.max(...points.map((point) => point.y))
98
+ };
99
+ }
100
+ function fitPie(width, height, startAngle = 0, endAngle = 360, padding = 4) {
101
+ const bounds = arcBounds(toRadians(startAngle), toRadians(Math.max(startAngle, Math.min(startAngle + 360, endAngle))));
102
+ const boxWidth = bounds.maxX - bounds.minX || 1;
103
+ const boxHeight = bounds.maxY - bounds.minY || 1;
104
+ const radius = Math.max(0, Math.min((width - padding * 2) / boxWidth, (height - padding * 2) / boxHeight));
105
+ return {
106
+ cx: width / 2 - (bounds.minX + bounds.maxX) / 2 * radius,
107
+ cy: height / 2 - (bounds.minY + bounds.maxY) / 2 * radius,
108
+ radius
109
+ };
110
+ }
111
+ function pieArcs(values, options) {
112
+ const fit = fitPie(options.width, options.height, options.startAngle ?? 0, options.endAngle ?? 360, options.padding ?? 4);
113
+ const inner = fit.radius * Math.min(.95, Math.max(0, options.donutSize ?? 0));
114
+ const total = values.reduce((sum, value) => sum + (value > 0 ? value : 0), 0);
115
+ return {
116
+ fit,
117
+ inner,
118
+ arcs: pieAngles(values, options.startAngle ?? 0, options.endAngle ?? 360).map((angle) => {
119
+ const middle = (angle.start + angle.end) / 2;
120
+ const labelRadius = inner > 0 ? (inner + fit.radius) / 2 : fit.radius * .62;
121
+ const label = polar(fit.cx, fit.cy, labelRadius, middle);
122
+ return {
123
+ index: angle.index,
124
+ value: angle.value,
125
+ percent: total ? angle.value / total * 100 : 0,
126
+ start: angle.start,
127
+ end: angle.end,
128
+ path: arcPath(fit.cx, fit.cy, inner, fit.radius, angle.start, angle.end, options.cornerRadius ?? 0),
129
+ labelX: round(label.x),
130
+ labelY: round(label.y),
131
+ middle
132
+ };
133
+ })
134
+ };
135
+ }
136
+ function arcAt(arcs, fit, inner, x, y) {
137
+ const dx = x - fit.cx;
138
+ const dy = y - fit.cy;
139
+ const distance = Math.hypot(dx, dy);
140
+ if (distance > fit.radius + 2 || distance < inner - 2) return -1;
141
+ let angle = Math.atan2(dx, -dy);
142
+ const first = arcs.find((arc) => arc.end > arc.start)?.start ?? 0;
143
+ while (angle < first) angle += FULL;
144
+ while (angle >= first + FULL) angle -= FULL;
145
+ return arcs.find((arc) => arc.end > arc.start && angle >= arc.start && angle < arc.end)?.index ?? -1;
146
+ }
147
+ function pieLegend(data) {
148
+ if (!data) return [];
149
+ const total = data.series.reduce((sum, value) => sum + (value > 0 ? value : 0), 0);
150
+ return data.series.map((value, index) => ({
151
+ label: data.labels[index] ?? "",
152
+ value,
153
+ percent: total ? Math.max(0, value) / total * 100 : 0,
154
+ color: seriesColor(data.colors?.[index], index)
155
+ }));
156
+ }
157
+ var TxPieLegendPipe = class TxPieLegendPipe {
158
+ transform(data) {
159
+ return pieLegend(data);
160
+ }
161
+ static ɵfac = i0.ɵɵngDeclareFactory({
162
+ minVersion: "12.0.0",
163
+ version: "22.2.3",
164
+ ngImport: i0,
165
+ type: TxPieLegendPipe,
166
+ deps: [],
167
+ target: i0.ɵɵFactoryTarget.Pipe
168
+ });
169
+ static ɵpipe = i0.ɵɵngDeclarePipe({
170
+ minVersion: "14.0.0",
171
+ version: "22.2.3",
172
+ ngImport: i0,
173
+ type: TxPieLegendPipe,
174
+ isStandalone: true,
175
+ name: "txPieLegend"
176
+ });
177
+ };
178
+ i0.ɵɵngDeclareClassMetadata({
179
+ minVersion: "12.0.0",
180
+ version: "22.2.3",
181
+ ngImport: i0,
182
+ type: TxPieLegendPipe,
183
+ decorators: [{
184
+ type: Pipe,
185
+ args: [{ name: "txPieLegend" }]
186
+ }]
187
+ });
188
+ var TxPieCenter = class TxPieCenter {
189
+ template = inject(TemplateRef);
190
+ static ngTemplateContextGuard(_directive, context) {
191
+ return !!context;
192
+ }
193
+ static ɵfac = i0.ɵɵngDeclareFactory({
194
+ minVersion: "12.0.0",
195
+ version: "22.2.3",
196
+ ngImport: i0,
197
+ type: TxPieCenter,
198
+ deps: [],
199
+ target: i0.ɵɵFactoryTarget.Directive
200
+ });
201
+ static ɵdir = i0.ɵɵngDeclareDirective({
202
+ minVersion: "14.0.0",
203
+ version: "22.2.3",
204
+ type: TxPieCenter,
205
+ isStandalone: true,
206
+ selector: "ng-template[txPieCenter]",
207
+ ngImport: i0
208
+ });
209
+ };
210
+ i0.ɵɵngDeclareClassMetadata({
211
+ minVersion: "12.0.0",
212
+ version: "22.2.3",
213
+ ngImport: i0,
214
+ type: TxPieCenter,
215
+ decorators: [{
216
+ type: Directive,
217
+ args: [{ selector: "ng-template[txPieCenter]" }]
218
+ }]
219
+ });
220
+ const MIN_LABEL_ANGLE = 10 * Math.PI / 180;
221
+ const LEGEND_ITEM_WIDTH = 34;
222
+ const DEFAULT_SEGMENT_RADIUS = 4;
223
+ const STAT_ITEM_WIDTH = 116;
224
+ const STAT_ROW = 66;
225
+ var TxPieChart = class TxPieChart {
226
+ locale = inject(TxLocaleService);
227
+ host = inject(ElementRef);
228
+ translations = injectTranslations();
229
+ pieData = input.required(...ngDevMode ? [{ debugName: "pieData" }] : /* istanbul ignore next */ []);
230
+ chartWidth = input(200, ...ngDevMode ? [{ debugName: "chartWidth" }] : /* istanbul ignore next */ []);
231
+ chartHeight = input(400, ...ngDevMode ? [{ debugName: "chartHeight" }] : /* istanbul ignore next */ []);
232
+ showLegend = input(true, {
233
+ ...ngDevMode ? { debugName: "showLegend" } : /* istanbul ignore next */ {},
234
+ transform: booleanAttribute
235
+ });
236
+ legendPosition = input("bottom", ...ngDevMode ? [{ debugName: "legendPosition" }] : /* istanbul ignore next */ []);
237
+ legendAlign = input("center", ...ngDevMode ? [{ debugName: "legendAlign" }] : /* istanbul ignore next */ []);
238
+ legendValues = input(false, {
239
+ ...ngDevMode ? { debugName: "legendValues" } : /* istanbul ignore next */ {},
240
+ transform: booleanAttribute
241
+ });
242
+ legendVariant = input("dot", ...ngDevMode ? [{ debugName: "legendVariant" }] : /* istanbul ignore next */ []);
243
+ showDataLabels = input(true, {
244
+ ...ngDevMode ? { debugName: "showDataLabels" } : /* istanbul ignore next */ {},
245
+ transform: booleanAttribute
246
+ });
247
+ totalLabel = input("", ...ngDevMode ? [{ debugName: "totalLabel" }] : /* istanbul ignore next */ []);
248
+ totalFormatter = input(null, ...ngDevMode ? [{ debugName: "totalFormatter" }] : /* istanbul ignore next */ []);
249
+ tooltipFormatter = input(null, ...ngDevMode ? [{ debugName: "tooltipFormatter" }] : /* istanbul ignore next */ []);
250
+ showTooltip = input(true, {
251
+ ...ngDevMode ? { debugName: "showTooltip" } : /* istanbul ignore next */ {},
252
+ transform: booleanAttribute
253
+ });
254
+ valueFormat = input("number", ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
255
+ donutSize = input("65%", ...ngDevMode ? [{ debugName: "donutSize" }] : /* istanbul ignore next */ []);
256
+ segmentGap = input(2, ...ngDevMode ? [{ debugName: "segmentGap" }] : /* istanbul ignore next */ []);
257
+ segmentRadius = input(void 0, ...ngDevMode ? [{ debugName: "segmentRadius" }] : /* istanbul ignore next */ []);
258
+ startAngle = input(0, ...ngDevMode ? [{ debugName: "startAngle" }] : /* istanbul ignore next */ []);
259
+ endAngle = input(360, ...ngDevMode ? [{ debugName: "endAngle" }] : /* istanbul ignore next */ []);
260
+ loading = input(false, {
261
+ ...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
262
+ transform: booleanAttribute
263
+ });
264
+ ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
265
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
266
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
267
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
268
+ unstyled = input(void 0, {
269
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
270
+ transform: optionalBoolean
271
+ });
272
+ segmentClick = output();
273
+ segmentToggle = output();
274
+ centerTemplate = contentChild(TxPieCenter, ...ngDevMode ? [{ debugName: "centerTemplate" }] : /* istanbul ignore next */ []);
275
+ legendTemplate = contentChild(TxChartLegendTemplate, ...ngDevMode ? [{ debugName: "legendTemplate" }] : /* istanbul ignore next */ []);
276
+ tooltipTemplate = contentChild(TxChartTooltipTemplate, ...ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []);
277
+ frame = viewChild(TxChartFrame, ...ngDevMode ? [{ debugName: "frame" }] : /* istanbul ignore next */ []);
278
+ isUnstyled = injectUnstyled(this.unstyled);
279
+ passThrough = injectPassThrough("pieChart", this, this.pt, this.ptOptions);
280
+ tokenStyle = computed(() => toStyleObject(this.dt(), "--tx-chart"), ...ngDevMode ? [{ debugName: "tokenStyle" }] : /* istanbul ignore next */ []);
281
+ hostStyle = computed(() => ({
282
+ ...this.tokenStyle(),
283
+ width: this.cssSize(this.chartWidth()),
284
+ height: this.cssSize(this.chartHeight()),
285
+ ...this.passThrough().root?.style
286
+ }), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
287
+ entrance = injectChartEntrance();
288
+ morph = signal(false, ...ngDevMode ? [{ debugName: "morph" }] : /* istanbul ignore next */ []);
289
+ hidden = signal(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []);
290
+ hovered = signal(null, ...ngDevMode ? [{ debugName: "hovered" }] : /* istanbul ignore next */ []);
291
+ tokenRadius = signal(DEFAULT_SEGMENT_RADIUS, ...ngDevMode ? [{ debugName: "tokenRadius" }] : /* istanbul ignore next */ []);
292
+ keyboard = signal(false, ...ngDevMode ? [{ debugName: "keyboard" }] : /* istanbul ignore next */ []);
293
+ fromLegend = signal(false, ...ngDevMode ? [{ debugName: "fromLegend" }] : /* istanbul ignore next */ []);
294
+ intl = computed(() => this.locale.locale().intl, ...ngDevMode ? [{ debugName: "intl" }] : /* istanbul ignore next */ []);
295
+ values = computed(() => this.pieData()?.series ?? [], ...ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []);
296
+ labels = computed(() => this.values().map((_, index) => this.pieData()?.labels[index] ?? ""), ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
297
+ keys = computed(() => this.labels().map((label, index) => `${index}:${label}`), ...ngDevMode ? [{ debugName: "keys" }] : /* istanbul ignore next */ []);
298
+ colors = computed(() => this.values().map((_, index) => seriesColor(this.pieData()?.colors?.[index], index)), ...ngDevMode ? [{ debugName: "colors" }] : /* istanbul ignore next */ []);
299
+ total = computed(() => this.values().reduce((sum, value, index) => sum + (value > 0 && !this.hidden().has(this.keys()[index]) ? value : 0), 0), ...ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []);
300
+ isEmpty = computed(() => !this.values().length || this.values().every((value) => !(value > 0)), ...ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []);
301
+ legendShown = computed(() => this.showLegend() && this.values().length > 0, ...ngDevMode ? [{ debugName: "legendShown" }] : /* istanbul ignore next */ []);
302
+ sideLegend = computed(() => this.legendPosition() === "left" || this.legendPosition() === "right", ...ngDevMode ? [{ debugName: "sideLegend" }] : /* istanbul ignore next */ []);
303
+ size = linkedSignal(() => {
304
+ const width = typeof this.chartWidth() === "number" ? this.chartWidth() : 200;
305
+ return {
306
+ width: this.legendShown() && this.sideLegend() ? Math.max(80, width - TX_CHART_LEGEND_SIDE) : width,
307
+ height: width
308
+ };
309
+ }, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
310
+ plotHeight = computed(() => {
311
+ const width = this.size().width;
312
+ const height = this.chartHeight();
313
+ if (typeof height === "string" && !/px$/.test(height.trim())) return Math.round(width);
314
+ const available = chartHeightValue(height) - (this.legendShown() && !this.sideLegend() ? this.legendReserve() : 0);
315
+ return Math.max(40, Math.round(Math.min(width, available)));
316
+ }, ...ngDevMode ? [{ debugName: "plotHeight" }] : /* istanbul ignore next */ []);
317
+ legendReserve = computed(() => {
318
+ const width = Math.max(1, this.size().width);
319
+ const items = this.legendItems();
320
+ if (this.legendVariant() === "stat") {
321
+ const perRow = Math.max(1, Math.floor(width / STAT_ITEM_WIDTH));
322
+ return Math.ceil(items.length / perRow) * STAT_ROW + 7;
323
+ }
324
+ if (this.legendValues()) return items.length * 22 + 8;
325
+ let rows = 1;
326
+ let line = 0;
327
+ for (const item of items) {
328
+ const next = textWidth(item.label, 12.25) + LEGEND_ITEM_WIDTH + (this.legendVariant() === "pill" ? 12 : 0);
329
+ if (line && line + next > width) {
330
+ rows += 1;
331
+ line = 0;
332
+ }
333
+ line += next;
334
+ }
335
+ return rows * (TX_CHART_LEGEND_ROW - 7) + 7;
336
+ }, ...ngDevMode ? [{ debugName: "legendReserve" }] : /* istanbul ignore next */ []);
337
+ inner = computed(() => Math.min(.95, Math.max(0, parseRatio(this.donutSize(), .65))), ...ngDevMode ? [{ debugName: "inner" }] : /* istanbul ignore next */ []);
338
+ geometry = computed(() => pieArcs(this.values().map((value, index) => this.hidden().has(this.keys()[index]) ? 0 : value), {
339
+ width: this.size().width,
340
+ height: this.plotHeight(),
341
+ startAngle: this.startAngle(),
342
+ endAngle: this.endAngle(),
343
+ donutSize: this.inner(),
344
+ padding: Math.max(8, this.segmentGap() + 2),
345
+ cornerRadius: this.segmentRadius() ?? this.tokenRadius()
346
+ }), ...ngDevMode ? [{ debugName: "geometry" }] : /* istanbul ignore next */ []);
347
+ valueFormatter = computed(() => chartNumberFormatter(this.intl(), this.valueFormat()), ...ngDevMode ? [{ debugName: "valueFormatter" }] : /* istanbul ignore next */ []);
348
+ percentFormatter = computed(() => {
349
+ const format = chartNumberFormatter(this.intl(), "percent");
350
+ return (value) => format(value);
351
+ }, ...ngDevMode ? [{ debugName: "percentFormatter" }] : /* istanbul ignore next */ []);
352
+ dataLabelFormatter = computed(() => {
353
+ const format = numberFormat(this.intl(), {
354
+ style: "percent",
355
+ minimumFractionDigits: 1,
356
+ maximumFractionDigits: 1
357
+ });
358
+ return (percent) => format.format(percent / 100);
359
+ }, ...ngDevMode ? [{ debugName: "dataLabelFormatter" }] : /* istanbul ignore next */ []);
360
+ segments = computed(() => {
361
+ const { arcs } = this.geometry();
362
+ const labelFormat = this.dataLabelFormatter();
363
+ return arcs.filter((arc) => arc.end > arc.start).map((arc) => ({
364
+ ...arc,
365
+ key: this.keys()[arc.index],
366
+ color: this.colors()[arc.index],
367
+ ux: Math.round(Math.sin(arc.middle) * 1e3) / 1e3,
368
+ uy: Math.round(-Math.cos(arc.middle) * 1e3) / 1e3,
369
+ label: this.showDataLabels() && arc.end - arc.start >= MIN_LABEL_ANGLE ? labelFormat(arc.percent) : null
370
+ }));
371
+ }, ...ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []);
372
+ center = computed(() => {
373
+ const index = this.hovered();
374
+ const format = this.totalFormatter() ?? this.valueFormatter();
375
+ if (index !== null && this.values()[index] !== void 0) {
376
+ const raw = this.values()[index];
377
+ return {
378
+ label: this.labels()[index],
379
+ value: format(raw),
380
+ raw,
381
+ total: this.total(),
382
+ hovered: true,
383
+ index,
384
+ color: this.colors()[index]
385
+ };
386
+ }
387
+ if (!this.totalLabel()) return null;
388
+ return {
389
+ label: this.totalLabel(),
390
+ value: format(this.total()),
391
+ raw: this.total(),
392
+ total: this.total(),
393
+ hovered: false,
394
+ index: -1,
395
+ color: null
396
+ };
397
+ }, ...ngDevMode ? [{ debugName: "center" }] : /* istanbul ignore next */ []);
398
+ centerBox = computed(() => {
399
+ const { fit, inner } = this.geometry();
400
+ const side = inner * Math.SQRT2 * .92;
401
+ return {
402
+ x: fit.cx - side / 2,
403
+ y: fit.cy - side / 2,
404
+ size: Math.max(0, side),
405
+ cx: fit.cx,
406
+ cy: fit.cy
407
+ };
408
+ }, ...ngDevMode ? [{ debugName: "centerBox" }] : /* istanbul ignore next */ []);
409
+ centerFont = computed(() => {
410
+ const inner = this.geometry().inner;
411
+ return {
412
+ name: Math.max(10, Math.min(12, inner * .17)),
413
+ value: Math.max(13, Math.min(22, inner * .3))
414
+ };
415
+ }, ...ngDevMode ? [{ debugName: "centerFont" }] : /* istanbul ignore next */ []);
416
+ legendItems = computed(() => {
417
+ const total = this.total();
418
+ const format = this.valueFormatter();
419
+ const percent = this.percentFormatter();
420
+ return this.values().map((value, index) => ({
421
+ key: this.keys()[index],
422
+ label: this.labels()[index],
423
+ color: this.colors()[index],
424
+ hidden: this.hidden().has(this.keys()[index]),
425
+ ...this.legendVariant() === "stat" ? {
426
+ value: format(value),
427
+ caption: percent(total && !this.hidden().has(this.keys()[index]) ? Number((Math.max(0, value) / total * 100).toFixed(1)) : 0)
428
+ } : this.legendValues() ? {
429
+ value: format(value),
430
+ percent: percent(total && !this.hidden().has(this.keys()[index]) ? Number((Math.max(0, value) / total * 100).toFixed(1)) : 0)
431
+ } : {}
432
+ }));
433
+ }, ...ngDevMode ? [{ debugName: "legendItems" }] : /* istanbul ignore next */ []);
434
+ tooltip = computed(() => {
435
+ const index = this.hovered();
436
+ if (index === null || !this.showTooltip() || this.isEmpty() || this.fromLegend() || this.legendVariant() === "stat") return null;
437
+ const raw = this.values()[index];
438
+ const custom = this.tooltipFormatter();
439
+ const value = custom ? custom(raw, {
440
+ seriesIndex: index,
441
+ dataPointIndex: index
442
+ }) : this.valueFormatter()(raw);
443
+ const { arcs, fit } = this.geometry();
444
+ const arc = arcs[index];
445
+ const sin = Math.sin(arc.middle);
446
+ const cos = Math.cos(arc.middle);
447
+ const placement = Math.abs(sin) >= Math.SQRT1_2 ? sin > 0 ? "right" : "left" : cos > 0 ? "top" : "bottom";
448
+ const reach = fit.radius + 4;
449
+ const share = this.percentFormatter()(Number(arc.percent.toFixed(1)));
450
+ return {
451
+ title: "",
452
+ rows: [{
453
+ label: this.labels()[index],
454
+ value,
455
+ share,
456
+ color: this.colors()[index],
457
+ raw,
458
+ seriesIndex: index,
459
+ active: true
460
+ }],
461
+ index,
462
+ x: fit.cx + sin * reach,
463
+ y: fit.cy - cos * reach,
464
+ placement
465
+ };
466
+ }, ...ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []);
467
+ summary = computed(() => {
468
+ const t = this.translations();
469
+ const values = this.values();
470
+ const format = this.valueFormatter();
471
+ const total = values.reduce((sum, value) => sum + (value > 0 ? value : 0), 0);
472
+ const withTotal = `${chartSummary(t, this.intl(), this.inner() > 0 ? t.chartDonut : t.chartPie, 1, values.length, null)}, ${t.chartTotal.toLocaleLowerCase(this.intl())} ${format(total)}`;
473
+ return this.ariaLabel() ? `${this.ariaLabel()}. ${withTotal}` : withTotal;
474
+ }, ...ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []);
475
+ dataTable = computed(() => {
476
+ const t = this.translations();
477
+ const format = this.valueFormatter();
478
+ const percent = this.percentFormatter();
479
+ const total = this.values().reduce((sum, value) => sum + (value > 0 ? value : 0), 0);
480
+ return {
481
+ columns: [{
482
+ key: "value",
483
+ label: t.chartValue
484
+ }, {
485
+ key: "share",
486
+ label: t.chartShare
487
+ }],
488
+ rows: this.values().map((value, index) => ({
489
+ label: this.labels()[index],
490
+ cells: [format(value), percent(total ? Number((Math.max(0, value) / total * 100).toFixed(1)) : 0)]
491
+ }))
492
+ };
493
+ }, ...ngDevMode ? [{ debugName: "dataTable" }] : /* istanbul ignore next */ []);
494
+ constructor() {
495
+ afterNextRender(() => setTimeout(() => this.morph.set(true), 120));
496
+ afterRenderEffect(() => {
497
+ this.dt();
498
+ const next = this.isUnstyled() ? 0 : readTokenNumber(this.host.nativeElement, "--tx-chart-pie-segment-radius", DEFAULT_SEGMENT_RADIUS);
499
+ if (next !== this.tokenRadius()) this.tokenRadius.set(next);
500
+ });
501
+ }
502
+ onPointer(event) {
503
+ if (event.type === "leave") {
504
+ this.hovered.set(null);
505
+ return;
506
+ }
507
+ const { arcs, fit, inner } = this.geometry();
508
+ const index = arcAt(arcs, fit, inner, event.x, event.y);
509
+ this.keyboard.set(false);
510
+ this.fromLegend.set(false);
511
+ this.hovered.set(index >= 0 ? index : null);
512
+ if (event.type === "click" && index >= 0) this.segmentClick.emit({
513
+ index,
514
+ label: this.labels()[index],
515
+ value: this.values()[index],
516
+ percent: arcs[index].percent
517
+ });
518
+ }
519
+ onNavigate(event) {
520
+ if (event.key === "Escape") {
521
+ this.hovered.set(null);
522
+ return;
523
+ }
524
+ const visible = this.segments().map((segment) => segment.index);
525
+ if (!visible.length) return;
526
+ const current = this.hovered();
527
+ const at = current === null ? -1 : visible.indexOf(current);
528
+ const forward = event.key === "ArrowRight" || event.key === "ArrowDown";
529
+ const index = visible[event.key === "Home" ? 0 : event.key === "End" ? visible.length - 1 : at < 0 ? forward ? 0 : visible.length - 1 : (at + (forward ? 1 : -1) + visible.length) % visible.length];
530
+ this.keyboard.set(true);
531
+ this.fromLegend.set(false);
532
+ this.hovered.set(index);
533
+ const arc = this.geometry().arcs[index];
534
+ this.frame()?.announce(`${this.labels()[index]}: ${this.valueFormatter()(this.values()[index])}, ${this.percentFormatter()(Number(arc.percent.toFixed(1)))}`);
535
+ }
536
+ onLegendToggle(key) {
537
+ const index = this.keys().indexOf(key);
538
+ this.hidden.update((keys) => toggleKey(keys, key));
539
+ this.hovered.set(null);
540
+ this.segmentToggle.emit({
541
+ index,
542
+ label: this.labels()[index] ?? "",
543
+ hidden: this.hidden().has(key)
544
+ });
545
+ }
546
+ onLegendHover(key) {
547
+ const index = key === null ? -1 : this.keys().indexOf(key);
548
+ this.fromLegend.set(index >= 0);
549
+ this.hovered.set(index >= 0 && !this.hidden().has(key ?? "") ? index : null);
550
+ }
551
+ cssSize(value) {
552
+ return typeof value === "number" ? `${value}px` : value;
553
+ }
554
+ static ɵfac = i0.ɵɵngDeclareFactory({
555
+ minVersion: "12.0.0",
556
+ version: "22.2.3",
557
+ ngImport: i0,
558
+ type: TxPieChart,
559
+ deps: [],
560
+ target: i0.ɵɵFactoryTarget.Component
561
+ });
562
+ static ɵcmp = i0.ɵɵngDeclareComponent({
563
+ minVersion: "17.0.0",
564
+ version: "22.2.3",
565
+ type: TxPieChart,
566
+ isStandalone: true,
567
+ selector: "tx-pie-chart",
568
+ inputs: {
569
+ pieData: {
570
+ classPropertyName: "pieData",
571
+ publicName: "pieData",
572
+ isSignal: true,
573
+ isRequired: true,
574
+ transformFunction: null
575
+ },
576
+ chartWidth: {
577
+ classPropertyName: "chartWidth",
578
+ publicName: "chartWidth",
579
+ isSignal: true,
580
+ isRequired: false,
581
+ transformFunction: null
582
+ },
583
+ chartHeight: {
584
+ classPropertyName: "chartHeight",
585
+ publicName: "chartHeight",
586
+ isSignal: true,
587
+ isRequired: false,
588
+ transformFunction: null
589
+ },
590
+ showLegend: {
591
+ classPropertyName: "showLegend",
592
+ publicName: "showLegend",
593
+ isSignal: true,
594
+ isRequired: false,
595
+ transformFunction: null
596
+ },
597
+ legendPosition: {
598
+ classPropertyName: "legendPosition",
599
+ publicName: "legendPosition",
600
+ isSignal: true,
601
+ isRequired: false,
602
+ transformFunction: null
603
+ },
604
+ legendAlign: {
605
+ classPropertyName: "legendAlign",
606
+ publicName: "legendAlign",
607
+ isSignal: true,
608
+ isRequired: false,
609
+ transformFunction: null
610
+ },
611
+ legendValues: {
612
+ classPropertyName: "legendValues",
613
+ publicName: "legendValues",
614
+ isSignal: true,
615
+ isRequired: false,
616
+ transformFunction: null
617
+ },
618
+ legendVariant: {
619
+ classPropertyName: "legendVariant",
620
+ publicName: "legendVariant",
621
+ isSignal: true,
622
+ isRequired: false,
623
+ transformFunction: null
624
+ },
625
+ showDataLabels: {
626
+ classPropertyName: "showDataLabels",
627
+ publicName: "showDataLabels",
628
+ isSignal: true,
629
+ isRequired: false,
630
+ transformFunction: null
631
+ },
632
+ totalLabel: {
633
+ classPropertyName: "totalLabel",
634
+ publicName: "totalLabel",
635
+ isSignal: true,
636
+ isRequired: false,
637
+ transformFunction: null
638
+ },
639
+ totalFormatter: {
640
+ classPropertyName: "totalFormatter",
641
+ publicName: "totalFormatter",
642
+ isSignal: true,
643
+ isRequired: false,
644
+ transformFunction: null
645
+ },
646
+ tooltipFormatter: {
647
+ classPropertyName: "tooltipFormatter",
648
+ publicName: "tooltipFormatter",
649
+ isSignal: true,
650
+ isRequired: false,
651
+ transformFunction: null
652
+ },
653
+ showTooltip: {
654
+ classPropertyName: "showTooltip",
655
+ publicName: "showTooltip",
656
+ isSignal: true,
657
+ isRequired: false,
658
+ transformFunction: null
659
+ },
660
+ valueFormat: {
661
+ classPropertyName: "valueFormat",
662
+ publicName: "valueFormat",
663
+ isSignal: true,
664
+ isRequired: false,
665
+ transformFunction: null
666
+ },
667
+ donutSize: {
668
+ classPropertyName: "donutSize",
669
+ publicName: "donutSize",
670
+ isSignal: true,
671
+ isRequired: false,
672
+ transformFunction: null
673
+ },
674
+ segmentGap: {
675
+ classPropertyName: "segmentGap",
676
+ publicName: "segmentGap",
677
+ isSignal: true,
678
+ isRequired: false,
679
+ transformFunction: null
680
+ },
681
+ segmentRadius: {
682
+ classPropertyName: "segmentRadius",
683
+ publicName: "segmentRadius",
684
+ isSignal: true,
685
+ isRequired: false,
686
+ transformFunction: null
687
+ },
688
+ startAngle: {
689
+ classPropertyName: "startAngle",
690
+ publicName: "startAngle",
691
+ isSignal: true,
692
+ isRequired: false,
693
+ transformFunction: null
694
+ },
695
+ endAngle: {
696
+ classPropertyName: "endAngle",
697
+ publicName: "endAngle",
698
+ isSignal: true,
699
+ isRequired: false,
700
+ transformFunction: null
701
+ },
702
+ loading: {
703
+ classPropertyName: "loading",
704
+ publicName: "loading",
705
+ isSignal: true,
706
+ isRequired: false,
707
+ transformFunction: null
708
+ },
709
+ ariaLabel: {
710
+ classPropertyName: "ariaLabel",
711
+ publicName: "ariaLabel",
712
+ isSignal: true,
713
+ isRequired: false,
714
+ transformFunction: null
715
+ },
716
+ dt: {
717
+ classPropertyName: "dt",
718
+ publicName: "dt",
719
+ isSignal: true,
720
+ isRequired: false,
721
+ transformFunction: null
722
+ },
723
+ pt: {
724
+ classPropertyName: "pt",
725
+ publicName: "pt",
726
+ isSignal: true,
727
+ isRequired: false,
728
+ transformFunction: null
729
+ },
730
+ ptOptions: {
731
+ classPropertyName: "ptOptions",
732
+ publicName: "ptOptions",
733
+ isSignal: true,
734
+ isRequired: false,
735
+ transformFunction: null
736
+ },
737
+ unstyled: {
738
+ classPropertyName: "unstyled",
739
+ publicName: "unstyled",
740
+ isSignal: true,
741
+ isRequired: false,
742
+ transformFunction: null
743
+ }
744
+ },
745
+ outputs: {
746
+ segmentClick: "segmentClick",
747
+ segmentToggle: "segmentToggle"
748
+ },
749
+ host: {
750
+ properties: {
751
+ "class": "passThrough().root?.class",
752
+ "style": "hostStyle()",
753
+ "attr.data-styled": "!isUnstyled() || null",
754
+ "class.tx-pie-chart--donut": "inner() > 0",
755
+ "class.tx-pie-chart--entering": "entrance.active()",
756
+ "class.tx-pie-chart--morph": "morph()",
757
+ "class.tx-pie-chart--hovering": "hovered() !== null"
758
+ },
759
+ classAttribute: "tx-pie-chart"
760
+ },
761
+ queries: [
762
+ {
763
+ propertyName: "centerTemplate",
764
+ first: true,
765
+ predicate: TxPieCenter,
766
+ descendants: true,
767
+ isSignal: true
768
+ },
769
+ {
770
+ propertyName: "legendTemplate",
771
+ first: true,
772
+ predicate: TxChartLegendTemplate,
773
+ descendants: true,
774
+ isSignal: true
775
+ },
776
+ {
777
+ propertyName: "tooltipTemplate",
778
+ first: true,
779
+ predicate: TxChartTooltipTemplate,
780
+ descendants: true,
781
+ isSignal: true
782
+ }
783
+ ],
784
+ viewQueries: [{
785
+ propertyName: "frame",
786
+ first: true,
787
+ predicate: TxChartFrame,
788
+ descendants: true,
789
+ isSignal: true
790
+ }],
791
+ ngImport: i0,
792
+ template: "<tx-chart-frame\n height=\"auto\"\n [plotHeight]=\"plotHeight()\"\n [(size)]=\"size\"\n [legendItems]=\"legendItems()\"\n [showLegend]=\"legendShown()\"\n [legendPosition]=\"legendPosition()\"\n [legendAlign]=\"legendAlign()\"\n [legendVariant]=\"legendVariant()\"\n [legendTemplate]=\"legendTemplate()?.template\"\n [empty]=\"isEmpty()\"\n [loading]=\"loading()\"\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 (legendToggled)=\"onLegendToggle($event)\"\n (legendHovered)=\"onLegendHover($event)\"\n (tooltipClosed)=\"hovered.set(null)\"\n>\n <svg:g class=\"tx-pie-chart__segments\" [style.transform-origin]=\"geometry().fit.cx + 'px ' + geometry().fit.cy + 'px'\">\n @for (segment of segments(); track segment.key) {\n <svg:path\n class=\"tx-pie-chart__segment\"\n [class.tx-pie-chart__segment--hovered]=\"hovered() === segment.index\"\n [class]=\"passThrough().segment?.class\"\n [style]=\"passThrough().segment?.style\"\n [attr.data-index]=\"segment.index\"\n [attr.d]=\"segment.path\"\n [style.--tx-pie-chart-color]=\"segment.color\"\n [style.stroke-width]=\"segmentGap()\"\n [style.--tx-pie-chart-ux]=\"segment.ux\"\n [style.--tx-pie-chart-uy]=\"segment.uy\"\n />\n }\n </svg:g>\n @if (showDataLabels()) {\n <svg:g class=\"tx-pie-chart__labels\">\n @for (segment of segments(); track segment.key) {\n @if (segment.label) {\n <svg:text\n class=\"tx-pie-chart__label\"\n [class]=\"passThrough().dataLabel?.class\"\n [style]=\"passThrough().dataLabel?.style\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [attr.x]=\"segment.labelX\"\n [attr.y]=\"segment.labelY\"\n >\n {{ segment.label }}\n </svg:text>\n }\n }\n </svg:g>\n }\n @if (inner() > 0) {\n @if (centerTemplate(); as custom) {\n <svg:foreignObject\n class=\"tx-pie-chart__center\"\n [class]=\"passThrough().center?.class\"\n [style]=\"passThrough().center?.style\"\n [attr.x]=\"centerBox().x\"\n [attr.y]=\"centerBox().y\"\n [attr.width]=\"centerBox().size\"\n [attr.height]=\"centerBox().size\"\n >\n <xhtml:div class=\"tx-pie-chart__center-content\">\n <ng-container [ngTemplateOutlet]=\"custom.template\" [ngTemplateOutletContext]=\"{ $implicit: center() ?? { label: '', value: '', raw: total(), total: total(), hovered: false, index: -1, color: null } }\" />\n </xhtml:div>\n </svg:foreignObject>\n } @else if (center(); as data) {\n <svg:g class=\"tx-pie-chart__center\" [class]=\"passThrough().center?.class\" [style]=\"passThrough().center?.style\">\n <svg:text\n class=\"tx-pie-chart__center-value\"\n text-anchor=\"middle\"\n [attr.x]=\"centerBox().cx\"\n [attr.y]=\"centerBox().cy + centerFont().value * 0.32 - centerFont().name * 0.55\"\n [style.font-size.px]=\"centerFont().value\"\n >\n {{ data.value }}\n </svg:text>\n <svg:text\n class=\"tx-pie-chart__center-name\"\n text-anchor=\"middle\"\n dominant-baseline=\"hanging\"\n [attr.x]=\"centerBox().cx\"\n [attr.y]=\"centerBox().cy + centerFont().value * 0.32 - centerFont().name * 0.55 + 6\"\n [style.font-size.px]=\"centerFont().name\"\n >\n {{ data.label }}\n </svg:text>\n </svg:g>\n }\n }\n</tx-chart-frame>\n",
793
+ styles: [":host{display:block;max-width:100%;min-width:0}.tx-pie-chart__segments{transform-box:view-box}.tx-pie-chart__segment{fill:var(--tx-pie-chart-color)}.tx-pie-chart__label,.tx-pie-chart__center{pointer-events:none}.tx-pie-chart__center-content{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}:host([data-styled]) .tx-pie-chart__segment{stroke:var(--tx-chart-pie-segment-gap);stroke-linejoin:round;transition:fill var(--tx-chart-motion-hover-duration) ease,transform var(--tx-chart-motion-hover-duration) var(--tx-chart-motion-easing)}:host([data-styled]) .tx-pie-chart__segment--hovered{transform:translate(calc(var(--tx-pie-chart-ux, 0) * var(--tx-chart-pie-hover-offset)),calc(var(--tx-pie-chart-uy, 0) * var(--tx-chart-pie-hover-offset)))}:host([data-styled]) .tx-pie-chart__label{fill:var(--tx-chart-pie-label-color);font-size:var(--tx-chart-pie-label-font-size);font-weight:var(--tx-chart-pie-label-font-weight);filter:var(--tx-chart-pie-label-shadow);transition:opacity var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-pie-chart__center-name{fill:var(--tx-chart-pie-name-color);font-weight:var(--tx-chart-pie-name-font-weight)}:host([data-styled]) .tx-pie-chart__center-name--total{fill:var(--tx-chart-pie-total-label-color)}:host([data-styled]) .tx-pie-chart__center-value{fill:var(--tx-chart-pie-value-color);font-weight:var(--tx-chart-pie-value-font-weight);font-variant-numeric:tabular-nums}:host([data-styled]) .tx-pie-chart__center-content{color:var(--tx-chart-pie-value-color)}:host([data-styled].tx-pie-chart--hovering) .tx-pie-chart__segment:not(.tx-pie-chart__segment--hovered){fill:color-mix(in oklab,var(--tx-pie-chart-color) var(--tx-chart-pie-dimmed-strength),var(--tx-chart-pie-dimmed-base))}:host([data-styled].tx-pie-chart--hovering) .tx-pie-chart__label{opacity:0}:host([data-styled].tx-pie-chart--morph) .tx-pie-chart__segment{transition:fill var(--tx-chart-motion-hover-duration) ease,transform var(--tx-chart-motion-hover-duration) var(--tx-chart-motion-easing),d var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing)}:host([data-styled].tx-pie-chart--entering) .tx-pie-chart__segments{animation:tx-pie-chart-enter var(--tx-chart-motion-enter-duration) var(--tx-chart-motion-easing) both}:host([data-styled].tx-pie-chart--entering) .tx-pie-chart__labels,:host([data-styled].tx-pie-chart--entering) .tx-pie-chart__center{animation:tx-pie-chart-fade var(--tx-chart-motion-enter-duration) ease both}@keyframes tx-pie-chart-enter{0%{opacity:0;transform:rotate(-90deg) scale(.6)}to{opacity:1;transform:none}}@keyframes tx-pie-chart-fade{0%,60%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-pie-chart__segment,:host([data-styled]) .tx-pie-chart__segments,:host([data-styled]) .tx-pie-chart__labels,:host([data-styled]) .tx-pie-chart__center{transition:none;animation:none}}\n"],
794
+ dependencies: [{
795
+ kind: "component",
796
+ type: TxChartFrame,
797
+ selector: "tx-chart-frame",
798
+ inputs: [
799
+ "height",
800
+ "size",
801
+ "legendItems",
802
+ "showLegend",
803
+ "legendPosition",
804
+ "legendAlign",
805
+ "legendVariant",
806
+ "legendToggle",
807
+ "legendTemplate",
808
+ "empty",
809
+ "loading",
810
+ "emptyIcon",
811
+ "summary",
812
+ "table",
813
+ "tooltip",
814
+ "tooltipTemplate",
815
+ "tooltipPlacement",
816
+ "panelStyle",
817
+ "parts",
818
+ "styled",
819
+ "interactive",
820
+ "plotHeight"
821
+ ],
822
+ outputs: [
823
+ "sizeChange",
824
+ "pointer",
825
+ "navigate",
826
+ "legendToggled",
827
+ "legendHovered",
828
+ "tooltipClosed"
829
+ ]
830
+ }, {
831
+ kind: "directive",
832
+ type: NgTemplateOutlet,
833
+ selector: "[ngTemplateOutlet]",
834
+ inputs: [
835
+ "ngTemplateOutletContext",
836
+ "ngTemplateOutlet",
837
+ "ngTemplateOutletInjector"
838
+ ]
839
+ }],
840
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
841
+ });
842
+ };
843
+ i0.ɵɵngDeclareClassMetadata({
844
+ minVersion: "12.0.0",
845
+ version: "22.2.3",
846
+ ngImport: i0,
847
+ type: TxPieChart,
848
+ decorators: [{
849
+ type: Component,
850
+ args: [{
851
+ selector: "tx-pie-chart",
852
+ imports: [TxChartFrame, NgTemplateOutlet],
853
+ changeDetection: ChangeDetectionStrategy.OnPush,
854
+ host: {
855
+ class: "tx-pie-chart",
856
+ "[class]": "passThrough().root?.class",
857
+ "[style]": "hostStyle()",
858
+ "[attr.data-styled]": "!isUnstyled() || null",
859
+ "[class.tx-pie-chart--donut]": "inner() > 0",
860
+ "[class.tx-pie-chart--entering]": "entrance.active()",
861
+ "[class.tx-pie-chart--morph]": "morph()",
862
+ "[class.tx-pie-chart--hovering]": "hovered() !== null"
863
+ },
864
+ template: "<tx-chart-frame\n height=\"auto\"\n [plotHeight]=\"plotHeight()\"\n [(size)]=\"size\"\n [legendItems]=\"legendItems()\"\n [showLegend]=\"legendShown()\"\n [legendPosition]=\"legendPosition()\"\n [legendAlign]=\"legendAlign()\"\n [legendVariant]=\"legendVariant()\"\n [legendTemplate]=\"legendTemplate()?.template\"\n [empty]=\"isEmpty()\"\n [loading]=\"loading()\"\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 (legendToggled)=\"onLegendToggle($event)\"\n (legendHovered)=\"onLegendHover($event)\"\n (tooltipClosed)=\"hovered.set(null)\"\n>\n <svg:g class=\"tx-pie-chart__segments\" [style.transform-origin]=\"geometry().fit.cx + 'px ' + geometry().fit.cy + 'px'\">\n @for (segment of segments(); track segment.key) {\n <svg:path\n class=\"tx-pie-chart__segment\"\n [class.tx-pie-chart__segment--hovered]=\"hovered() === segment.index\"\n [class]=\"passThrough().segment?.class\"\n [style]=\"passThrough().segment?.style\"\n [attr.data-index]=\"segment.index\"\n [attr.d]=\"segment.path\"\n [style.--tx-pie-chart-color]=\"segment.color\"\n [style.stroke-width]=\"segmentGap()\"\n [style.--tx-pie-chart-ux]=\"segment.ux\"\n [style.--tx-pie-chart-uy]=\"segment.uy\"\n />\n }\n </svg:g>\n @if (showDataLabels()) {\n <svg:g class=\"tx-pie-chart__labels\">\n @for (segment of segments(); track segment.key) {\n @if (segment.label) {\n <svg:text\n class=\"tx-pie-chart__label\"\n [class]=\"passThrough().dataLabel?.class\"\n [style]=\"passThrough().dataLabel?.style\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [attr.x]=\"segment.labelX\"\n [attr.y]=\"segment.labelY\"\n >\n {{ segment.label }}\n </svg:text>\n }\n }\n </svg:g>\n }\n @if (inner() > 0) {\n @if (centerTemplate(); as custom) {\n <svg:foreignObject\n class=\"tx-pie-chart__center\"\n [class]=\"passThrough().center?.class\"\n [style]=\"passThrough().center?.style\"\n [attr.x]=\"centerBox().x\"\n [attr.y]=\"centerBox().y\"\n [attr.width]=\"centerBox().size\"\n [attr.height]=\"centerBox().size\"\n >\n <xhtml:div class=\"tx-pie-chart__center-content\">\n <ng-container [ngTemplateOutlet]=\"custom.template\" [ngTemplateOutletContext]=\"{ $implicit: center() ?? { label: '', value: '', raw: total(), total: total(), hovered: false, index: -1, color: null } }\" />\n </xhtml:div>\n </svg:foreignObject>\n } @else if (center(); as data) {\n <svg:g class=\"tx-pie-chart__center\" [class]=\"passThrough().center?.class\" [style]=\"passThrough().center?.style\">\n <svg:text\n class=\"tx-pie-chart__center-value\"\n text-anchor=\"middle\"\n [attr.x]=\"centerBox().cx\"\n [attr.y]=\"centerBox().cy + centerFont().value * 0.32 - centerFont().name * 0.55\"\n [style.font-size.px]=\"centerFont().value\"\n >\n {{ data.value }}\n </svg:text>\n <svg:text\n class=\"tx-pie-chart__center-name\"\n text-anchor=\"middle\"\n dominant-baseline=\"hanging\"\n [attr.x]=\"centerBox().cx\"\n [attr.y]=\"centerBox().cy + centerFont().value * 0.32 - centerFont().name * 0.55 + 6\"\n [style.font-size.px]=\"centerFont().name\"\n >\n {{ data.label }}\n </svg:text>\n </svg:g>\n }\n }\n</tx-chart-frame>\n",
865
+ styles: [":host{display:block;max-width:100%;min-width:0}.tx-pie-chart__segments{transform-box:view-box}.tx-pie-chart__segment{fill:var(--tx-pie-chart-color)}.tx-pie-chart__label,.tx-pie-chart__center{pointer-events:none}.tx-pie-chart__center-content{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}:host([data-styled]) .tx-pie-chart__segment{stroke:var(--tx-chart-pie-segment-gap);stroke-linejoin:round;transition:fill var(--tx-chart-motion-hover-duration) ease,transform var(--tx-chart-motion-hover-duration) var(--tx-chart-motion-easing)}:host([data-styled]) .tx-pie-chart__segment--hovered{transform:translate(calc(var(--tx-pie-chart-ux, 0) * var(--tx-chart-pie-hover-offset)),calc(var(--tx-pie-chart-uy, 0) * var(--tx-chart-pie-hover-offset)))}:host([data-styled]) .tx-pie-chart__label{fill:var(--tx-chart-pie-label-color);font-size:var(--tx-chart-pie-label-font-size);font-weight:var(--tx-chart-pie-label-font-weight);filter:var(--tx-chart-pie-label-shadow);transition:opacity var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-pie-chart__center-name{fill:var(--tx-chart-pie-name-color);font-weight:var(--tx-chart-pie-name-font-weight)}:host([data-styled]) .tx-pie-chart__center-name--total{fill:var(--tx-chart-pie-total-label-color)}:host([data-styled]) .tx-pie-chart__center-value{fill:var(--tx-chart-pie-value-color);font-weight:var(--tx-chart-pie-value-font-weight);font-variant-numeric:tabular-nums}:host([data-styled]) .tx-pie-chart__center-content{color:var(--tx-chart-pie-value-color)}:host([data-styled].tx-pie-chart--hovering) .tx-pie-chart__segment:not(.tx-pie-chart__segment--hovered){fill:color-mix(in oklab,var(--tx-pie-chart-color) var(--tx-chart-pie-dimmed-strength),var(--tx-chart-pie-dimmed-base))}:host([data-styled].tx-pie-chart--hovering) .tx-pie-chart__label{opacity:0}:host([data-styled].tx-pie-chart--morph) .tx-pie-chart__segment{transition:fill var(--tx-chart-motion-hover-duration) ease,transform var(--tx-chart-motion-hover-duration) var(--tx-chart-motion-easing),d var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing)}:host([data-styled].tx-pie-chart--entering) .tx-pie-chart__segments{animation:tx-pie-chart-enter var(--tx-chart-motion-enter-duration) var(--tx-chart-motion-easing) both}:host([data-styled].tx-pie-chart--entering) .tx-pie-chart__labels,:host([data-styled].tx-pie-chart--entering) .tx-pie-chart__center{animation:tx-pie-chart-fade var(--tx-chart-motion-enter-duration) ease both}@keyframes tx-pie-chart-enter{0%{opacity:0;transform:rotate(-90deg) scale(.6)}to{opacity:1;transform:none}}@keyframes tx-pie-chart-fade{0%,60%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-pie-chart__segment,:host([data-styled]) .tx-pie-chart__segments,:host([data-styled]) .tx-pie-chart__labels,:host([data-styled]) .tx-pie-chart__center{transition:none;animation:none}}\n"]
866
+ }]
867
+ }],
868
+ ctorParameters: () => [],
869
+ propDecorators: {
870
+ pieData: [{
871
+ type: i0.Input,
872
+ args: [{
873
+ isSignal: true,
874
+ alias: "pieData",
875
+ required: true
876
+ }]
877
+ }],
878
+ chartWidth: [{
879
+ type: i0.Input,
880
+ args: [{
881
+ isSignal: true,
882
+ alias: "chartWidth",
883
+ required: false
884
+ }]
885
+ }],
886
+ chartHeight: [{
887
+ type: i0.Input,
888
+ args: [{
889
+ isSignal: true,
890
+ alias: "chartHeight",
891
+ required: false
892
+ }]
893
+ }],
894
+ showLegend: [{
895
+ type: i0.Input,
896
+ args: [{
897
+ isSignal: true,
898
+ alias: "showLegend",
899
+ required: false
900
+ }]
901
+ }],
902
+ legendPosition: [{
903
+ type: i0.Input,
904
+ args: [{
905
+ isSignal: true,
906
+ alias: "legendPosition",
907
+ required: false
908
+ }]
909
+ }],
910
+ legendAlign: [{
911
+ type: i0.Input,
912
+ args: [{
913
+ isSignal: true,
914
+ alias: "legendAlign",
915
+ required: false
916
+ }]
917
+ }],
918
+ legendValues: [{
919
+ type: i0.Input,
920
+ args: [{
921
+ isSignal: true,
922
+ alias: "legendValues",
923
+ required: false
924
+ }]
925
+ }],
926
+ legendVariant: [{
927
+ type: i0.Input,
928
+ args: [{
929
+ isSignal: true,
930
+ alias: "legendVariant",
931
+ required: false
932
+ }]
933
+ }],
934
+ showDataLabels: [{
935
+ type: i0.Input,
936
+ args: [{
937
+ isSignal: true,
938
+ alias: "showDataLabels",
939
+ required: false
940
+ }]
941
+ }],
942
+ totalLabel: [{
943
+ type: i0.Input,
944
+ args: [{
945
+ isSignal: true,
946
+ alias: "totalLabel",
947
+ required: false
948
+ }]
949
+ }],
950
+ totalFormatter: [{
951
+ type: i0.Input,
952
+ args: [{
953
+ isSignal: true,
954
+ alias: "totalFormatter",
955
+ required: false
956
+ }]
957
+ }],
958
+ tooltipFormatter: [{
959
+ type: i0.Input,
960
+ args: [{
961
+ isSignal: true,
962
+ alias: "tooltipFormatter",
963
+ required: false
964
+ }]
965
+ }],
966
+ showTooltip: [{
967
+ type: i0.Input,
968
+ args: [{
969
+ isSignal: true,
970
+ alias: "showTooltip",
971
+ required: false
972
+ }]
973
+ }],
974
+ valueFormat: [{
975
+ type: i0.Input,
976
+ args: [{
977
+ isSignal: true,
978
+ alias: "valueFormat",
979
+ required: false
980
+ }]
981
+ }],
982
+ donutSize: [{
983
+ type: i0.Input,
984
+ args: [{
985
+ isSignal: true,
986
+ alias: "donutSize",
987
+ required: false
988
+ }]
989
+ }],
990
+ segmentGap: [{
991
+ type: i0.Input,
992
+ args: [{
993
+ isSignal: true,
994
+ alias: "segmentGap",
995
+ required: false
996
+ }]
997
+ }],
998
+ segmentRadius: [{
999
+ type: i0.Input,
1000
+ args: [{
1001
+ isSignal: true,
1002
+ alias: "segmentRadius",
1003
+ required: false
1004
+ }]
1005
+ }],
1006
+ startAngle: [{
1007
+ type: i0.Input,
1008
+ args: [{
1009
+ isSignal: true,
1010
+ alias: "startAngle",
1011
+ required: false
1012
+ }]
1013
+ }],
1014
+ endAngle: [{
1015
+ type: i0.Input,
1016
+ args: [{
1017
+ isSignal: true,
1018
+ alias: "endAngle",
1019
+ required: false
1020
+ }]
1021
+ }],
1022
+ loading: [{
1023
+ type: i0.Input,
1024
+ args: [{
1025
+ isSignal: true,
1026
+ alias: "loading",
1027
+ required: false
1028
+ }]
1029
+ }],
1030
+ ariaLabel: [{
1031
+ type: i0.Input,
1032
+ args: [{
1033
+ isSignal: true,
1034
+ alias: "ariaLabel",
1035
+ required: false
1036
+ }]
1037
+ }],
1038
+ dt: [{
1039
+ type: i0.Input,
1040
+ args: [{
1041
+ isSignal: true,
1042
+ alias: "dt",
1043
+ required: false
1044
+ }]
1045
+ }],
1046
+ pt: [{
1047
+ type: i0.Input,
1048
+ args: [{
1049
+ isSignal: true,
1050
+ alias: "pt",
1051
+ required: false
1052
+ }]
1053
+ }],
1054
+ ptOptions: [{
1055
+ type: i0.Input,
1056
+ args: [{
1057
+ isSignal: true,
1058
+ alias: "ptOptions",
1059
+ required: false
1060
+ }]
1061
+ }],
1062
+ unstyled: [{
1063
+ type: i0.Input,
1064
+ args: [{
1065
+ isSignal: true,
1066
+ alias: "unstyled",
1067
+ required: false
1068
+ }]
1069
+ }],
1070
+ segmentClick: [{
1071
+ type: i0.Output,
1072
+ args: ["segmentClick"]
1073
+ }],
1074
+ segmentToggle: [{
1075
+ type: i0.Output,
1076
+ args: ["segmentToggle"]
1077
+ }],
1078
+ centerTemplate: [{
1079
+ type: i0.ContentChild,
1080
+ args: [i0.forwardRef(() => TxPieCenter), { isSignal: true }]
1081
+ }],
1082
+ legendTemplate: [{
1083
+ type: i0.ContentChild,
1084
+ args: [i0.forwardRef(() => TxChartLegendTemplate), { isSignal: true }]
1085
+ }],
1086
+ tooltipTemplate: [{
1087
+ type: i0.ContentChild,
1088
+ args: [i0.forwardRef(() => TxChartTooltipTemplate), { isSignal: true }]
1089
+ }],
1090
+ frame: [{
1091
+ type: i0.ViewChild,
1092
+ args: [i0.forwardRef(() => TxChartFrame), { isSignal: true }]
1093
+ }]
1094
+ }
1095
+ });
1096
+ export { TxPieCenter, TxPieChart, TxPieLegendPipe, arcAt, arcBounds, arcPath, fitPie, maxCornerRadius, pieAngles, pieArcs, pieLegend, polar, toRadians };
1097
+
1098
+ //# sourceMappingURL=tectra-ng-charts-pie.mjs.map