@8btc/xcanvas 0.0.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 +70 -0
- package/dist/Tableau10-BqnYsPR6.js +9 -0
- package/dist/XCanvas-BxdLBkBz.js +27732 -0
- package/dist/_commonjs-dynamic-modules-TGKdzP3c.js +6 -0
- package/dist/ar-SA-G6X2FPQ2-DjqDLLYL.js +41 -0
- package/dist/arc-D1qX5GFf.js +132 -0
- package/dist/array-DgktLKBx.js +6 -0
- package/dist/az-AZ-76LH7QW2-D7LOsF3_.js +32 -0
- package/dist/bg-BG-XCXSNQG7-WI4tFn23.js +36 -0
- package/dist/blockDiagram-38ab4fdb-DtemKfEh.js +1811 -0
- package/dist/bn-BD-2XOGV67Q-Bugx_8fy.js +36 -0
- package/dist/c4Diagram-3d4e48cf-Byd2vU9K.js +2463 -0
- package/dist/ca-ES-6MX7JW3Y-6rFwKGsQ.js +39 -0
- package/dist/channel-BT_3Ze-Y.js +7 -0
- package/dist/chunk-EIO257PC-C7qD7hGu.js +1641 -0
- package/dist/classDiagram-70f12bd4-CwfYadk-.js +354 -0
- package/dist/classDiagram-v2-f2320105-B28MuM8f.js +284 -0
- package/dist/clone-D2FUK8WY.js +8 -0
- package/dist/createText-2e5e7dd3-Ca1JfQaJ.js +4914 -0
- package/dist/cs-CZ-2BRQDIVT-Dhd8XszK.js +42 -0
- package/dist/da-DK-5WZEPLOC-BhL87sSs.js +36 -0
- package/dist/de-DE-XR44H4JA-xSrZSV0J.js +39 -0
- package/dist/directory-open-01563666-XowynPwH.js +14 -0
- package/dist/directory-open-4ed118d0-BwYbu9dw.js +55 -0
- package/dist/edges-e0da2a9e-9VbVapWU.js +1840 -0
- package/dist/el-GR-BZB4AONW-DQORZ_pY.js +41 -0
- package/dist/en-B4ZKOASM-D2BVbEdz.js +39 -0
- package/dist/erDiagram-9861fffd-D4S9QDes.js +1318 -0
- package/dist/es-ES-U4NZUMDT-C0Q89-0V.js +40 -0
- package/dist/eu-ES-A7QVB2H4-BwBW3cEw.js +42 -0
- package/dist/fa-IR-HGAKTJCU-DtZ74rm4.js +39 -0
- package/dist/fi-FI-Z5N7JZ37-QvQan48z.js +37 -0
- package/dist/file-open-002ab408-BNIYSKAV.js +18 -0
- package/dist/file-open-7c801643-B_l1UXdI.js +15 -0
- package/dist/file-save-3189631c-vzijizFw.js +23 -0
- package/dist/file-save-745eba88-B5-wM56X.js +25 -0
- package/dist/flowDb-956e92f1-S6T8ppJw.js +1713 -0
- package/dist/flowDiagram-66a62f08-C6TTwS5_.js +1264 -0
- package/dist/flowDiagram-v2-96b9c2cf-CzfeUNGP.js +24 -0
- package/dist/flowchart-elk-definition-4a651766-CRv1kWtk.js +92922 -0
- package/dist/fr-FR-RHASNOE6-CZFiweNU.js +40 -0
- package/dist/ganttDiagram-c361ad54-CAnfd8Sw.js +3420 -0
- package/dist/gitGraphDiagram-72cf32ee-CSGI-xRI.js +1790 -0
- package/dist/gl-ES-HMX3MZ6V-Bqv2xL-V.js +41 -0
- package/dist/graph-Ct2tKpKj.js +1253 -0
- package/dist/he-IL-6SHJWFNN-kso30jhn.js +41 -0
- package/dist/hi-IN-IWLTKZ5I-Busk5oaa.js +35 -0
- package/dist/hu-HU-A5ZG7DT2-xSR2C2H0.js +38 -0
- package/dist/id-ID-SAP4L64H-BQQZYm1L.js +41 -0
- package/dist/image-EDRW2JGV-Cx7o2kxD.js +6 -0
- package/dist/image-blob-reduce.esm-BKPqMdie.js +2396 -0
- package/dist/index-3862675e-B3j3w-v_.js +663 -0
- package/dist/index-CLOU2Ikr.js +14364 -0
- package/dist/index.css +450 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +7 -0
- package/dist/index.umd.cjs +235477 -0
- package/dist/infoDiagram-f8f76790-NqA75uBo.js +510 -0
- package/dist/init-ZxktEp_H.js +16 -0
- package/dist/it-IT-JPQ66NNP-CAMVZrYt.js +42 -0
- package/dist/ja-JP-DBVTYXUO-CAX8A_Uj.js +39 -0
- package/dist/journeyDiagram-49397b02-By5oBzsZ.js +1182 -0
- package/dist/kaa-6HZHGXH3-4-o94cPY.js +32 -0
- package/dist/kab-KAB-ZGHBKWFO-CgyjjBvZ.js +39 -0
- package/dist/katex-C-jAQc2m.js +14516 -0
- package/dist/kk-KZ-P5N5QNE5-BEqZcwLA.js +32 -0
- package/dist/km-KH-HSX4SM5Z-DvKDbeH4.js +42 -0
- package/dist/ko-KR-MTYHY66A-DKCuAbKE.js +40 -0
- package/dist/ku-TR-6OUDTVRD-CNUs4cCe.js +40 -0
- package/dist/layout-AJxYKqQV.js +2292 -0
- package/dist/line-DJIf5OM8.js +45 -0
- package/dist/linear-Cfj4s4vI.js +539 -0
- package/dist/lt-LT-XHIRWOB4-gouzGdoW.js +34 -0
- package/dist/lv-LV-5QDEKY6T-CTvg1XFv.js +38 -0
- package/dist/mindmap-definition-fc14e90a-CBlwH_UF.js +35283 -0
- package/dist/mr-IN-CRQNXWMA-QeYm06Kq.js +44 -0
- package/dist/my-MM-5M5IBNSE-DG3k9ORf.js +32 -0
- package/dist/nb-NO-T6EIAALU-Cj995Nmg.js +41 -0
- package/dist/nl-NL-IS3SIHDZ-B-2H7xey.js +39 -0
- package/dist/nn-NO-6E72VCQL-DrAwKKTN.js +39 -0
- package/dist/oc-FR-POXYY2M6-CeyJD7tq.js +39 -0
- package/dist/ordinal-DSZU4PqD.js +76 -0
- package/dist/pa-IN-N4M65BXN-DHzi6mjo.js +35 -0
- package/dist/path-Cp2qmpkd.js +109 -0
- package/dist/percentages-BXMCSKIN-CDYsTuua.js +6 -0
- package/dist/pica-CzzcRNRD.js +1702 -0
- package/dist/pieDiagram-8a3498a8-DueGoZOh.js +768 -0
- package/dist/pl-PL-T2D74RX3-BBNEV2c6.js +40 -0
- package/dist/pt-BR-5N22H2LF-D2cTx_F0.js +40 -0
- package/dist/pt-PT-UZXXM6DQ-BddvLLsF.js +40 -0
- package/dist/quadrantDiagram-120e2f19-Tb6_oGIn.js +1198 -0
- package/dist/requirementDiagram-deff3bca-CEeg0ep-.js +1089 -0
- package/dist/ro-RO-JPDTUUEW-DynuW50i.js +42 -0
- package/dist/roundRect-CjfubgrN.js +152 -0
- package/dist/ru-RU-B4JR7IUQ-B5Hecrew.js +40 -0
- package/dist/sankeyDiagram-04a897e0-CGTLQ8Gm.js +1172 -0
- package/dist/sequenceDiagram-704730f1-CZ72D-Nd.js +3336 -0
- package/dist/si-LK-N5RQ5JYF-BGMa93tc.js +32 -0
- package/dist/sk-SK-C5VTKIMK-BttCAlBm.js +37 -0
- package/dist/sl-SI-NN7IZMDC-DTC59nzG.js +37 -0
- package/dist/stateDiagram-587899a1-XISZzz_f.js +451 -0
- package/dist/stateDiagram-v2-d93cdb3a-DbCcmzTc.js +319 -0
- package/dist/styles-6aaf32cf-CyfdkEib.js +1363 -0
- package/dist/styles-9a916d00-zQ92RrTB.js +1483 -0
- package/dist/styles-c10674c1-BWmkigmR.js +571 -0
- package/dist/subset-shared.chunk-BuFt2PpZ.js +8 -0
- package/dist/subset-worker.chunk-CgaFXU4O.js +14 -0
- package/dist/sv-SE-XGPEYMSR-BPDlPxC1.js +41 -0
- package/dist/svgDrawCommon-08f97a94-CJ0lufOi.js +100 -0
- package/dist/ta-IN-2NMHFXQM-CI1ZsNk9.js +40 -0
- package/dist/th-TH-HPSO5L25-CUM-w2Qt.js +33 -0
- package/dist/timeline-definition-85554ec2-DV6084Gl.js +1210 -0
- package/dist/tr-TR-DEFEU3FU-CGpyf_vD.js +38 -0
- package/dist/uk-UA-QMV73CPH-Bg15Mv3J.js +37 -0
- package/dist/vi-VN-M7AON7JQ-AYmca9so.js +36 -0
- package/dist/vite.svg +1 -0
- package/dist/xychartDiagram-e933f94c-P1e6EEaH.js +1796 -0
- package/dist/zh-CN-LNUGB5OW-Dem2Cc-c.js +41 -0
- package/dist/zh-HK-E62DVLB3-BjsDyiLI.js +32 -0
- package/dist/zh-TW-RAJ6MFWO-IDAsc9Pz.js +40 -0
- package/package.json +52 -0
|
@@ -0,0 +1,1172 @@
|
|
|
1
|
+
import { p as setDiagramTitle, o as getDiagramTitle, s as setAccDescription, a as getAccDescription, c as setAccTitle, b as getAccTitle, g as getConfig, q as defaultConfig, d as select, _ as setupGraphViewbox$1, r as clear$1, k as common$1 } from "./index-CLOU2Ikr.js";
|
|
2
|
+
import { o as ordinal } from "./ordinal-DSZU4PqD.js";
|
|
3
|
+
import { s as schemeTableau10 } from "./Tableau10-BqnYsPR6.js";
|
|
4
|
+
function max(values, valueof) {
|
|
5
|
+
let max2;
|
|
6
|
+
if (valueof === void 0) {
|
|
7
|
+
for (const value2 of values) {
|
|
8
|
+
if (value2 != null && (max2 < value2 || max2 === void 0 && value2 >= value2)) {
|
|
9
|
+
max2 = value2;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
let index = -1;
|
|
14
|
+
for (let value2 of values) {
|
|
15
|
+
if ((value2 = valueof(value2, ++index, values)) != null && (max2 < value2 || max2 === void 0 && value2 >= value2)) {
|
|
16
|
+
max2 = value2;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return max2;
|
|
21
|
+
}
|
|
22
|
+
function min(values, valueof) {
|
|
23
|
+
let min2;
|
|
24
|
+
if (valueof === void 0) {
|
|
25
|
+
for (const value2 of values) {
|
|
26
|
+
if (value2 != null && (min2 > value2 || min2 === void 0 && value2 >= value2)) {
|
|
27
|
+
min2 = value2;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
let index = -1;
|
|
32
|
+
for (let value2 of values) {
|
|
33
|
+
if ((value2 = valueof(value2, ++index, values)) != null && (min2 > value2 || min2 === void 0 && value2 >= value2)) {
|
|
34
|
+
min2 = value2;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return min2;
|
|
39
|
+
}
|
|
40
|
+
function sum(values, valueof) {
|
|
41
|
+
let sum2 = 0;
|
|
42
|
+
if (valueof === void 0) {
|
|
43
|
+
for (let value2 of values) {
|
|
44
|
+
if (value2 = +value2) {
|
|
45
|
+
sum2 += value2;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
let index = -1;
|
|
50
|
+
for (let value2 of values) {
|
|
51
|
+
if (value2 = +valueof(value2, ++index, values)) {
|
|
52
|
+
sum2 += value2;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return sum2;
|
|
57
|
+
}
|
|
58
|
+
function targetDepth(d) {
|
|
59
|
+
return d.target.depth;
|
|
60
|
+
}
|
|
61
|
+
function left(node) {
|
|
62
|
+
return node.depth;
|
|
63
|
+
}
|
|
64
|
+
function right(node, n) {
|
|
65
|
+
return n - 1 - node.height;
|
|
66
|
+
}
|
|
67
|
+
function justify(node, n) {
|
|
68
|
+
return node.sourceLinks.length ? node.depth : n - 1;
|
|
69
|
+
}
|
|
70
|
+
function center(node) {
|
|
71
|
+
return node.targetLinks.length ? node.depth : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 : 0;
|
|
72
|
+
}
|
|
73
|
+
function constant$1(x2) {
|
|
74
|
+
return function() {
|
|
75
|
+
return x2;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function ascendingSourceBreadth(a, b) {
|
|
79
|
+
return ascendingBreadth(a.source, b.source) || a.index - b.index;
|
|
80
|
+
}
|
|
81
|
+
function ascendingTargetBreadth(a, b) {
|
|
82
|
+
return ascendingBreadth(a.target, b.target) || a.index - b.index;
|
|
83
|
+
}
|
|
84
|
+
function ascendingBreadth(a, b) {
|
|
85
|
+
return a.y0 - b.y0;
|
|
86
|
+
}
|
|
87
|
+
function value(d) {
|
|
88
|
+
return d.value;
|
|
89
|
+
}
|
|
90
|
+
function defaultId(d) {
|
|
91
|
+
return d.index;
|
|
92
|
+
}
|
|
93
|
+
function defaultNodes(graph) {
|
|
94
|
+
return graph.nodes;
|
|
95
|
+
}
|
|
96
|
+
function defaultLinks(graph) {
|
|
97
|
+
return graph.links;
|
|
98
|
+
}
|
|
99
|
+
function find(nodeById, id) {
|
|
100
|
+
const node = nodeById.get(id);
|
|
101
|
+
if (!node) throw new Error("missing: " + id);
|
|
102
|
+
return node;
|
|
103
|
+
}
|
|
104
|
+
function computeLinkBreadths({ nodes: nodes2 }) {
|
|
105
|
+
for (const node of nodes2) {
|
|
106
|
+
let y0 = node.y0;
|
|
107
|
+
let y1 = y0;
|
|
108
|
+
for (const link2 of node.sourceLinks) {
|
|
109
|
+
link2.y0 = y0 + link2.width / 2;
|
|
110
|
+
y0 += link2.width;
|
|
111
|
+
}
|
|
112
|
+
for (const link2 of node.targetLinks) {
|
|
113
|
+
link2.y1 = y1 + link2.width / 2;
|
|
114
|
+
y1 += link2.width;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function Sankey() {
|
|
119
|
+
let x0 = 0, y0 = 0, x1 = 1, y1 = 1;
|
|
120
|
+
let dx = 24;
|
|
121
|
+
let dy = 8, py;
|
|
122
|
+
let id = defaultId;
|
|
123
|
+
let align = justify;
|
|
124
|
+
let sort;
|
|
125
|
+
let linkSort;
|
|
126
|
+
let nodes2 = defaultNodes;
|
|
127
|
+
let links2 = defaultLinks;
|
|
128
|
+
let iterations = 6;
|
|
129
|
+
function sankey() {
|
|
130
|
+
const graph = { nodes: nodes2.apply(null, arguments), links: links2.apply(null, arguments) };
|
|
131
|
+
computeNodeLinks(graph);
|
|
132
|
+
computeNodeValues(graph);
|
|
133
|
+
computeNodeDepths(graph);
|
|
134
|
+
computeNodeHeights(graph);
|
|
135
|
+
computeNodeBreadths(graph);
|
|
136
|
+
computeLinkBreadths(graph);
|
|
137
|
+
return graph;
|
|
138
|
+
}
|
|
139
|
+
sankey.update = function(graph) {
|
|
140
|
+
computeLinkBreadths(graph);
|
|
141
|
+
return graph;
|
|
142
|
+
};
|
|
143
|
+
sankey.nodeId = function(_) {
|
|
144
|
+
return arguments.length ? (id = typeof _ === "function" ? _ : constant$1(_), sankey) : id;
|
|
145
|
+
};
|
|
146
|
+
sankey.nodeAlign = function(_) {
|
|
147
|
+
return arguments.length ? (align = typeof _ === "function" ? _ : constant$1(_), sankey) : align;
|
|
148
|
+
};
|
|
149
|
+
sankey.nodeSort = function(_) {
|
|
150
|
+
return arguments.length ? (sort = _, sankey) : sort;
|
|
151
|
+
};
|
|
152
|
+
sankey.nodeWidth = function(_) {
|
|
153
|
+
return arguments.length ? (dx = +_, sankey) : dx;
|
|
154
|
+
};
|
|
155
|
+
sankey.nodePadding = function(_) {
|
|
156
|
+
return arguments.length ? (dy = py = +_, sankey) : dy;
|
|
157
|
+
};
|
|
158
|
+
sankey.nodes = function(_) {
|
|
159
|
+
return arguments.length ? (nodes2 = typeof _ === "function" ? _ : constant$1(_), sankey) : nodes2;
|
|
160
|
+
};
|
|
161
|
+
sankey.links = function(_) {
|
|
162
|
+
return arguments.length ? (links2 = typeof _ === "function" ? _ : constant$1(_), sankey) : links2;
|
|
163
|
+
};
|
|
164
|
+
sankey.linkSort = function(_) {
|
|
165
|
+
return arguments.length ? (linkSort = _, sankey) : linkSort;
|
|
166
|
+
};
|
|
167
|
+
sankey.size = function(_) {
|
|
168
|
+
return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];
|
|
169
|
+
};
|
|
170
|
+
sankey.extent = function(_) {
|
|
171
|
+
return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];
|
|
172
|
+
};
|
|
173
|
+
sankey.iterations = function(_) {
|
|
174
|
+
return arguments.length ? (iterations = +_, sankey) : iterations;
|
|
175
|
+
};
|
|
176
|
+
function computeNodeLinks({ nodes: nodes3, links: links3 }) {
|
|
177
|
+
for (const [i, node] of nodes3.entries()) {
|
|
178
|
+
node.index = i;
|
|
179
|
+
node.sourceLinks = [];
|
|
180
|
+
node.targetLinks = [];
|
|
181
|
+
}
|
|
182
|
+
const nodeById = new Map(nodes3.map((d, i) => [id(d, i, nodes3), d]));
|
|
183
|
+
for (const [i, link2] of links3.entries()) {
|
|
184
|
+
link2.index = i;
|
|
185
|
+
let { source, target } = link2;
|
|
186
|
+
if (typeof source !== "object") source = link2.source = find(nodeById, source);
|
|
187
|
+
if (typeof target !== "object") target = link2.target = find(nodeById, target);
|
|
188
|
+
source.sourceLinks.push(link2);
|
|
189
|
+
target.targetLinks.push(link2);
|
|
190
|
+
}
|
|
191
|
+
if (linkSort != null) {
|
|
192
|
+
for (const { sourceLinks, targetLinks } of nodes3) {
|
|
193
|
+
sourceLinks.sort(linkSort);
|
|
194
|
+
targetLinks.sort(linkSort);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function computeNodeValues({ nodes: nodes3 }) {
|
|
199
|
+
for (const node of nodes3) {
|
|
200
|
+
node.value = node.fixedValue === void 0 ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value)) : node.fixedValue;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function computeNodeDepths({ nodes: nodes3 }) {
|
|
204
|
+
const n = nodes3.length;
|
|
205
|
+
let current = new Set(nodes3);
|
|
206
|
+
let next = /* @__PURE__ */ new Set();
|
|
207
|
+
let x2 = 0;
|
|
208
|
+
while (current.size) {
|
|
209
|
+
for (const node of current) {
|
|
210
|
+
node.depth = x2;
|
|
211
|
+
for (const { target } of node.sourceLinks) {
|
|
212
|
+
next.add(target);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (++x2 > n) throw new Error("circular link");
|
|
216
|
+
current = next;
|
|
217
|
+
next = /* @__PURE__ */ new Set();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function computeNodeHeights({ nodes: nodes3 }) {
|
|
221
|
+
const n = nodes3.length;
|
|
222
|
+
let current = new Set(nodes3);
|
|
223
|
+
let next = /* @__PURE__ */ new Set();
|
|
224
|
+
let x2 = 0;
|
|
225
|
+
while (current.size) {
|
|
226
|
+
for (const node of current) {
|
|
227
|
+
node.height = x2;
|
|
228
|
+
for (const { source } of node.targetLinks) {
|
|
229
|
+
next.add(source);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (++x2 > n) throw new Error("circular link");
|
|
233
|
+
current = next;
|
|
234
|
+
next = /* @__PURE__ */ new Set();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function computeNodeLayers({ nodes: nodes3 }) {
|
|
238
|
+
const x2 = max(nodes3, (d) => d.depth) + 1;
|
|
239
|
+
const kx = (x1 - x0 - dx) / (x2 - 1);
|
|
240
|
+
const columns = new Array(x2);
|
|
241
|
+
for (const node of nodes3) {
|
|
242
|
+
const i = Math.max(0, Math.min(x2 - 1, Math.floor(align.call(null, node, x2))));
|
|
243
|
+
node.layer = i;
|
|
244
|
+
node.x0 = x0 + i * kx;
|
|
245
|
+
node.x1 = node.x0 + dx;
|
|
246
|
+
if (columns[i]) columns[i].push(node);
|
|
247
|
+
else columns[i] = [node];
|
|
248
|
+
}
|
|
249
|
+
if (sort) for (const column of columns) {
|
|
250
|
+
column.sort(sort);
|
|
251
|
+
}
|
|
252
|
+
return columns;
|
|
253
|
+
}
|
|
254
|
+
function initializeNodeBreadths(columns) {
|
|
255
|
+
const ky = min(columns, (c) => (y1 - y0 - (c.length - 1) * py) / sum(c, value));
|
|
256
|
+
for (const nodes3 of columns) {
|
|
257
|
+
let y2 = y0;
|
|
258
|
+
for (const node of nodes3) {
|
|
259
|
+
node.y0 = y2;
|
|
260
|
+
node.y1 = y2 + node.value * ky;
|
|
261
|
+
y2 = node.y1 + py;
|
|
262
|
+
for (const link2 of node.sourceLinks) {
|
|
263
|
+
link2.width = link2.value * ky;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
y2 = (y1 - y2 + py) / (nodes3.length + 1);
|
|
267
|
+
for (let i = 0; i < nodes3.length; ++i) {
|
|
268
|
+
const node = nodes3[i];
|
|
269
|
+
node.y0 += y2 * (i + 1);
|
|
270
|
+
node.y1 += y2 * (i + 1);
|
|
271
|
+
}
|
|
272
|
+
reorderLinks(nodes3);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function computeNodeBreadths(graph) {
|
|
276
|
+
const columns = computeNodeLayers(graph);
|
|
277
|
+
py = Math.min(dy, (y1 - y0) / (max(columns, (c) => c.length) - 1));
|
|
278
|
+
initializeNodeBreadths(columns);
|
|
279
|
+
for (let i = 0; i < iterations; ++i) {
|
|
280
|
+
const alpha = Math.pow(0.99, i);
|
|
281
|
+
const beta = Math.max(1 - alpha, (i + 1) / iterations);
|
|
282
|
+
relaxRightToLeft(columns, alpha, beta);
|
|
283
|
+
relaxLeftToRight(columns, alpha, beta);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function relaxLeftToRight(columns, alpha, beta) {
|
|
287
|
+
for (let i = 1, n = columns.length; i < n; ++i) {
|
|
288
|
+
const column = columns[i];
|
|
289
|
+
for (const target of column) {
|
|
290
|
+
let y2 = 0;
|
|
291
|
+
let w = 0;
|
|
292
|
+
for (const { source, value: value2 } of target.targetLinks) {
|
|
293
|
+
let v = value2 * (target.layer - source.layer);
|
|
294
|
+
y2 += targetTop(source, target) * v;
|
|
295
|
+
w += v;
|
|
296
|
+
}
|
|
297
|
+
if (!(w > 0)) continue;
|
|
298
|
+
let dy2 = (y2 / w - target.y0) * alpha;
|
|
299
|
+
target.y0 += dy2;
|
|
300
|
+
target.y1 += dy2;
|
|
301
|
+
reorderNodeLinks(target);
|
|
302
|
+
}
|
|
303
|
+
if (sort === void 0) column.sort(ascendingBreadth);
|
|
304
|
+
resolveCollisions(column, beta);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function relaxRightToLeft(columns, alpha, beta) {
|
|
308
|
+
for (let n = columns.length, i = n - 2; i >= 0; --i) {
|
|
309
|
+
const column = columns[i];
|
|
310
|
+
for (const source of column) {
|
|
311
|
+
let y2 = 0;
|
|
312
|
+
let w = 0;
|
|
313
|
+
for (const { target, value: value2 } of source.sourceLinks) {
|
|
314
|
+
let v = value2 * (target.layer - source.layer);
|
|
315
|
+
y2 += sourceTop(source, target) * v;
|
|
316
|
+
w += v;
|
|
317
|
+
}
|
|
318
|
+
if (!(w > 0)) continue;
|
|
319
|
+
let dy2 = (y2 / w - source.y0) * alpha;
|
|
320
|
+
source.y0 += dy2;
|
|
321
|
+
source.y1 += dy2;
|
|
322
|
+
reorderNodeLinks(source);
|
|
323
|
+
}
|
|
324
|
+
if (sort === void 0) column.sort(ascendingBreadth);
|
|
325
|
+
resolveCollisions(column, beta);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function resolveCollisions(nodes3, alpha) {
|
|
329
|
+
const i = nodes3.length >> 1;
|
|
330
|
+
const subject = nodes3[i];
|
|
331
|
+
resolveCollisionsBottomToTop(nodes3, subject.y0 - py, i - 1, alpha);
|
|
332
|
+
resolveCollisionsTopToBottom(nodes3, subject.y1 + py, i + 1, alpha);
|
|
333
|
+
resolveCollisionsBottomToTop(nodes3, y1, nodes3.length - 1, alpha);
|
|
334
|
+
resolveCollisionsTopToBottom(nodes3, y0, 0, alpha);
|
|
335
|
+
}
|
|
336
|
+
function resolveCollisionsTopToBottom(nodes3, y2, i, alpha) {
|
|
337
|
+
for (; i < nodes3.length; ++i) {
|
|
338
|
+
const node = nodes3[i];
|
|
339
|
+
const dy2 = (y2 - node.y0) * alpha;
|
|
340
|
+
if (dy2 > 1e-6) node.y0 += dy2, node.y1 += dy2;
|
|
341
|
+
y2 = node.y1 + py;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function resolveCollisionsBottomToTop(nodes3, y2, i, alpha) {
|
|
345
|
+
for (; i >= 0; --i) {
|
|
346
|
+
const node = nodes3[i];
|
|
347
|
+
const dy2 = (node.y1 - y2) * alpha;
|
|
348
|
+
if (dy2 > 1e-6) node.y0 -= dy2, node.y1 -= dy2;
|
|
349
|
+
y2 = node.y0 - py;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function reorderNodeLinks({ sourceLinks, targetLinks }) {
|
|
353
|
+
if (linkSort === void 0) {
|
|
354
|
+
for (const { source: { sourceLinks: sourceLinks2 } } of targetLinks) {
|
|
355
|
+
sourceLinks2.sort(ascendingTargetBreadth);
|
|
356
|
+
}
|
|
357
|
+
for (const { target: { targetLinks: targetLinks2 } } of sourceLinks) {
|
|
358
|
+
targetLinks2.sort(ascendingSourceBreadth);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function reorderLinks(nodes3) {
|
|
363
|
+
if (linkSort === void 0) {
|
|
364
|
+
for (const { sourceLinks, targetLinks } of nodes3) {
|
|
365
|
+
sourceLinks.sort(ascendingTargetBreadth);
|
|
366
|
+
targetLinks.sort(ascendingSourceBreadth);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
function targetTop(source, target) {
|
|
371
|
+
let y2 = source.y0 - (source.sourceLinks.length - 1) * py / 2;
|
|
372
|
+
for (const { target: node, width } of source.sourceLinks) {
|
|
373
|
+
if (node === target) break;
|
|
374
|
+
y2 += width + py;
|
|
375
|
+
}
|
|
376
|
+
for (const { source: node, width } of target.targetLinks) {
|
|
377
|
+
if (node === source) break;
|
|
378
|
+
y2 -= width;
|
|
379
|
+
}
|
|
380
|
+
return y2;
|
|
381
|
+
}
|
|
382
|
+
function sourceTop(source, target) {
|
|
383
|
+
let y2 = target.y0 - (target.targetLinks.length - 1) * py / 2;
|
|
384
|
+
for (const { source: node, width } of target.targetLinks) {
|
|
385
|
+
if (node === source) break;
|
|
386
|
+
y2 += width + py;
|
|
387
|
+
}
|
|
388
|
+
for (const { target: node, width } of source.sourceLinks) {
|
|
389
|
+
if (node === target) break;
|
|
390
|
+
y2 -= width;
|
|
391
|
+
}
|
|
392
|
+
return y2;
|
|
393
|
+
}
|
|
394
|
+
return sankey;
|
|
395
|
+
}
|
|
396
|
+
var pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon;
|
|
397
|
+
function Path() {
|
|
398
|
+
this._x0 = this._y0 = // start of current subpath
|
|
399
|
+
this._x1 = this._y1 = null;
|
|
400
|
+
this._ = "";
|
|
401
|
+
}
|
|
402
|
+
function path() {
|
|
403
|
+
return new Path();
|
|
404
|
+
}
|
|
405
|
+
Path.prototype = path.prototype = {
|
|
406
|
+
constructor: Path,
|
|
407
|
+
moveTo: function(x2, y2) {
|
|
408
|
+
this._ += "M" + (this._x0 = this._x1 = +x2) + "," + (this._y0 = this._y1 = +y2);
|
|
409
|
+
},
|
|
410
|
+
closePath: function() {
|
|
411
|
+
if (this._x1 !== null) {
|
|
412
|
+
this._x1 = this._x0, this._y1 = this._y0;
|
|
413
|
+
this._ += "Z";
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
lineTo: function(x2, y2) {
|
|
417
|
+
this._ += "L" + (this._x1 = +x2) + "," + (this._y1 = +y2);
|
|
418
|
+
},
|
|
419
|
+
quadraticCurveTo: function(x1, y1, x2, y2) {
|
|
420
|
+
this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x2) + "," + (this._y1 = +y2);
|
|
421
|
+
},
|
|
422
|
+
bezierCurveTo: function(x1, y1, x2, y2, x3, y3) {
|
|
423
|
+
this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x3) + "," + (this._y1 = +y3);
|
|
424
|
+
},
|
|
425
|
+
arcTo: function(x1, y1, x2, y2, r) {
|
|
426
|
+
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
|
|
427
|
+
var x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
|
|
428
|
+
if (r < 0) throw new Error("negative radius: " + r);
|
|
429
|
+
if (this._x1 === null) {
|
|
430
|
+
this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
431
|
+
} else if (!(l01_2 > epsilon)) ;
|
|
432
|
+
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
|
|
433
|
+
this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
434
|
+
} else {
|
|
435
|
+
var x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
|
|
436
|
+
if (Math.abs(t01 - 1) > epsilon) {
|
|
437
|
+
this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
|
|
438
|
+
}
|
|
439
|
+
this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
arc: function(x2, y2, r, a0, a1, ccw) {
|
|
443
|
+
x2 = +x2, y2 = +y2, r = +r, ccw = !!ccw;
|
|
444
|
+
var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x2 + dx, y0 = y2 + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
|
|
445
|
+
if (r < 0) throw new Error("negative radius: " + r);
|
|
446
|
+
if (this._x1 === null) {
|
|
447
|
+
this._ += "M" + x0 + "," + y0;
|
|
448
|
+
} else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {
|
|
449
|
+
this._ += "L" + x0 + "," + y0;
|
|
450
|
+
}
|
|
451
|
+
if (!r) return;
|
|
452
|
+
if (da < 0) da = da % tau + tau;
|
|
453
|
+
if (da > tauEpsilon) {
|
|
454
|
+
this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x2 - dx) + "," + (y2 - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
|
|
455
|
+
} else if (da > epsilon) {
|
|
456
|
+
this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x2 + r * Math.cos(a1)) + "," + (this._y1 = y2 + r * Math.sin(a1));
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
rect: function(x2, y2, w, h) {
|
|
460
|
+
this._ += "M" + (this._x0 = this._x1 = +x2) + "," + (this._y0 = this._y1 = +y2) + "h" + +w + "v" + +h + "h" + -w + "Z";
|
|
461
|
+
},
|
|
462
|
+
toString: function() {
|
|
463
|
+
return this._;
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
function constant(x2) {
|
|
467
|
+
return function constant2() {
|
|
468
|
+
return x2;
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function x(p) {
|
|
472
|
+
return p[0];
|
|
473
|
+
}
|
|
474
|
+
function y(p) {
|
|
475
|
+
return p[1];
|
|
476
|
+
}
|
|
477
|
+
var slice = Array.prototype.slice;
|
|
478
|
+
function linkSource(d) {
|
|
479
|
+
return d.source;
|
|
480
|
+
}
|
|
481
|
+
function linkTarget(d) {
|
|
482
|
+
return d.target;
|
|
483
|
+
}
|
|
484
|
+
function link(curve) {
|
|
485
|
+
var source = linkSource, target = linkTarget, x$1 = x, y$1 = y, context = null;
|
|
486
|
+
function link2() {
|
|
487
|
+
var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
|
|
488
|
+
if (!context) context = buffer = path();
|
|
489
|
+
curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv));
|
|
490
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
491
|
+
}
|
|
492
|
+
link2.source = function(_) {
|
|
493
|
+
return arguments.length ? (source = _, link2) : source;
|
|
494
|
+
};
|
|
495
|
+
link2.target = function(_) {
|
|
496
|
+
return arguments.length ? (target = _, link2) : target;
|
|
497
|
+
};
|
|
498
|
+
link2.x = function(_) {
|
|
499
|
+
return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link2) : x$1;
|
|
500
|
+
};
|
|
501
|
+
link2.y = function(_) {
|
|
502
|
+
return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link2) : y$1;
|
|
503
|
+
};
|
|
504
|
+
link2.context = function(_) {
|
|
505
|
+
return arguments.length ? (context = _ == null ? null : _, link2) : context;
|
|
506
|
+
};
|
|
507
|
+
return link2;
|
|
508
|
+
}
|
|
509
|
+
function curveHorizontal(context, x0, y0, x1, y1) {
|
|
510
|
+
context.moveTo(x0, y0);
|
|
511
|
+
context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
|
|
512
|
+
}
|
|
513
|
+
function linkHorizontal() {
|
|
514
|
+
return link(curveHorizontal);
|
|
515
|
+
}
|
|
516
|
+
function horizontalSource(d) {
|
|
517
|
+
return [d.source.x1, d.y0];
|
|
518
|
+
}
|
|
519
|
+
function horizontalTarget(d) {
|
|
520
|
+
return [d.target.x0, d.y1];
|
|
521
|
+
}
|
|
522
|
+
function sankeyLinkHorizontal() {
|
|
523
|
+
return linkHorizontal().source(horizontalSource).target(horizontalTarget);
|
|
524
|
+
}
|
|
525
|
+
var parser = (function() {
|
|
526
|
+
var o = function(k, v, o2, l) {
|
|
527
|
+
for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
|
528
|
+
;
|
|
529
|
+
return o2;
|
|
530
|
+
}, $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12];
|
|
531
|
+
var parser2 = {
|
|
532
|
+
trace: function trace() {
|
|
533
|
+
},
|
|
534
|
+
yy: {},
|
|
535
|
+
symbols_: { "error": 2, "start": 3, "SANKEY": 4, "NEWLINE": 5, "csv": 6, "opt_eof": 7, "record": 8, "csv_tail": 9, "EOF": 10, "field[source]": 11, "COMMA": 12, "field[target]": 13, "field[value]": 14, "field": 15, "escaped": 16, "non_escaped": 17, "DQUOTE": 18, "ESCAPED_TEXT": 19, "NON_ESCAPED_TEXT": 20, "$accept": 0, "$end": 1 },
|
|
536
|
+
terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" },
|
|
537
|
+
productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]],
|
|
538
|
+
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
|
539
|
+
var $0 = $$.length - 1;
|
|
540
|
+
switch (yystate) {
|
|
541
|
+
case 7:
|
|
542
|
+
const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"'));
|
|
543
|
+
const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"'));
|
|
544
|
+
const value2 = parseFloat($$[$0].trim());
|
|
545
|
+
yy.addLink(source, target, value2);
|
|
546
|
+
break;
|
|
547
|
+
case 8:
|
|
548
|
+
case 9:
|
|
549
|
+
case 11:
|
|
550
|
+
this.$ = $$[$0];
|
|
551
|
+
break;
|
|
552
|
+
case 10:
|
|
553
|
+
this.$ = $$[$0 - 1];
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])],
|
|
558
|
+
defaultActions: { 11: [2, 1], 12: [2, 5] },
|
|
559
|
+
parseError: function parseError(str, hash) {
|
|
560
|
+
if (hash.recoverable) {
|
|
561
|
+
this.trace(str);
|
|
562
|
+
} else {
|
|
563
|
+
var error = new Error(str);
|
|
564
|
+
error.hash = hash;
|
|
565
|
+
throw error;
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
parse: function parse(input) {
|
|
569
|
+
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
|
570
|
+
var args = lstack.slice.call(arguments, 1);
|
|
571
|
+
var lexer2 = Object.create(this.lexer);
|
|
572
|
+
var sharedState = { yy: {} };
|
|
573
|
+
for (var k in this.yy) {
|
|
574
|
+
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
575
|
+
sharedState.yy[k] = this.yy[k];
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
lexer2.setInput(input, sharedState.yy);
|
|
579
|
+
sharedState.yy.lexer = lexer2;
|
|
580
|
+
sharedState.yy.parser = this;
|
|
581
|
+
if (typeof lexer2.yylloc == "undefined") {
|
|
582
|
+
lexer2.yylloc = {};
|
|
583
|
+
}
|
|
584
|
+
var yyloc = lexer2.yylloc;
|
|
585
|
+
lstack.push(yyloc);
|
|
586
|
+
var ranges = lexer2.options && lexer2.options.ranges;
|
|
587
|
+
if (typeof sharedState.yy.parseError === "function") {
|
|
588
|
+
this.parseError = sharedState.yy.parseError;
|
|
589
|
+
} else {
|
|
590
|
+
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
591
|
+
}
|
|
592
|
+
function lex() {
|
|
593
|
+
var token;
|
|
594
|
+
token = tstack.pop() || lexer2.lex() || EOF;
|
|
595
|
+
if (typeof token !== "number") {
|
|
596
|
+
if (token instanceof Array) {
|
|
597
|
+
tstack = token;
|
|
598
|
+
token = tstack.pop();
|
|
599
|
+
}
|
|
600
|
+
token = self.symbols_[token] || token;
|
|
601
|
+
}
|
|
602
|
+
return token;
|
|
603
|
+
}
|
|
604
|
+
var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
|
605
|
+
while (true) {
|
|
606
|
+
state = stack[stack.length - 1];
|
|
607
|
+
if (this.defaultActions[state]) {
|
|
608
|
+
action = this.defaultActions[state];
|
|
609
|
+
} else {
|
|
610
|
+
if (symbol === null || typeof symbol == "undefined") {
|
|
611
|
+
symbol = lex();
|
|
612
|
+
}
|
|
613
|
+
action = table[state] && table[state][symbol];
|
|
614
|
+
}
|
|
615
|
+
if (typeof action === "undefined" || !action.length || !action[0]) {
|
|
616
|
+
var errStr = "";
|
|
617
|
+
expected = [];
|
|
618
|
+
for (p in table[state]) {
|
|
619
|
+
if (this.terminals_[p] && p > TERROR) {
|
|
620
|
+
expected.push("'" + this.terminals_[p] + "'");
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (lexer2.showPosition) {
|
|
624
|
+
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
|
625
|
+
} else {
|
|
626
|
+
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
|
627
|
+
}
|
|
628
|
+
this.parseError(errStr, {
|
|
629
|
+
text: lexer2.match,
|
|
630
|
+
token: this.terminals_[symbol] || symbol,
|
|
631
|
+
line: lexer2.yylineno,
|
|
632
|
+
loc: yyloc,
|
|
633
|
+
expected
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
if (action[0] instanceof Array && action.length > 1) {
|
|
637
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
|
638
|
+
}
|
|
639
|
+
switch (action[0]) {
|
|
640
|
+
case 1:
|
|
641
|
+
stack.push(symbol);
|
|
642
|
+
vstack.push(lexer2.yytext);
|
|
643
|
+
lstack.push(lexer2.yylloc);
|
|
644
|
+
stack.push(action[1]);
|
|
645
|
+
symbol = null;
|
|
646
|
+
{
|
|
647
|
+
yyleng = lexer2.yyleng;
|
|
648
|
+
yytext = lexer2.yytext;
|
|
649
|
+
yylineno = lexer2.yylineno;
|
|
650
|
+
yyloc = lexer2.yylloc;
|
|
651
|
+
}
|
|
652
|
+
break;
|
|
653
|
+
case 2:
|
|
654
|
+
len = this.productions_[action[1]][1];
|
|
655
|
+
yyval.$ = vstack[vstack.length - len];
|
|
656
|
+
yyval._$ = {
|
|
657
|
+
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
658
|
+
last_line: lstack[lstack.length - 1].last_line,
|
|
659
|
+
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
660
|
+
last_column: lstack[lstack.length - 1].last_column
|
|
661
|
+
};
|
|
662
|
+
if (ranges) {
|
|
663
|
+
yyval._$.range = [
|
|
664
|
+
lstack[lstack.length - (len || 1)].range[0],
|
|
665
|
+
lstack[lstack.length - 1].range[1]
|
|
666
|
+
];
|
|
667
|
+
}
|
|
668
|
+
r = this.performAction.apply(yyval, [
|
|
669
|
+
yytext,
|
|
670
|
+
yyleng,
|
|
671
|
+
yylineno,
|
|
672
|
+
sharedState.yy,
|
|
673
|
+
action[1],
|
|
674
|
+
vstack,
|
|
675
|
+
lstack
|
|
676
|
+
].concat(args));
|
|
677
|
+
if (typeof r !== "undefined") {
|
|
678
|
+
return r;
|
|
679
|
+
}
|
|
680
|
+
if (len) {
|
|
681
|
+
stack = stack.slice(0, -1 * len * 2);
|
|
682
|
+
vstack = vstack.slice(0, -1 * len);
|
|
683
|
+
lstack = lstack.slice(0, -1 * len);
|
|
684
|
+
}
|
|
685
|
+
stack.push(this.productions_[action[1]][0]);
|
|
686
|
+
vstack.push(yyval.$);
|
|
687
|
+
lstack.push(yyval._$);
|
|
688
|
+
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
689
|
+
stack.push(newState);
|
|
690
|
+
break;
|
|
691
|
+
case 3:
|
|
692
|
+
return true;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return true;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var lexer = /* @__PURE__ */ (function() {
|
|
699
|
+
var lexer2 = {
|
|
700
|
+
EOF: 1,
|
|
701
|
+
parseError: function parseError(str, hash) {
|
|
702
|
+
if (this.yy.parser) {
|
|
703
|
+
this.yy.parser.parseError(str, hash);
|
|
704
|
+
} else {
|
|
705
|
+
throw new Error(str);
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
// resets the lexer, sets new input
|
|
709
|
+
setInput: function(input, yy) {
|
|
710
|
+
this.yy = yy || this.yy || {};
|
|
711
|
+
this._input = input;
|
|
712
|
+
this._more = this._backtrack = this.done = false;
|
|
713
|
+
this.yylineno = this.yyleng = 0;
|
|
714
|
+
this.yytext = this.matched = this.match = "";
|
|
715
|
+
this.conditionStack = ["INITIAL"];
|
|
716
|
+
this.yylloc = {
|
|
717
|
+
first_line: 1,
|
|
718
|
+
first_column: 0,
|
|
719
|
+
last_line: 1,
|
|
720
|
+
last_column: 0
|
|
721
|
+
};
|
|
722
|
+
if (this.options.ranges) {
|
|
723
|
+
this.yylloc.range = [0, 0];
|
|
724
|
+
}
|
|
725
|
+
this.offset = 0;
|
|
726
|
+
return this;
|
|
727
|
+
},
|
|
728
|
+
// consumes and returns one char from the input
|
|
729
|
+
input: function() {
|
|
730
|
+
var ch = this._input[0];
|
|
731
|
+
this.yytext += ch;
|
|
732
|
+
this.yyleng++;
|
|
733
|
+
this.offset++;
|
|
734
|
+
this.match += ch;
|
|
735
|
+
this.matched += ch;
|
|
736
|
+
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
737
|
+
if (lines) {
|
|
738
|
+
this.yylineno++;
|
|
739
|
+
this.yylloc.last_line++;
|
|
740
|
+
} else {
|
|
741
|
+
this.yylloc.last_column++;
|
|
742
|
+
}
|
|
743
|
+
if (this.options.ranges) {
|
|
744
|
+
this.yylloc.range[1]++;
|
|
745
|
+
}
|
|
746
|
+
this._input = this._input.slice(1);
|
|
747
|
+
return ch;
|
|
748
|
+
},
|
|
749
|
+
// unshifts one char (or a string) into the input
|
|
750
|
+
unput: function(ch) {
|
|
751
|
+
var len = ch.length;
|
|
752
|
+
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
753
|
+
this._input = ch + this._input;
|
|
754
|
+
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
755
|
+
this.offset -= len;
|
|
756
|
+
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
757
|
+
this.match = this.match.substr(0, this.match.length - 1);
|
|
758
|
+
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
759
|
+
if (lines.length - 1) {
|
|
760
|
+
this.yylineno -= lines.length - 1;
|
|
761
|
+
}
|
|
762
|
+
var r = this.yylloc.range;
|
|
763
|
+
this.yylloc = {
|
|
764
|
+
first_line: this.yylloc.first_line,
|
|
765
|
+
last_line: this.yylineno + 1,
|
|
766
|
+
first_column: this.yylloc.first_column,
|
|
767
|
+
last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
|
|
768
|
+
};
|
|
769
|
+
if (this.options.ranges) {
|
|
770
|
+
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
771
|
+
}
|
|
772
|
+
this.yyleng = this.yytext.length;
|
|
773
|
+
return this;
|
|
774
|
+
},
|
|
775
|
+
// When called from action, caches matched text and appends it on next action
|
|
776
|
+
more: function() {
|
|
777
|
+
this._more = true;
|
|
778
|
+
return this;
|
|
779
|
+
},
|
|
780
|
+
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
|
781
|
+
reject: function() {
|
|
782
|
+
if (this.options.backtrack_lexer) {
|
|
783
|
+
this._backtrack = true;
|
|
784
|
+
} else {
|
|
785
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
|
|
786
|
+
text: "",
|
|
787
|
+
token: null,
|
|
788
|
+
line: this.yylineno
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
return this;
|
|
792
|
+
},
|
|
793
|
+
// retain first n characters of the match
|
|
794
|
+
less: function(n) {
|
|
795
|
+
this.unput(this.match.slice(n));
|
|
796
|
+
},
|
|
797
|
+
// displays already matched input, i.e. for error messages
|
|
798
|
+
pastInput: function() {
|
|
799
|
+
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
800
|
+
return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
|
801
|
+
},
|
|
802
|
+
// displays upcoming input, i.e. for error messages
|
|
803
|
+
upcomingInput: function() {
|
|
804
|
+
var next = this.match;
|
|
805
|
+
if (next.length < 20) {
|
|
806
|
+
next += this._input.substr(0, 20 - next.length);
|
|
807
|
+
}
|
|
808
|
+
return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
|
809
|
+
},
|
|
810
|
+
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
811
|
+
showPosition: function() {
|
|
812
|
+
var pre = this.pastInput();
|
|
813
|
+
var c = new Array(pre.length + 1).join("-");
|
|
814
|
+
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
815
|
+
},
|
|
816
|
+
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
817
|
+
test_match: function(match, indexed_rule) {
|
|
818
|
+
var token, lines, backup;
|
|
819
|
+
if (this.options.backtrack_lexer) {
|
|
820
|
+
backup = {
|
|
821
|
+
yylineno: this.yylineno,
|
|
822
|
+
yylloc: {
|
|
823
|
+
first_line: this.yylloc.first_line,
|
|
824
|
+
last_line: this.last_line,
|
|
825
|
+
first_column: this.yylloc.first_column,
|
|
826
|
+
last_column: this.yylloc.last_column
|
|
827
|
+
},
|
|
828
|
+
yytext: this.yytext,
|
|
829
|
+
match: this.match,
|
|
830
|
+
matches: this.matches,
|
|
831
|
+
matched: this.matched,
|
|
832
|
+
yyleng: this.yyleng,
|
|
833
|
+
offset: this.offset,
|
|
834
|
+
_more: this._more,
|
|
835
|
+
_input: this._input,
|
|
836
|
+
yy: this.yy,
|
|
837
|
+
conditionStack: this.conditionStack.slice(0),
|
|
838
|
+
done: this.done
|
|
839
|
+
};
|
|
840
|
+
if (this.options.ranges) {
|
|
841
|
+
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
845
|
+
if (lines) {
|
|
846
|
+
this.yylineno += lines.length;
|
|
847
|
+
}
|
|
848
|
+
this.yylloc = {
|
|
849
|
+
first_line: this.yylloc.last_line,
|
|
850
|
+
last_line: this.yylineno + 1,
|
|
851
|
+
first_column: this.yylloc.last_column,
|
|
852
|
+
last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
|
853
|
+
};
|
|
854
|
+
this.yytext += match[0];
|
|
855
|
+
this.match += match[0];
|
|
856
|
+
this.matches = match;
|
|
857
|
+
this.yyleng = this.yytext.length;
|
|
858
|
+
if (this.options.ranges) {
|
|
859
|
+
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
860
|
+
}
|
|
861
|
+
this._more = false;
|
|
862
|
+
this._backtrack = false;
|
|
863
|
+
this._input = this._input.slice(match[0].length);
|
|
864
|
+
this.matched += match[0];
|
|
865
|
+
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
866
|
+
if (this.done && this._input) {
|
|
867
|
+
this.done = false;
|
|
868
|
+
}
|
|
869
|
+
if (token) {
|
|
870
|
+
return token;
|
|
871
|
+
} else if (this._backtrack) {
|
|
872
|
+
for (var k in backup) {
|
|
873
|
+
this[k] = backup[k];
|
|
874
|
+
}
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
return false;
|
|
878
|
+
},
|
|
879
|
+
// return next match in input
|
|
880
|
+
next: function() {
|
|
881
|
+
if (this.done) {
|
|
882
|
+
return this.EOF;
|
|
883
|
+
}
|
|
884
|
+
if (!this._input) {
|
|
885
|
+
this.done = true;
|
|
886
|
+
}
|
|
887
|
+
var token, match, tempMatch, index;
|
|
888
|
+
if (!this._more) {
|
|
889
|
+
this.yytext = "";
|
|
890
|
+
this.match = "";
|
|
891
|
+
}
|
|
892
|
+
var rules = this._currentRules();
|
|
893
|
+
for (var i = 0; i < rules.length; i++) {
|
|
894
|
+
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
895
|
+
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
896
|
+
match = tempMatch;
|
|
897
|
+
index = i;
|
|
898
|
+
if (this.options.backtrack_lexer) {
|
|
899
|
+
token = this.test_match(tempMatch, rules[i]);
|
|
900
|
+
if (token !== false) {
|
|
901
|
+
return token;
|
|
902
|
+
} else if (this._backtrack) {
|
|
903
|
+
match = false;
|
|
904
|
+
continue;
|
|
905
|
+
} else {
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
} else if (!this.options.flex) {
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
if (match) {
|
|
914
|
+
token = this.test_match(match, rules[index]);
|
|
915
|
+
if (token !== false) {
|
|
916
|
+
return token;
|
|
917
|
+
}
|
|
918
|
+
return false;
|
|
919
|
+
}
|
|
920
|
+
if (this._input === "") {
|
|
921
|
+
return this.EOF;
|
|
922
|
+
} else {
|
|
923
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
|
924
|
+
text: "",
|
|
925
|
+
token: null,
|
|
926
|
+
line: this.yylineno
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
},
|
|
930
|
+
// return next match that has a token
|
|
931
|
+
lex: function lex() {
|
|
932
|
+
var r = this.next();
|
|
933
|
+
if (r) {
|
|
934
|
+
return r;
|
|
935
|
+
} else {
|
|
936
|
+
return this.lex();
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
940
|
+
begin: function begin(condition) {
|
|
941
|
+
this.conditionStack.push(condition);
|
|
942
|
+
},
|
|
943
|
+
// pop the previously active lexer condition state off the condition stack
|
|
944
|
+
popState: function popState() {
|
|
945
|
+
var n = this.conditionStack.length - 1;
|
|
946
|
+
if (n > 0) {
|
|
947
|
+
return this.conditionStack.pop();
|
|
948
|
+
} else {
|
|
949
|
+
return this.conditionStack[0];
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
953
|
+
_currentRules: function _currentRules() {
|
|
954
|
+
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
955
|
+
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
956
|
+
} else {
|
|
957
|
+
return this.conditions["INITIAL"].rules;
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
961
|
+
topState: function topState(n) {
|
|
962
|
+
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
963
|
+
if (n >= 0) {
|
|
964
|
+
return this.conditionStack[n];
|
|
965
|
+
} else {
|
|
966
|
+
return "INITIAL";
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
// alias for begin(condition)
|
|
970
|
+
pushState: function pushState(condition) {
|
|
971
|
+
this.begin(condition);
|
|
972
|
+
},
|
|
973
|
+
// return the number of states currently on the stack
|
|
974
|
+
stateStackSize: function stateStackSize() {
|
|
975
|
+
return this.conditionStack.length;
|
|
976
|
+
},
|
|
977
|
+
options: { "case-insensitive": true },
|
|
978
|
+
performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
|
979
|
+
switch ($avoiding_name_collisions) {
|
|
980
|
+
case 0:
|
|
981
|
+
this.pushState("csv");
|
|
982
|
+
return 4;
|
|
983
|
+
case 1:
|
|
984
|
+
return 10;
|
|
985
|
+
case 2:
|
|
986
|
+
return 5;
|
|
987
|
+
case 3:
|
|
988
|
+
return 12;
|
|
989
|
+
case 4:
|
|
990
|
+
this.pushState("escaped_text");
|
|
991
|
+
return 18;
|
|
992
|
+
case 5:
|
|
993
|
+
return 20;
|
|
994
|
+
case 6:
|
|
995
|
+
this.popState("escaped_text");
|
|
996
|
+
return 18;
|
|
997
|
+
case 7:
|
|
998
|
+
return 19;
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
rules: [/^(?:sankey-beta\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],
|
|
1002
|
+
conditions: { "csv": { "rules": [1, 2, 3, 4, 5, 6, 7], "inclusive": false }, "escaped_text": { "rules": [6, 7], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } }
|
|
1003
|
+
};
|
|
1004
|
+
return lexer2;
|
|
1005
|
+
})();
|
|
1006
|
+
parser2.lexer = lexer;
|
|
1007
|
+
function Parser() {
|
|
1008
|
+
this.yy = {};
|
|
1009
|
+
}
|
|
1010
|
+
Parser.prototype = parser2;
|
|
1011
|
+
parser2.Parser = Parser;
|
|
1012
|
+
return new Parser();
|
|
1013
|
+
})();
|
|
1014
|
+
parser.parser = parser;
|
|
1015
|
+
const parser$1 = parser;
|
|
1016
|
+
let links = [];
|
|
1017
|
+
let nodes = [];
|
|
1018
|
+
let nodesMap = {};
|
|
1019
|
+
const clear = () => {
|
|
1020
|
+
links = [];
|
|
1021
|
+
nodes = [];
|
|
1022
|
+
nodesMap = {};
|
|
1023
|
+
clear$1();
|
|
1024
|
+
};
|
|
1025
|
+
class SankeyLink {
|
|
1026
|
+
constructor(source, target, value2 = 0) {
|
|
1027
|
+
this.source = source;
|
|
1028
|
+
this.target = target;
|
|
1029
|
+
this.value = value2;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
const addLink = (source, target, value2) => {
|
|
1033
|
+
links.push(new SankeyLink(source, target, value2));
|
|
1034
|
+
};
|
|
1035
|
+
class SankeyNode {
|
|
1036
|
+
constructor(ID) {
|
|
1037
|
+
this.ID = ID;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
const findOrCreateNode = (ID) => {
|
|
1041
|
+
ID = common$1.sanitizeText(ID, getConfig());
|
|
1042
|
+
if (!nodesMap[ID]) {
|
|
1043
|
+
nodesMap[ID] = new SankeyNode(ID);
|
|
1044
|
+
nodes.push(nodesMap[ID]);
|
|
1045
|
+
}
|
|
1046
|
+
return nodesMap[ID];
|
|
1047
|
+
};
|
|
1048
|
+
const getNodes = () => nodes;
|
|
1049
|
+
const getLinks = () => links;
|
|
1050
|
+
const getGraph = () => ({
|
|
1051
|
+
nodes: nodes.map((node) => ({ id: node.ID })),
|
|
1052
|
+
links: links.map((link2) => ({
|
|
1053
|
+
source: link2.source.ID,
|
|
1054
|
+
target: link2.target.ID,
|
|
1055
|
+
value: link2.value
|
|
1056
|
+
}))
|
|
1057
|
+
});
|
|
1058
|
+
const db = {
|
|
1059
|
+
nodesMap,
|
|
1060
|
+
getConfig: () => getConfig().sankey,
|
|
1061
|
+
getNodes,
|
|
1062
|
+
getLinks,
|
|
1063
|
+
getGraph,
|
|
1064
|
+
addLink,
|
|
1065
|
+
findOrCreateNode,
|
|
1066
|
+
getAccTitle,
|
|
1067
|
+
setAccTitle,
|
|
1068
|
+
getAccDescription,
|
|
1069
|
+
setAccDescription,
|
|
1070
|
+
getDiagramTitle,
|
|
1071
|
+
setDiagramTitle,
|
|
1072
|
+
clear
|
|
1073
|
+
};
|
|
1074
|
+
const _Uid = class _Uid2 {
|
|
1075
|
+
static next(name) {
|
|
1076
|
+
return new _Uid2(name + ++_Uid2.count);
|
|
1077
|
+
}
|
|
1078
|
+
constructor(id) {
|
|
1079
|
+
this.id = id;
|
|
1080
|
+
this.href = `#${id}`;
|
|
1081
|
+
}
|
|
1082
|
+
toString() {
|
|
1083
|
+
return "url(" + this.href + ")";
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
_Uid.count = 0;
|
|
1087
|
+
let Uid = _Uid;
|
|
1088
|
+
const alignmentsMap = {
|
|
1089
|
+
left,
|
|
1090
|
+
right,
|
|
1091
|
+
center,
|
|
1092
|
+
justify
|
|
1093
|
+
};
|
|
1094
|
+
const draw = function(text, id, _version, diagObj) {
|
|
1095
|
+
const { securityLevel, sankey: conf } = getConfig();
|
|
1096
|
+
const defaultSankeyConfig = defaultConfig.sankey;
|
|
1097
|
+
let sandboxElement;
|
|
1098
|
+
if (securityLevel === "sandbox") {
|
|
1099
|
+
sandboxElement = select("#i" + id);
|
|
1100
|
+
}
|
|
1101
|
+
const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
|
1102
|
+
const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`);
|
|
1103
|
+
const width = (conf == null ? void 0 : conf.width) ?? defaultSankeyConfig.width;
|
|
1104
|
+
const height = (conf == null ? void 0 : conf.height) ?? defaultSankeyConfig.width;
|
|
1105
|
+
const useMaxWidth = (conf == null ? void 0 : conf.useMaxWidth) ?? defaultSankeyConfig.useMaxWidth;
|
|
1106
|
+
const nodeAlignment = (conf == null ? void 0 : conf.nodeAlignment) ?? defaultSankeyConfig.nodeAlignment;
|
|
1107
|
+
const prefix = (conf == null ? void 0 : conf.prefix) ?? defaultSankeyConfig.prefix;
|
|
1108
|
+
const suffix = (conf == null ? void 0 : conf.suffix) ?? defaultSankeyConfig.suffix;
|
|
1109
|
+
const showValues = (conf == null ? void 0 : conf.showValues) ?? defaultSankeyConfig.showValues;
|
|
1110
|
+
const graph = diagObj.db.getGraph();
|
|
1111
|
+
const nodeAlign = alignmentsMap[nodeAlignment];
|
|
1112
|
+
const nodeWidth = 10;
|
|
1113
|
+
const sankey$1 = Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(10 + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([
|
|
1114
|
+
[0, 0],
|
|
1115
|
+
[width, height]
|
|
1116
|
+
]);
|
|
1117
|
+
sankey$1(graph);
|
|
1118
|
+
const colorScheme = ordinal(schemeTableau10);
|
|
1119
|
+
svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) {
|
|
1120
|
+
return "translate(" + d.x0 + "," + d.y0 + ")";
|
|
1121
|
+
}).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => {
|
|
1122
|
+
return d.y1 - d.y0;
|
|
1123
|
+
}).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => colorScheme(d.id));
|
|
1124
|
+
const getText = ({ id: id2, value: value2 }) => {
|
|
1125
|
+
if (!showValues) {
|
|
1126
|
+
return id2;
|
|
1127
|
+
}
|
|
1128
|
+
return `${id2}
|
|
1129
|
+
${prefix}${Math.round(value2 * 100) / 100}${suffix}`;
|
|
1130
|
+
};
|
|
1131
|
+
svg.append("g").attr("class", "node-labels").attr("font-family", "sans-serif").attr("font-size", 14).selectAll("text").data(graph.nodes).join("text").attr("x", (d) => d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => d.x0 < width / 2 ? "start" : "end").text(getText);
|
|
1132
|
+
const link2 = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply");
|
|
1133
|
+
const linkColor = (conf == null ? void 0 : conf.linkColor) || "gradient";
|
|
1134
|
+
if (linkColor === "gradient") {
|
|
1135
|
+
const gradient = link2.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0);
|
|
1136
|
+
gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => colorScheme(d.source.id));
|
|
1137
|
+
gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => colorScheme(d.target.id));
|
|
1138
|
+
}
|
|
1139
|
+
let coloring;
|
|
1140
|
+
switch (linkColor) {
|
|
1141
|
+
case "gradient":
|
|
1142
|
+
coloring = (d) => d.uid;
|
|
1143
|
+
break;
|
|
1144
|
+
case "source":
|
|
1145
|
+
coloring = (d) => colorScheme(d.source.id);
|
|
1146
|
+
break;
|
|
1147
|
+
case "target":
|
|
1148
|
+
coloring = (d) => colorScheme(d.target.id);
|
|
1149
|
+
break;
|
|
1150
|
+
default:
|
|
1151
|
+
coloring = linkColor;
|
|
1152
|
+
}
|
|
1153
|
+
link2.append("path").attr("d", sankeyLinkHorizontal()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width));
|
|
1154
|
+
setupGraphViewbox$1(void 0, svg, 0, useMaxWidth);
|
|
1155
|
+
};
|
|
1156
|
+
const renderer = {
|
|
1157
|
+
draw
|
|
1158
|
+
};
|
|
1159
|
+
const prepareTextForParsing = (text) => {
|
|
1160
|
+
const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, "\n").trim();
|
|
1161
|
+
return textToParse;
|
|
1162
|
+
};
|
|
1163
|
+
const originalParse = parser$1.parse.bind(parser$1);
|
|
1164
|
+
parser$1.parse = (text) => originalParse(prepareTextForParsing(text));
|
|
1165
|
+
const diagram = {
|
|
1166
|
+
parser: parser$1,
|
|
1167
|
+
db,
|
|
1168
|
+
renderer
|
|
1169
|
+
};
|
|
1170
|
+
export {
|
|
1171
|
+
diagram
|
|
1172
|
+
};
|