@tectra-ng/charts 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -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 +4 -2
- package/combo/README.md +83 -0
- package/core/README.md +3 -1
- 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 +149 -66
- package/fesm2022/tectra-ng-charts-column.mjs.map +1 -1
- 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 +1334 -49
- package/fesm2022/tectra-ng-charts-core.mjs.map +1 -1
- 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 +527 -67
- package/fesm2022/tectra-ng-charts-line.mjs.map +1 -1
- 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 +47 -86
- package/fesm2022/tectra-ng-charts-pie.mjs.map +1 -1
- 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/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 +13 -2
- package/org-chart/README.md +57 -0
- package/package.json +114 -6
- package/pie/README.md +1 -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 +486 -3
- package/types/tectra-ng-charts-column.d.ts.map +1 -1
- 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 +266 -5
- package/types/tectra-ng-charts-core.d.ts.map +1 -1
- 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 +556 -2
- package/types/tectra-ng-charts-line.d.ts.map +1 -1
- 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 +477 -14
- package/types/tectra-ng-charts-pie.d.ts.map +1 -1
- 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/waterfall/README.md +60 -0
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
import { TxChartFrame, TxChartTooltipTemplate, chartNumberFormatter, initialChartSize, injectChartEntrance, readTokenNumber, seriesColor, textWidth } from "@tectra-ng/charts/core";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, ElementRef, afterNextRender, 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, formatMessage, injectTranslations } from "@tectra-ng/core/i18n";
|
|
6
|
+
import { optionalBoolean } from "@tectra-ng/core/utils";
|
|
7
|
+
import { toStyleObject } from "@tectra-ng/themes";
|
|
8
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
9
|
+
function sankeyLinkPath(x0, y0, x1, y1) {
|
|
10
|
+
const middle = (x0 + x1) / 2;
|
|
11
|
+
return `M${round(x0)},${round(y0)}C${round(middle)},${round(y0)} ${round(middle)},${round(y1)} ${round(x1)},${round(y1)}`;
|
|
12
|
+
}
|
|
13
|
+
function sankeyRibbonPath(x0, y0, x1, y1, width) {
|
|
14
|
+
const middle = (x0 + x1) / 2;
|
|
15
|
+
const half = width / 2;
|
|
16
|
+
return `M${round(x0)},${round(y0 - half)}C${round(middle)},${round(y0 - half)} ${round(middle)},${round(y1 - half)} ${round(x1)},${round(y1 - half)}L${round(x1)},${round(y1 + half)}C${round(middle)},${round(y1 + half)} ${round(middle)},${round(y0 + half)} ${round(x0)},${round(y0 + half)}Z`;
|
|
17
|
+
}
|
|
18
|
+
function sankeyLinkY(x0, y0, x1, y1, x) {
|
|
19
|
+
if (x <= x0) return y0;
|
|
20
|
+
if (x >= x1) return y1;
|
|
21
|
+
let low = 0;
|
|
22
|
+
let high = 1;
|
|
23
|
+
for (let step = 0; step < 24; step++) {
|
|
24
|
+
const t = (low + high) / 2;
|
|
25
|
+
if ((1 - t) ** 3 * x0 + 3 * (1 - t) ** 2 * t * ((x0 + x1) / 2) + 3 * (1 - t) * t ** 2 * ((x0 + x1) / 2) + t ** 3 * x1 < x) low = t;
|
|
26
|
+
else high = t;
|
|
27
|
+
}
|
|
28
|
+
const t = (low + high) / 2;
|
|
29
|
+
return (1 - t) ** 3 * y0 + 3 * (1 - t) ** 2 * t * y0 + 3 * (1 - t) * t ** 2 * y1 + t ** 3 * y1;
|
|
30
|
+
}
|
|
31
|
+
function sankeyLayout(nodesInput, linksInput, options) {
|
|
32
|
+
const ids = [];
|
|
33
|
+
const add = (id) => {
|
|
34
|
+
if (!ids.includes(id)) ids.push(id);
|
|
35
|
+
};
|
|
36
|
+
nodesInput.forEach((node) => add(node.id));
|
|
37
|
+
const valid = linksInput.filter((link) => link.source !== link.target && Number.isFinite(link.value) && link.value > 0);
|
|
38
|
+
valid.forEach((link) => {
|
|
39
|
+
add(link.source);
|
|
40
|
+
add(link.target);
|
|
41
|
+
});
|
|
42
|
+
const meta = new Map(nodesInput.map((node) => [node.id, node]));
|
|
43
|
+
const outgoing = ids.map(() => []);
|
|
44
|
+
const incoming = ids.map(() => []);
|
|
45
|
+
const linkPairs = valid.map((link) => ({
|
|
46
|
+
link,
|
|
47
|
+
source: ids.indexOf(link.source),
|
|
48
|
+
target: ids.indexOf(link.target)
|
|
49
|
+
}));
|
|
50
|
+
const depth = ids.map(() => 0);
|
|
51
|
+
const order = [];
|
|
52
|
+
const state = ids.map(() => 0);
|
|
53
|
+
const kept = [];
|
|
54
|
+
const visit = (node) => {
|
|
55
|
+
state[node] = 1;
|
|
56
|
+
for (const pair of linkPairs) {
|
|
57
|
+
if (pair.source !== node) continue;
|
|
58
|
+
if (state[pair.target] === 1) continue;
|
|
59
|
+
kept.push(pair);
|
|
60
|
+
if (state[pair.target] === 0) visit(pair.target);
|
|
61
|
+
}
|
|
62
|
+
state[node] = 2;
|
|
63
|
+
order.unshift(node);
|
|
64
|
+
};
|
|
65
|
+
ids.forEach((_, node) => {
|
|
66
|
+
if (state[node] === 0 && !linkPairs.some((pair) => pair.target === node)) visit(node);
|
|
67
|
+
});
|
|
68
|
+
ids.forEach((_, node) => {
|
|
69
|
+
if (state[node] === 0) visit(node);
|
|
70
|
+
});
|
|
71
|
+
const links = linkPairs.filter((pair) => kept.includes(pair));
|
|
72
|
+
links.forEach((pair, index) => {
|
|
73
|
+
outgoing[pair.source].push(index);
|
|
74
|
+
incoming[pair.target].push(index);
|
|
75
|
+
});
|
|
76
|
+
for (const node of order) for (const index of outgoing[node]) {
|
|
77
|
+
const target = links[index].target;
|
|
78
|
+
depth[target] = Math.max(depth[target], depth[node] + 1);
|
|
79
|
+
}
|
|
80
|
+
const columns = Math.max(1, ...depth.map((value) => value + 1));
|
|
81
|
+
if ((options.align ?? "justify") === "justify") ids.forEach((_, node) => {
|
|
82
|
+
if (!outgoing[node].length && incoming[node].length) depth[node] = columns - 1;
|
|
83
|
+
});
|
|
84
|
+
const sum = (list) => list.reduce((total, index) => total + links[index].link.value, 0);
|
|
85
|
+
const values = ids.map((_, node) => Math.max(sum(incoming[node]), sum(outgoing[node])));
|
|
86
|
+
const byColumn = Array.from({ length: columns }, (_, column) => ids.map((_, node) => node).filter((node) => depth[node] === column));
|
|
87
|
+
const padding = options.nodePadding;
|
|
88
|
+
const ky = Math.min(...byColumn.filter((column) => column.length).map((column) => (options.height - (column.length - 1) * padding) / Math.max(1e-9, column.reduce((total, node) => total + values[node], 0))));
|
|
89
|
+
const step = columns > 1 ? (options.width - options.nodeWidth) / (columns - 1) : 0;
|
|
90
|
+
const height = values.map((value) => Math.max(1, value * ky));
|
|
91
|
+
const y = ids.map(() => 0);
|
|
92
|
+
byColumn.forEach((column, at) => {
|
|
93
|
+
if (at) {
|
|
94
|
+
const weight = (node) => {
|
|
95
|
+
const total = incoming[node].reduce((acc, index) => acc + links[index].link.value, 0);
|
|
96
|
+
return total ? incoming[node].reduce((acc, index) => acc + (y[links[index].source] + height[links[index].source] / 2) * links[index].link.value, 0) / total : Infinity;
|
|
97
|
+
};
|
|
98
|
+
const order = new Map(column.map((node) => [node, weight(node)]));
|
|
99
|
+
column.sort((a, b) => (order.get(a) ?? 0) - (order.get(b) ?? 0));
|
|
100
|
+
}
|
|
101
|
+
let cursor = 0;
|
|
102
|
+
column.forEach((node) => {
|
|
103
|
+
y[node] = cursor;
|
|
104
|
+
cursor += height[node] + padding;
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
const center = (node) => y[node] + height[node] / 2;
|
|
108
|
+
const resolve = (column) => {
|
|
109
|
+
column.sort((a, b) => y[a] - y[b]);
|
|
110
|
+
let cursor = 0;
|
|
111
|
+
for (const node of column) {
|
|
112
|
+
y[node] = Math.max(y[node], cursor);
|
|
113
|
+
cursor = y[node] + height[node] + padding;
|
|
114
|
+
}
|
|
115
|
+
let limit = options.height;
|
|
116
|
+
for (let at = column.length - 1; at >= 0; at--) {
|
|
117
|
+
const node = column[at];
|
|
118
|
+
y[node] = Math.min(y[node], limit - height[node]);
|
|
119
|
+
limit = y[node] - padding;
|
|
120
|
+
}
|
|
121
|
+
cursor = 0;
|
|
122
|
+
for (const node of column) {
|
|
123
|
+
y[node] = Math.max(y[node], cursor);
|
|
124
|
+
cursor = y[node] + height[node] + padding;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const iterations = options.iterations ?? 24;
|
|
128
|
+
for (let pass = 0; pass < iterations; pass++) {
|
|
129
|
+
const weight = .99 ** pass;
|
|
130
|
+
const forward = pass % 2 === 0;
|
|
131
|
+
const columnsOrder = forward ? byColumn.slice(1) : byColumn.slice(0, -1).reverse();
|
|
132
|
+
for (const column of columnsOrder) {
|
|
133
|
+
for (const node of column) {
|
|
134
|
+
const related = forward ? incoming[node].map((index) => links[index].source) : outgoing[node].map((index) => links[index].target);
|
|
135
|
+
const linked = forward ? incoming[node] : outgoing[node];
|
|
136
|
+
if (!related.length) continue;
|
|
137
|
+
const total = linked.reduce((acc, index) => acc + links[index].link.value, 0);
|
|
138
|
+
const target = linked.reduce((acc, index, at) => acc + center(related[at]) * links[index].link.value, 0) / Math.max(1e-9, total);
|
|
139
|
+
y[node] += (target - center(node)) * weight;
|
|
140
|
+
}
|
|
141
|
+
resolve(column);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const top = options.top ?? 0;
|
|
145
|
+
const layoutNodes = ids.map((id, node) => ({
|
|
146
|
+
id,
|
|
147
|
+
index: node,
|
|
148
|
+
label: meta.get(id)?.label ?? id,
|
|
149
|
+
color: seriesColor(meta.get(id)?.color, node),
|
|
150
|
+
depth: depth[node],
|
|
151
|
+
value: values[node],
|
|
152
|
+
incoming: sum(incoming[node]),
|
|
153
|
+
outgoing: sum(outgoing[node]),
|
|
154
|
+
x: round(depth[node] * step),
|
|
155
|
+
y: round(y[node] + top),
|
|
156
|
+
width: options.nodeWidth,
|
|
157
|
+
height: round(height[node])
|
|
158
|
+
}));
|
|
159
|
+
const sourceOffset = ids.map(() => 0);
|
|
160
|
+
const targetOffset = ids.map(() => 0);
|
|
161
|
+
const sorted = links.map((_, index) => index);
|
|
162
|
+
const byTarget = [...sorted].sort((a, b) => center(links[a].target) - center(links[b].target));
|
|
163
|
+
const bySource = [...sorted].sort((a, b) => center(links[a].source) - center(links[b].source));
|
|
164
|
+
const y0 = links.map(() => 0);
|
|
165
|
+
const y1 = links.map(() => 0);
|
|
166
|
+
for (const index of byTarget) {
|
|
167
|
+
const pair = links[index];
|
|
168
|
+
const width = pair.link.value * ky;
|
|
169
|
+
y0[index] = y[pair.source] + top + sourceOffset[pair.source] + width / 2;
|
|
170
|
+
sourceOffset[pair.source] += width;
|
|
171
|
+
}
|
|
172
|
+
for (const index of bySource) {
|
|
173
|
+
const pair = links[index];
|
|
174
|
+
const width = pair.link.value * ky;
|
|
175
|
+
y1[index] = y[pair.target] + top + targetOffset[pair.target] + width / 2;
|
|
176
|
+
targetOffset[pair.target] += width;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
nodes: layoutNodes,
|
|
180
|
+
links: links.map((pair, index) => {
|
|
181
|
+
const source = layoutNodes[pair.source];
|
|
182
|
+
const target = layoutNodes[pair.target];
|
|
183
|
+
return {
|
|
184
|
+
index,
|
|
185
|
+
key: `${source.id}>${target.id}`,
|
|
186
|
+
source,
|
|
187
|
+
target,
|
|
188
|
+
value: pair.link.value,
|
|
189
|
+
width: round(Math.max(1, pair.link.value * ky)),
|
|
190
|
+
y0: round(y0[index]),
|
|
191
|
+
y1: round(y1[index]),
|
|
192
|
+
path: sankeyRibbonPath(source.x + source.width, y0[index], target.x, y1[index], Math.max(1, pair.link.value * ky)),
|
|
193
|
+
color: pair.link.color ?? source.color
|
|
194
|
+
};
|
|
195
|
+
}),
|
|
196
|
+
columns
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const DEFAULTS = {
|
|
200
|
+
nodeWidth: 12,
|
|
201
|
+
nodePadding: 14,
|
|
202
|
+
labelGap: 8,
|
|
203
|
+
fontSize: 12
|
|
204
|
+
};
|
|
205
|
+
const PADDING = 4;
|
|
206
|
+
const HIT_SLACK = 3;
|
|
207
|
+
var TxSankeyChart = class TxSankeyChart {
|
|
208
|
+
locale = inject(TxLocaleService);
|
|
209
|
+
host = inject(ElementRef);
|
|
210
|
+
translations = injectTranslations();
|
|
211
|
+
nodes = input([], ...ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []);
|
|
212
|
+
links = input([], ...ngDevMode ? [{ debugName: "links" }] : /* istanbul ignore next */ []);
|
|
213
|
+
height = input(360, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
|
|
214
|
+
align = input("justify", ...ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []);
|
|
215
|
+
showValues = input(true, {
|
|
216
|
+
...ngDevMode ? { debugName: "showValues" } : /* istanbul ignore next */ {},
|
|
217
|
+
transform: booleanAttribute
|
|
218
|
+
});
|
|
219
|
+
showTooltip = input(true, {
|
|
220
|
+
...ngDevMode ? { debugName: "showTooltip" } : /* istanbul ignore next */ {},
|
|
221
|
+
transform: booleanAttribute
|
|
222
|
+
});
|
|
223
|
+
valueFormat = input("number", ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
|
|
224
|
+
toolbar = input(true, {
|
|
225
|
+
...ngDevMode ? { debugName: "toolbar" } : /* istanbul ignore next */ {},
|
|
226
|
+
transform: booleanAttribute
|
|
227
|
+
});
|
|
228
|
+
loading = input(false, {
|
|
229
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
230
|
+
transform: booleanAttribute
|
|
231
|
+
});
|
|
232
|
+
ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
233
|
+
dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
|
|
234
|
+
pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
|
|
235
|
+
ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
|
|
236
|
+
unstyled = input(void 0, {
|
|
237
|
+
...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
|
|
238
|
+
transform: optionalBoolean
|
|
239
|
+
});
|
|
240
|
+
nodeClick = output();
|
|
241
|
+
linkClick = output();
|
|
242
|
+
tooltipTemplate = contentChild(TxChartTooltipTemplate, ...ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []);
|
|
243
|
+
frame = viewChild(TxChartFrame, ...ngDevMode ? [{ debugName: "frame" }] : /* istanbul ignore next */ []);
|
|
244
|
+
isUnstyled = injectUnstyled(this.unstyled);
|
|
245
|
+
passThrough = injectPassThrough("sankeyChart", this, this.pt, this.ptOptions);
|
|
246
|
+
tokenStyle = computed(() => toStyleObject(this.dt(), "--tx-chart"), ...ngDevMode ? [{ debugName: "tokenStyle" }] : /* istanbul ignore next */ []);
|
|
247
|
+
hostStyle = computed(() => ({
|
|
248
|
+
...this.tokenStyle(),
|
|
249
|
+
...this.passThrough().root?.style
|
|
250
|
+
}), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
|
|
251
|
+
entrance = injectChartEntrance();
|
|
252
|
+
morph = signal(false, ...ngDevMode ? [{ debugName: "morph" }] : /* istanbul ignore next */ []);
|
|
253
|
+
active = signal(null, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
|
|
254
|
+
geometry = signal(DEFAULTS, ...ngDevMode ? [{ debugName: "geometry" }] : /* istanbul ignore next */ []);
|
|
255
|
+
intl = computed(() => this.locale.locale().intl, ...ngDevMode ? [{ debugName: "intl" }] : /* istanbul ignore next */ []);
|
|
256
|
+
size = linkedSignal(() => initialChartSize(this.height(), null, void 0, this.toolbar()), ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
257
|
+
valueFormatter = computed(() => chartNumberFormatter(this.intl(), this.valueFormat()), ...ngDevMode ? [{ debugName: "valueFormatter" }] : /* istanbul ignore next */ []);
|
|
258
|
+
percentFormatter = computed(() => chartNumberFormatter(this.intl(), "percent"), ...ngDevMode ? [{ debugName: "percentFormatter" }] : /* istanbul ignore next */ []);
|
|
259
|
+
layout = computed(() => {
|
|
260
|
+
const { width, height } = this.size();
|
|
261
|
+
const { nodeWidth, nodePadding } = this.geometry();
|
|
262
|
+
return sankeyLayout(this.nodes() ?? [], this.links() ?? [], {
|
|
263
|
+
width: Math.max(1, width),
|
|
264
|
+
height: Math.max(1, height - 8),
|
|
265
|
+
nodeWidth,
|
|
266
|
+
nodePadding,
|
|
267
|
+
align: this.align(),
|
|
268
|
+
top: PADDING
|
|
269
|
+
});
|
|
270
|
+
}, ...ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []);
|
|
271
|
+
isEmpty = computed(() => !this.layout().links.length, ...ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []);
|
|
272
|
+
drawnLinks = computed(() => [...this.layout().links].sort((a, b) => b.width - a.width), ...ngDevMode ? [{ debugName: "drawnLinks" }] : /* istanbul ignore next */ []);
|
|
273
|
+
labels = computed(() => {
|
|
274
|
+
const { labelGap, fontSize } = this.geometry();
|
|
275
|
+
const last = this.layout().columns - 1;
|
|
276
|
+
const width = this.size().width;
|
|
277
|
+
return this.layout().nodes.map((node) => {
|
|
278
|
+
const before = node.depth === last && last > 0;
|
|
279
|
+
const value = this.showValues() ? this.valueFormatter()(node.value) : "";
|
|
280
|
+
const room = before ? node.x - labelGap : width - node.x - node.width - labelGap;
|
|
281
|
+
const fits = textWidth(`${node.label} ${value}`, fontSize) <= room;
|
|
282
|
+
return {
|
|
283
|
+
key: node.id,
|
|
284
|
+
x: before ? node.x - labelGap : node.x + node.width + labelGap,
|
|
285
|
+
y: node.y + node.height / 2,
|
|
286
|
+
anchor: before ? "end" : "start",
|
|
287
|
+
label: node.label,
|
|
288
|
+
value: fits ? value : ""
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
}, ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
|
|
292
|
+
related = computed(() => {
|
|
293
|
+
const active = this.active();
|
|
294
|
+
const layout = this.layout();
|
|
295
|
+
if (!active) return null;
|
|
296
|
+
if (active.kind === "link") {
|
|
297
|
+
const link = layout.links[active.index];
|
|
298
|
+
return {
|
|
299
|
+
links: /* @__PURE__ */ new Set([link.index]),
|
|
300
|
+
nodes: /* @__PURE__ */ new Set([link.source.index, link.target.index])
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const links = layout.links.filter((link) => link.source.index === active.index || link.target.index === active.index);
|
|
304
|
+
return {
|
|
305
|
+
links: new Set(links.map((link) => link.index)),
|
|
306
|
+
nodes: /* @__PURE__ */ new Set([active.index, ...links.flatMap((link) => [link.source.index, link.target.index])])
|
|
307
|
+
};
|
|
308
|
+
}, ...ngDevMode ? [{ debugName: "related" }] : /* istanbul ignore next */ []);
|
|
309
|
+
tooltip = computed(() => {
|
|
310
|
+
const active = this.active();
|
|
311
|
+
if (!active || !this.showTooltip()) return null;
|
|
312
|
+
const t = this.translations();
|
|
313
|
+
const format = this.valueFormatter();
|
|
314
|
+
if (active.kind === "node") {
|
|
315
|
+
const node = this.layout().nodes[active.index];
|
|
316
|
+
if (!node) return null;
|
|
317
|
+
const rows = [...node.incoming ? [{
|
|
318
|
+
label: t.chartIncoming,
|
|
319
|
+
value: format(node.incoming),
|
|
320
|
+
color: node.color,
|
|
321
|
+
raw: node.incoming,
|
|
322
|
+
seriesIndex: 0
|
|
323
|
+
}] : [], ...node.outgoing ? [{
|
|
324
|
+
label: t.chartOutgoing,
|
|
325
|
+
value: format(node.outgoing),
|
|
326
|
+
color: node.incoming ? "transparent" : node.color,
|
|
327
|
+
raw: node.outgoing,
|
|
328
|
+
seriesIndex: 1
|
|
329
|
+
}] : []];
|
|
330
|
+
return {
|
|
331
|
+
title: node.label,
|
|
332
|
+
rows,
|
|
333
|
+
index: active.index,
|
|
334
|
+
x: node.x + node.width / 2,
|
|
335
|
+
y: node.y,
|
|
336
|
+
placement: "top"
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const link = this.layout().links[active.index];
|
|
340
|
+
if (!link) return null;
|
|
341
|
+
const share = link.source.outgoing ? link.value / link.source.outgoing * 100 : 0;
|
|
342
|
+
const x = (link.source.x + link.source.width + link.target.x) / 2;
|
|
343
|
+
return {
|
|
344
|
+
title: formatMessage(t.chartFlow, {
|
|
345
|
+
source: link.source.label,
|
|
346
|
+
target: link.target.label
|
|
347
|
+
}),
|
|
348
|
+
rows: [{
|
|
349
|
+
label: t.chartValue,
|
|
350
|
+
value: format(link.value),
|
|
351
|
+
share: this.percentFormatter()(Number(share.toFixed(1))),
|
|
352
|
+
color: link.color,
|
|
353
|
+
raw: link.value,
|
|
354
|
+
seriesIndex: 0
|
|
355
|
+
}],
|
|
356
|
+
index: active.index,
|
|
357
|
+
x,
|
|
358
|
+
y: sankeyLinkY(link.source.x + link.source.width, link.y0, link.target.x, link.y1, x) - link.width / 2,
|
|
359
|
+
placement: "top"
|
|
360
|
+
};
|
|
361
|
+
}, ...ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []);
|
|
362
|
+
order = computed(() => [...this.layout().nodes].sort((a, b) => a.depth - b.depth || a.y - b.y).map((node) => node.index), ...ngDevMode ? [{ debugName: "order" }] : /* istanbul ignore next */ []);
|
|
363
|
+
summary = computed(() => {
|
|
364
|
+
const t = this.translations();
|
|
365
|
+
const text = `${t.chartSankey}, ${formatMessage(t.chartFlows, { count: this.layout().links.length }, this.intl())}`;
|
|
366
|
+
return this.ariaLabel() ? `${this.ariaLabel()}. ${text}` : text;
|
|
367
|
+
}, ...ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []);
|
|
368
|
+
dataTable = computed(() => {
|
|
369
|
+
const t = this.translations();
|
|
370
|
+
return {
|
|
371
|
+
columns: [{
|
|
372
|
+
key: "value",
|
|
373
|
+
label: t.chartValue
|
|
374
|
+
}],
|
|
375
|
+
rows: this.layout().links.map((link) => ({
|
|
376
|
+
label: formatMessage(t.chartFlow, {
|
|
377
|
+
source: link.source.label,
|
|
378
|
+
target: link.target.label
|
|
379
|
+
}),
|
|
380
|
+
cells: [this.valueFormatter()(link.value)]
|
|
381
|
+
}))
|
|
382
|
+
};
|
|
383
|
+
}, ...ngDevMode ? [{ debugName: "dataTable" }] : /* istanbul ignore next */ []);
|
|
384
|
+
constructor() {
|
|
385
|
+
afterNextRender(() => setTimeout(() => this.morph.set(true), 120));
|
|
386
|
+
afterRenderEffect(() => {
|
|
387
|
+
this.dt();
|
|
388
|
+
this.readGeometry();
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
isNodeDimmed(node) {
|
|
392
|
+
const related = this.related();
|
|
393
|
+
return !!related && !related.nodes.has(node.index);
|
|
394
|
+
}
|
|
395
|
+
isLinkLit(link) {
|
|
396
|
+
return !!this.related()?.links.has(link.index);
|
|
397
|
+
}
|
|
398
|
+
onPointer(event) {
|
|
399
|
+
if (event.type === "leave") {
|
|
400
|
+
this.active.set(null);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const hit = this.hitTest(event.x, event.y);
|
|
404
|
+
this.active.set(hit);
|
|
405
|
+
if (event.type !== "click" || !hit) return;
|
|
406
|
+
if (hit.kind === "node") {
|
|
407
|
+
const node = this.layout().nodes[hit.index];
|
|
408
|
+
this.nodeClick.emit({
|
|
409
|
+
id: node.id,
|
|
410
|
+
label: node.label,
|
|
411
|
+
incoming: node.incoming,
|
|
412
|
+
outgoing: node.outgoing
|
|
413
|
+
});
|
|
414
|
+
} else {
|
|
415
|
+
const link = this.layout().links[hit.index];
|
|
416
|
+
this.linkClick.emit({
|
|
417
|
+
source: link.source.id,
|
|
418
|
+
target: link.target.id,
|
|
419
|
+
value: link.value
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
onNavigate(event) {
|
|
424
|
+
if (event.key === "Escape") {
|
|
425
|
+
this.active.set(null);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const order = this.order();
|
|
429
|
+
if (!order.length) return;
|
|
430
|
+
const current = this.active();
|
|
431
|
+
const at = current?.kind === "node" ? order.indexOf(current.index) : -1;
|
|
432
|
+
const forward = event.key === "ArrowRight" || event.key === "ArrowDown";
|
|
433
|
+
if (![
|
|
434
|
+
"ArrowRight",
|
|
435
|
+
"ArrowDown",
|
|
436
|
+
"ArrowLeft",
|
|
437
|
+
"ArrowUp",
|
|
438
|
+
"Home",
|
|
439
|
+
"End"
|
|
440
|
+
].includes(event.key)) return;
|
|
441
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? order.length - 1 : at < 0 ? forward ? 0 : order.length - 1 : Math.max(0, Math.min(order.length - 1, at + (forward ? 1 : -1)));
|
|
442
|
+
const node = this.layout().nodes[order[next]];
|
|
443
|
+
this.active.set({
|
|
444
|
+
kind: "node",
|
|
445
|
+
index: node.index
|
|
446
|
+
});
|
|
447
|
+
const t = this.translations();
|
|
448
|
+
const format = this.valueFormatter();
|
|
449
|
+
const parts = [node.incoming ? `${t.chartIncoming} ${format(node.incoming)}` : "", node.outgoing ? `${t.chartOutgoing} ${format(node.outgoing)}` : ""].filter(Boolean);
|
|
450
|
+
this.frame()?.announce(`${node.label}: ${parts.join(", ")}`);
|
|
451
|
+
}
|
|
452
|
+
hitTest(x, y) {
|
|
453
|
+
const layout = this.layout();
|
|
454
|
+
const node = layout.nodes.find((item) => x >= item.x - HIT_SLACK && x <= item.x + item.width + HIT_SLACK && y >= item.y - HIT_SLACK && y <= item.y + item.height + HIT_SLACK);
|
|
455
|
+
if (node) return {
|
|
456
|
+
kind: "node",
|
|
457
|
+
index: node.index
|
|
458
|
+
};
|
|
459
|
+
let best = null;
|
|
460
|
+
for (const link of layout.links) {
|
|
461
|
+
const x0 = link.source.x + link.source.width;
|
|
462
|
+
const x1 = link.target.x;
|
|
463
|
+
if (x < x0 || x > x1) continue;
|
|
464
|
+
const centre = sankeyLinkY(x0, link.y0, x1, link.y1, x);
|
|
465
|
+
if (Math.abs(y - centre) <= link.width / 2 + 1 && (!best || link.width < best.width)) best = link;
|
|
466
|
+
}
|
|
467
|
+
return best ? {
|
|
468
|
+
kind: "link",
|
|
469
|
+
index: best.index
|
|
470
|
+
} : null;
|
|
471
|
+
}
|
|
472
|
+
readGeometry() {
|
|
473
|
+
const element = this.host.nativeElement;
|
|
474
|
+
const next = {
|
|
475
|
+
nodeWidth: readTokenNumber(element, "--tx-chart-sankey-node-width", DEFAULTS.nodeWidth),
|
|
476
|
+
nodePadding: readTokenNumber(element, "--tx-chart-sankey-node-padding", DEFAULTS.nodePadding),
|
|
477
|
+
labelGap: readTokenNumber(element, "--tx-chart-sankey-label-gap", DEFAULTS.labelGap),
|
|
478
|
+
fontSize: readTokenNumber(element, "--tx-chart-sankey-label-font-size", DEFAULTS.fontSize)
|
|
479
|
+
};
|
|
480
|
+
const current = this.geometry();
|
|
481
|
+
if (Object.keys(next).some((key) => next[key] !== current[key])) this.geometry.set(next);
|
|
482
|
+
}
|
|
483
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
484
|
+
minVersion: "12.0.0",
|
|
485
|
+
version: "22.2.3",
|
|
486
|
+
ngImport: i0,
|
|
487
|
+
type: TxSankeyChart,
|
|
488
|
+
deps: [],
|
|
489
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
490
|
+
});
|
|
491
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
492
|
+
minVersion: "17.0.0",
|
|
493
|
+
version: "22.2.3",
|
|
494
|
+
type: TxSankeyChart,
|
|
495
|
+
isStandalone: true,
|
|
496
|
+
selector: "tx-sankey-chart",
|
|
497
|
+
inputs: {
|
|
498
|
+
nodes: {
|
|
499
|
+
classPropertyName: "nodes",
|
|
500
|
+
publicName: "nodes",
|
|
501
|
+
isSignal: true,
|
|
502
|
+
isRequired: false,
|
|
503
|
+
transformFunction: null
|
|
504
|
+
},
|
|
505
|
+
links: {
|
|
506
|
+
classPropertyName: "links",
|
|
507
|
+
publicName: "links",
|
|
508
|
+
isSignal: true,
|
|
509
|
+
isRequired: false,
|
|
510
|
+
transformFunction: null
|
|
511
|
+
},
|
|
512
|
+
height: {
|
|
513
|
+
classPropertyName: "height",
|
|
514
|
+
publicName: "height",
|
|
515
|
+
isSignal: true,
|
|
516
|
+
isRequired: false,
|
|
517
|
+
transformFunction: null
|
|
518
|
+
},
|
|
519
|
+
align: {
|
|
520
|
+
classPropertyName: "align",
|
|
521
|
+
publicName: "align",
|
|
522
|
+
isSignal: true,
|
|
523
|
+
isRequired: false,
|
|
524
|
+
transformFunction: null
|
|
525
|
+
},
|
|
526
|
+
showValues: {
|
|
527
|
+
classPropertyName: "showValues",
|
|
528
|
+
publicName: "showValues",
|
|
529
|
+
isSignal: true,
|
|
530
|
+
isRequired: false,
|
|
531
|
+
transformFunction: null
|
|
532
|
+
},
|
|
533
|
+
showTooltip: {
|
|
534
|
+
classPropertyName: "showTooltip",
|
|
535
|
+
publicName: "showTooltip",
|
|
536
|
+
isSignal: true,
|
|
537
|
+
isRequired: false,
|
|
538
|
+
transformFunction: null
|
|
539
|
+
},
|
|
540
|
+
valueFormat: {
|
|
541
|
+
classPropertyName: "valueFormat",
|
|
542
|
+
publicName: "valueFormat",
|
|
543
|
+
isSignal: true,
|
|
544
|
+
isRequired: false,
|
|
545
|
+
transformFunction: null
|
|
546
|
+
},
|
|
547
|
+
toolbar: {
|
|
548
|
+
classPropertyName: "toolbar",
|
|
549
|
+
publicName: "toolbar",
|
|
550
|
+
isSignal: true,
|
|
551
|
+
isRequired: false,
|
|
552
|
+
transformFunction: null
|
|
553
|
+
},
|
|
554
|
+
loading: {
|
|
555
|
+
classPropertyName: "loading",
|
|
556
|
+
publicName: "loading",
|
|
557
|
+
isSignal: true,
|
|
558
|
+
isRequired: false,
|
|
559
|
+
transformFunction: null
|
|
560
|
+
},
|
|
561
|
+
ariaLabel: {
|
|
562
|
+
classPropertyName: "ariaLabel",
|
|
563
|
+
publicName: "ariaLabel",
|
|
564
|
+
isSignal: true,
|
|
565
|
+
isRequired: false,
|
|
566
|
+
transformFunction: null
|
|
567
|
+
},
|
|
568
|
+
dt: {
|
|
569
|
+
classPropertyName: "dt",
|
|
570
|
+
publicName: "dt",
|
|
571
|
+
isSignal: true,
|
|
572
|
+
isRequired: false,
|
|
573
|
+
transformFunction: null
|
|
574
|
+
},
|
|
575
|
+
pt: {
|
|
576
|
+
classPropertyName: "pt",
|
|
577
|
+
publicName: "pt",
|
|
578
|
+
isSignal: true,
|
|
579
|
+
isRequired: false,
|
|
580
|
+
transformFunction: null
|
|
581
|
+
},
|
|
582
|
+
ptOptions: {
|
|
583
|
+
classPropertyName: "ptOptions",
|
|
584
|
+
publicName: "ptOptions",
|
|
585
|
+
isSignal: true,
|
|
586
|
+
isRequired: false,
|
|
587
|
+
transformFunction: null
|
|
588
|
+
},
|
|
589
|
+
unstyled: {
|
|
590
|
+
classPropertyName: "unstyled",
|
|
591
|
+
publicName: "unstyled",
|
|
592
|
+
isSignal: true,
|
|
593
|
+
isRequired: false,
|
|
594
|
+
transformFunction: null
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
outputs: {
|
|
598
|
+
nodeClick: "nodeClick",
|
|
599
|
+
linkClick: "linkClick"
|
|
600
|
+
},
|
|
601
|
+
host: {
|
|
602
|
+
properties: {
|
|
603
|
+
"class": "passThrough().root?.class",
|
|
604
|
+
"style": "hostStyle()",
|
|
605
|
+
"attr.data-styled": "!isUnstyled() || null",
|
|
606
|
+
"class.tx-sankey-chart--fill": "typeof height() === \"string\"",
|
|
607
|
+
"class.tx-sankey-chart--entering": "entrance.active()",
|
|
608
|
+
"class.tx-sankey-chart--morph": "morph()",
|
|
609
|
+
"class.tx-sankey-chart--active": "active() !== null"
|
|
610
|
+
},
|
|
611
|
+
classAttribute: "tx-sankey-chart"
|
|
612
|
+
},
|
|
613
|
+
queries: [{
|
|
614
|
+
propertyName: "tooltipTemplate",
|
|
615
|
+
first: true,
|
|
616
|
+
predicate: TxChartTooltipTemplate,
|
|
617
|
+
descendants: true,
|
|
618
|
+
isSignal: true
|
|
619
|
+
}],
|
|
620
|
+
viewQueries: [{
|
|
621
|
+
propertyName: "frame",
|
|
622
|
+
first: true,
|
|
623
|
+
predicate: TxChartFrame,
|
|
624
|
+
descendants: true,
|
|
625
|
+
isSignal: true
|
|
626
|
+
}],
|
|
627
|
+
ngImport: i0,
|
|
628
|
+
template: "<tx-chart-frame\n [height]=\"height()\"\n [(size)]=\"size\"\n [showLegend]=\"false\"\n [empty]=\"isEmpty()\"\n [loading]=\"loading()\"\n [toolbar]=\"toolbar()\"\n [exportName]=\"ariaLabel()\"\n emptyIcon=\"chart-bar\"\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-sankey-chart__links\">\n @for (link of drawnLinks(); track link.key) {\n <svg:path\n class=\"tx-sankey-chart__link\"\n [class.tx-sankey-chart__link--lit]=\"isLinkLit(link)\"\n [class]=\"passThrough().link?.class\"\n [style]=\"passThrough().link?.style\"\n [attr.data-link]=\"link.key\"\n [attr.d]=\"link.path\"\n [style.--tx-sankey-chart-color]=\"link.color\"\n />\n }\n </svg:g>\n <svg:g class=\"tx-sankey-chart__nodes\">\n @for (node of layout().nodes; track node.id) {\n <svg:rect\n class=\"tx-sankey-chart__node\"\n [class.tx-sankey-chart__node--dimmed]=\"isNodeDimmed(node)\"\n [class]=\"passThrough().node?.class\"\n [style]=\"passThrough().node?.style\"\n [attr.data-node]=\"node.id\"\n [attr.x]=\"node.x\"\n [attr.y]=\"node.y\"\n [attr.width]=\"node.width\"\n [attr.height]=\"node.height\"\n [style.fill]=\"node.color\"\n [style.--tx-sankey-chart-order]=\"node.depth\"\n />\n }\n </svg:g>\n <svg:g class=\"tx-sankey-chart__labels\">\n @for (label of labels(); track label.key) {\n <svg:text\n class=\"tx-sankey-chart__label\"\n [class]=\"passThrough().label?.class\"\n [style]=\"passThrough().label?.style\"\n dominant-baseline=\"central\"\n [attr.x]=\"label.x\"\n [attr.y]=\"label.y\"\n [attr.text-anchor]=\"label.anchor\"\n >\n {{ label.label }}\n @if (label.value) {\n <svg:tspan class=\"tx-sankey-chart__value\" dx=\"5\">{{ label.value }}</svg:tspan>\n }\n </svg:text>\n }\n </svg:g>\n</tx-chart-frame>\n",
|
|
629
|
+
styles: [":host{display:block;min-width:0}:host(.tx-sankey-chart--fill){height:100%}.tx-sankey-chart__link{fill:var(--tx-sankey-chart-color);fill-opacity:.35}.tx-sankey-chart__links,.tx-sankey-chart__labels,.tx-sankey-chart__nodes{pointer-events:none}:host([data-styled]) .tx-sankey-chart__link{fill:color-mix(in srgb,var(--tx-sankey-chart-color) var(--tx-chart-sankey-link-strength),var(--tx-chart-sankey-link-base));fill-opacity:1;stroke:var(--tx-chart-sankey-link-edge-color);stroke-width:var(--tx-chart-sankey-link-edge-width);stroke-linejoin:round;transition:fill var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sankey-chart__node{rx:var(--tx-chart-sankey-node-radius);transition:opacity var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sankey-chart__label{fill:var(--tx-chart-sankey-label-color);font-size:var(--tx-chart-sankey-label-font-size);font-weight:var(--tx-chart-sankey-label-font-weight)}:host([data-styled]) .tx-sankey-chart__value{fill:var(--tx-chart-sankey-value-color);font-weight:var(--tx-font-weight-regular);font-variant-numeric:tabular-nums}:host([data-styled].tx-sankey-chart--active) .tx-sankey-chart__link{fill:color-mix(in srgb,var(--tx-sankey-chart-color) var(--tx-chart-sankey-link-dimmed-strength),var(--tx-chart-sankey-link-base))}:host([data-styled].tx-sankey-chart--active) .tx-sankey-chart__link--lit{fill:color-mix(in srgb,var(--tx-sankey-chart-color) var(--tx-chart-sankey-link-active-strength),var(--tx-chart-sankey-link-base))}:host([data-styled].tx-sankey-chart--active) .tx-sankey-chart__node--dimmed{opacity:var(--tx-chart-sankey-node-dimmed-opacity)}:host([data-styled].tx-sankey-chart--morph) .tx-sankey-chart__link{transition:fill var(--tx-chart-motion-hover-duration) ease,d var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing)}:host([data-styled].tx-sankey-chart--morph) .tx-sankey-chart__node{transition:opacity var(--tx-chart-motion-hover-duration) ease,y var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing),height var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing)}:host([data-styled].tx-sankey-chart--entering) .tx-sankey-chart__node{animation:tx-sankey-chart-fade var(--tx-chart-motion-enter-duration) ease both;animation-delay:calc(var(--tx-sankey-chart-order, 0) * var(--tx-chart-motion-stagger) * 3)}:host([data-styled].tx-sankey-chart--entering) .tx-sankey-chart__links{animation:tx-sankey-chart-reveal var(--tx-chart-motion-enter-duration) var(--tx-chart-motion-easing) both}:host([data-styled].tx-sankey-chart--entering) .tx-sankey-chart__labels{animation:tx-sankey-chart-fade var(--tx-chart-motion-enter-duration) ease both}@keyframes tx-sankey-chart-reveal{0%{clip-path:inset(0 100% 0 0)}to{clip-path:inset(0 0 0 0)}}@keyframes tx-sankey-chart-fade{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-sankey-chart__link,:host([data-styled]) .tx-sankey-chart__node,:host([data-styled]) .tx-sankey-chart__links,:host([data-styled]) .tx-sankey-chart__labels{transition:none;animation:none}}\n"],
|
|
630
|
+
dependencies: [{
|
|
631
|
+
kind: "component",
|
|
632
|
+
type: TxChartFrame,
|
|
633
|
+
selector: "tx-chart-frame",
|
|
634
|
+
inputs: [
|
|
635
|
+
"height",
|
|
636
|
+
"size",
|
|
637
|
+
"legendItems",
|
|
638
|
+
"showLegend",
|
|
639
|
+
"legendPosition",
|
|
640
|
+
"legendAlign",
|
|
641
|
+
"legendVariant",
|
|
642
|
+
"legendToggle",
|
|
643
|
+
"legendTemplate",
|
|
644
|
+
"empty",
|
|
645
|
+
"loading",
|
|
646
|
+
"emptyIcon",
|
|
647
|
+
"summary",
|
|
648
|
+
"table",
|
|
649
|
+
"tooltip",
|
|
650
|
+
"tooltipTemplate",
|
|
651
|
+
"tooltipPlacement",
|
|
652
|
+
"panelStyle",
|
|
653
|
+
"parts",
|
|
654
|
+
"styled",
|
|
655
|
+
"interactive",
|
|
656
|
+
"actionKeys",
|
|
657
|
+
"zoomable",
|
|
658
|
+
"zoomedIn",
|
|
659
|
+
"plotHeight",
|
|
660
|
+
"toolbar",
|
|
661
|
+
"exportName"
|
|
662
|
+
],
|
|
663
|
+
outputs: [
|
|
664
|
+
"sizeChange",
|
|
665
|
+
"pointer",
|
|
666
|
+
"navigate",
|
|
667
|
+
"legendToggled",
|
|
668
|
+
"legendHovered",
|
|
669
|
+
"tooltipClosed",
|
|
670
|
+
"zoomed",
|
|
671
|
+
"panned",
|
|
672
|
+
"zoomReset"
|
|
673
|
+
]
|
|
674
|
+
}],
|
|
675
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
676
|
+
});
|
|
677
|
+
};
|
|
678
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
679
|
+
minVersion: "12.0.0",
|
|
680
|
+
version: "22.2.3",
|
|
681
|
+
ngImport: i0,
|
|
682
|
+
type: TxSankeyChart,
|
|
683
|
+
decorators: [{
|
|
684
|
+
type: Component,
|
|
685
|
+
args: [{
|
|
686
|
+
selector: "tx-sankey-chart",
|
|
687
|
+
imports: [TxChartFrame],
|
|
688
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
689
|
+
host: {
|
|
690
|
+
class: "tx-sankey-chart",
|
|
691
|
+
"[class]": "passThrough().root?.class",
|
|
692
|
+
"[style]": "hostStyle()",
|
|
693
|
+
"[attr.data-styled]": "!isUnstyled() || null",
|
|
694
|
+
"[class.tx-sankey-chart--fill]": "typeof height() === \"string\"",
|
|
695
|
+
"[class.tx-sankey-chart--entering]": "entrance.active()",
|
|
696
|
+
"[class.tx-sankey-chart--morph]": "morph()",
|
|
697
|
+
"[class.tx-sankey-chart--active]": "active() !== null"
|
|
698
|
+
},
|
|
699
|
+
template: "<tx-chart-frame\n [height]=\"height()\"\n [(size)]=\"size\"\n [showLegend]=\"false\"\n [empty]=\"isEmpty()\"\n [loading]=\"loading()\"\n [toolbar]=\"toolbar()\"\n [exportName]=\"ariaLabel()\"\n emptyIcon=\"chart-bar\"\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-sankey-chart__links\">\n @for (link of drawnLinks(); track link.key) {\n <svg:path\n class=\"tx-sankey-chart__link\"\n [class.tx-sankey-chart__link--lit]=\"isLinkLit(link)\"\n [class]=\"passThrough().link?.class\"\n [style]=\"passThrough().link?.style\"\n [attr.data-link]=\"link.key\"\n [attr.d]=\"link.path\"\n [style.--tx-sankey-chart-color]=\"link.color\"\n />\n }\n </svg:g>\n <svg:g class=\"tx-sankey-chart__nodes\">\n @for (node of layout().nodes; track node.id) {\n <svg:rect\n class=\"tx-sankey-chart__node\"\n [class.tx-sankey-chart__node--dimmed]=\"isNodeDimmed(node)\"\n [class]=\"passThrough().node?.class\"\n [style]=\"passThrough().node?.style\"\n [attr.data-node]=\"node.id\"\n [attr.x]=\"node.x\"\n [attr.y]=\"node.y\"\n [attr.width]=\"node.width\"\n [attr.height]=\"node.height\"\n [style.fill]=\"node.color\"\n [style.--tx-sankey-chart-order]=\"node.depth\"\n />\n }\n </svg:g>\n <svg:g class=\"tx-sankey-chart__labels\">\n @for (label of labels(); track label.key) {\n <svg:text\n class=\"tx-sankey-chart__label\"\n [class]=\"passThrough().label?.class\"\n [style]=\"passThrough().label?.style\"\n dominant-baseline=\"central\"\n [attr.x]=\"label.x\"\n [attr.y]=\"label.y\"\n [attr.text-anchor]=\"label.anchor\"\n >\n {{ label.label }}\n @if (label.value) {\n <svg:tspan class=\"tx-sankey-chart__value\" dx=\"5\">{{ label.value }}</svg:tspan>\n }\n </svg:text>\n }\n </svg:g>\n</tx-chart-frame>\n",
|
|
700
|
+
styles: [":host{display:block;min-width:0}:host(.tx-sankey-chart--fill){height:100%}.tx-sankey-chart__link{fill:var(--tx-sankey-chart-color);fill-opacity:.35}.tx-sankey-chart__links,.tx-sankey-chart__labels,.tx-sankey-chart__nodes{pointer-events:none}:host([data-styled]) .tx-sankey-chart__link{fill:color-mix(in srgb,var(--tx-sankey-chart-color) var(--tx-chart-sankey-link-strength),var(--tx-chart-sankey-link-base));fill-opacity:1;stroke:var(--tx-chart-sankey-link-edge-color);stroke-width:var(--tx-chart-sankey-link-edge-width);stroke-linejoin:round;transition:fill var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sankey-chart__node{rx:var(--tx-chart-sankey-node-radius);transition:opacity var(--tx-chart-motion-hover-duration) ease}:host([data-styled]) .tx-sankey-chart__label{fill:var(--tx-chart-sankey-label-color);font-size:var(--tx-chart-sankey-label-font-size);font-weight:var(--tx-chart-sankey-label-font-weight)}:host([data-styled]) .tx-sankey-chart__value{fill:var(--tx-chart-sankey-value-color);font-weight:var(--tx-font-weight-regular);font-variant-numeric:tabular-nums}:host([data-styled].tx-sankey-chart--active) .tx-sankey-chart__link{fill:color-mix(in srgb,var(--tx-sankey-chart-color) var(--tx-chart-sankey-link-dimmed-strength),var(--tx-chart-sankey-link-base))}:host([data-styled].tx-sankey-chart--active) .tx-sankey-chart__link--lit{fill:color-mix(in srgb,var(--tx-sankey-chart-color) var(--tx-chart-sankey-link-active-strength),var(--tx-chart-sankey-link-base))}:host([data-styled].tx-sankey-chart--active) .tx-sankey-chart__node--dimmed{opacity:var(--tx-chart-sankey-node-dimmed-opacity)}:host([data-styled].tx-sankey-chart--morph) .tx-sankey-chart__link{transition:fill var(--tx-chart-motion-hover-duration) ease,d var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing)}:host([data-styled].tx-sankey-chart--morph) .tx-sankey-chart__node{transition:opacity var(--tx-chart-motion-hover-duration) ease,y var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing),height var(--tx-chart-motion-update-duration) var(--tx-chart-motion-easing)}:host([data-styled].tx-sankey-chart--entering) .tx-sankey-chart__node{animation:tx-sankey-chart-fade var(--tx-chart-motion-enter-duration) ease both;animation-delay:calc(var(--tx-sankey-chart-order, 0) * var(--tx-chart-motion-stagger) * 3)}:host([data-styled].tx-sankey-chart--entering) .tx-sankey-chart__links{animation:tx-sankey-chart-reveal var(--tx-chart-motion-enter-duration) var(--tx-chart-motion-easing) both}:host([data-styled].tx-sankey-chart--entering) .tx-sankey-chart__labels{animation:tx-sankey-chart-fade var(--tx-chart-motion-enter-duration) ease both}@keyframes tx-sankey-chart-reveal{0%{clip-path:inset(0 100% 0 0)}to{clip-path:inset(0 0 0 0)}}@keyframes tx-sankey-chart-fade{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-sankey-chart__link,:host([data-styled]) .tx-sankey-chart__node,:host([data-styled]) .tx-sankey-chart__links,:host([data-styled]) .tx-sankey-chart__labels{transition:none;animation:none}}\n"]
|
|
701
|
+
}]
|
|
702
|
+
}],
|
|
703
|
+
ctorParameters: () => [],
|
|
704
|
+
propDecorators: {
|
|
705
|
+
nodes: [{
|
|
706
|
+
type: i0.Input,
|
|
707
|
+
args: [{
|
|
708
|
+
isSignal: true,
|
|
709
|
+
alias: "nodes",
|
|
710
|
+
required: false
|
|
711
|
+
}]
|
|
712
|
+
}],
|
|
713
|
+
links: [{
|
|
714
|
+
type: i0.Input,
|
|
715
|
+
args: [{
|
|
716
|
+
isSignal: true,
|
|
717
|
+
alias: "links",
|
|
718
|
+
required: false
|
|
719
|
+
}]
|
|
720
|
+
}],
|
|
721
|
+
height: [{
|
|
722
|
+
type: i0.Input,
|
|
723
|
+
args: [{
|
|
724
|
+
isSignal: true,
|
|
725
|
+
alias: "height",
|
|
726
|
+
required: false
|
|
727
|
+
}]
|
|
728
|
+
}],
|
|
729
|
+
align: [{
|
|
730
|
+
type: i0.Input,
|
|
731
|
+
args: [{
|
|
732
|
+
isSignal: true,
|
|
733
|
+
alias: "align",
|
|
734
|
+
required: false
|
|
735
|
+
}]
|
|
736
|
+
}],
|
|
737
|
+
showValues: [{
|
|
738
|
+
type: i0.Input,
|
|
739
|
+
args: [{
|
|
740
|
+
isSignal: true,
|
|
741
|
+
alias: "showValues",
|
|
742
|
+
required: false
|
|
743
|
+
}]
|
|
744
|
+
}],
|
|
745
|
+
showTooltip: [{
|
|
746
|
+
type: i0.Input,
|
|
747
|
+
args: [{
|
|
748
|
+
isSignal: true,
|
|
749
|
+
alias: "showTooltip",
|
|
750
|
+
required: false
|
|
751
|
+
}]
|
|
752
|
+
}],
|
|
753
|
+
valueFormat: [{
|
|
754
|
+
type: i0.Input,
|
|
755
|
+
args: [{
|
|
756
|
+
isSignal: true,
|
|
757
|
+
alias: "valueFormat",
|
|
758
|
+
required: false
|
|
759
|
+
}]
|
|
760
|
+
}],
|
|
761
|
+
toolbar: [{
|
|
762
|
+
type: i0.Input,
|
|
763
|
+
args: [{
|
|
764
|
+
isSignal: true,
|
|
765
|
+
alias: "toolbar",
|
|
766
|
+
required: false
|
|
767
|
+
}]
|
|
768
|
+
}],
|
|
769
|
+
loading: [{
|
|
770
|
+
type: i0.Input,
|
|
771
|
+
args: [{
|
|
772
|
+
isSignal: true,
|
|
773
|
+
alias: "loading",
|
|
774
|
+
required: false
|
|
775
|
+
}]
|
|
776
|
+
}],
|
|
777
|
+
ariaLabel: [{
|
|
778
|
+
type: i0.Input,
|
|
779
|
+
args: [{
|
|
780
|
+
isSignal: true,
|
|
781
|
+
alias: "ariaLabel",
|
|
782
|
+
required: false
|
|
783
|
+
}]
|
|
784
|
+
}],
|
|
785
|
+
dt: [{
|
|
786
|
+
type: i0.Input,
|
|
787
|
+
args: [{
|
|
788
|
+
isSignal: true,
|
|
789
|
+
alias: "dt",
|
|
790
|
+
required: false
|
|
791
|
+
}]
|
|
792
|
+
}],
|
|
793
|
+
pt: [{
|
|
794
|
+
type: i0.Input,
|
|
795
|
+
args: [{
|
|
796
|
+
isSignal: true,
|
|
797
|
+
alias: "pt",
|
|
798
|
+
required: false
|
|
799
|
+
}]
|
|
800
|
+
}],
|
|
801
|
+
ptOptions: [{
|
|
802
|
+
type: i0.Input,
|
|
803
|
+
args: [{
|
|
804
|
+
isSignal: true,
|
|
805
|
+
alias: "ptOptions",
|
|
806
|
+
required: false
|
|
807
|
+
}]
|
|
808
|
+
}],
|
|
809
|
+
unstyled: [{
|
|
810
|
+
type: i0.Input,
|
|
811
|
+
args: [{
|
|
812
|
+
isSignal: true,
|
|
813
|
+
alias: "unstyled",
|
|
814
|
+
required: false
|
|
815
|
+
}]
|
|
816
|
+
}],
|
|
817
|
+
nodeClick: [{
|
|
818
|
+
type: i0.Output,
|
|
819
|
+
args: ["nodeClick"]
|
|
820
|
+
}],
|
|
821
|
+
linkClick: [{
|
|
822
|
+
type: i0.Output,
|
|
823
|
+
args: ["linkClick"]
|
|
824
|
+
}],
|
|
825
|
+
tooltipTemplate: [{
|
|
826
|
+
type: i0.ContentChild,
|
|
827
|
+
args: [i0.forwardRef(() => TxChartTooltipTemplate), { isSignal: true }]
|
|
828
|
+
}],
|
|
829
|
+
frame: [{
|
|
830
|
+
type: i0.ViewChild,
|
|
831
|
+
args: [i0.forwardRef(() => TxChartFrame), { isSignal: true }]
|
|
832
|
+
}]
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
export { TxSankeyChart, sankeyLayout, sankeyLinkPath, sankeyLinkY, sankeyRibbonPath };
|
|
836
|
+
|
|
837
|
+
//# sourceMappingURL=tectra-ng-charts-sankey.mjs.map
|