@mui/x-charts-vendor 8.19.0 → 8.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/d3-path.d.ts +5 -0
- package/d3-path.js +7 -0
- package/d3-sankey.d.ts +0 -5
- package/package.json +6 -7
- package/es/d3-sankey.mjs +0 -6
- package/lib/d3-sankey.js +0 -6
- package/lib-vendor/d3-sankey/LICENSE +0 -27
- package/lib-vendor/d3-sankey/dist/d3-sankey.js +0 -438
- package/lib-vendor/d3-sankey/dist/d3-sankey.min.js +0 -329
- package/lib-vendor/d3-sankey/src/align.js +0 -25
- package/lib-vendor/d3-sankey/src/constant.js +0 -11
- package/lib-vendor/d3-sankey/src/index.js +0 -45
- package/lib-vendor/d3-sankey/src/sankey.js +0 -401
- package/lib-vendor/d3-sankey/src/sankeyLinkHorizontal.js +0 -16
package/d3-path.d.ts
ADDED
package/d3-path.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
// `x-charts-vendor/d3-path` (CommonJS)
|
|
3
|
+
// See upstream license: https://github.com/d3/d3-path/blob/main/LICENSE
|
|
4
|
+
//
|
|
5
|
+
// This file only exists for tooling that doesn't work yet with package.json:exports
|
|
6
|
+
// by proxying through the CommonJS version.
|
|
7
|
+
module.exports = require("./lib/d3-path");
|
package/d3-sankey.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts-vendor",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.21.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Vendored dependencies for MUI X Charts.",
|
|
6
6
|
"keywords": [
|
|
@@ -27,34 +27,33 @@
|
|
|
27
27
|
"@babel/runtime": "^7.28.4",
|
|
28
28
|
"@types/d3-color": "^3.1.3",
|
|
29
29
|
"@types/d3-interpolate": "^3.0.4",
|
|
30
|
-
"@types/d3-sankey": "^0.12.
|
|
30
|
+
"@types/d3-sankey": "^0.12.5",
|
|
31
31
|
"@types/d3-scale": "^4.0.9",
|
|
32
32
|
"@types/d3-shape": "^3.1.7",
|
|
33
33
|
"@types/d3-time": "^3.0.4",
|
|
34
34
|
"@types/d3-timer": "^3.0.2",
|
|
35
|
+
"@types/d3-path": "^3.1.1",
|
|
35
36
|
"d3-color": "^3.1.0",
|
|
36
37
|
"d3-interpolate": "^3.0.1",
|
|
37
|
-
"d3-sankey": "^0.12.3",
|
|
38
38
|
"d3-scale": "^4.0.2",
|
|
39
39
|
"d3-shape": "^3.2.0",
|
|
40
40
|
"d3-time": "^3.1.0",
|
|
41
|
-
"d3-timer": "^3.0.1"
|
|
41
|
+
"d3-timer": "^3.0.1",
|
|
42
|
+
"d3-path": "^3.1.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@babel/cli": "^7.28.3",
|
|
45
46
|
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
46
47
|
"@types/d3-array": "^3.2.2",
|
|
47
48
|
"@types/d3-format": "^3.0.4",
|
|
48
|
-
"@types/d3-path": "^3.1.1",
|
|
49
49
|
"@types/d3-time-format": "^4.0.3",
|
|
50
50
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
51
51
|
"d3-array": "^3.2.4",
|
|
52
52
|
"d3-format": "^3.1.0",
|
|
53
|
-
"d3-path": "^3.1.0",
|
|
54
53
|
"d3-time-format": "^4.1.0",
|
|
55
54
|
"execa": "^9.6.0",
|
|
56
55
|
"internmap": "^2.0.3",
|
|
57
|
-
"rimraf": "^6.1.
|
|
56
|
+
"rimraf": "^6.1.2"
|
|
58
57
|
},
|
|
59
58
|
"publishConfig": {
|
|
60
59
|
"access": "public"
|
package/es/d3-sankey.mjs
DELETED
package/lib/d3-sankey.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// `x-charts-vendor/d3-sankey` (CommonJS)
|
|
3
|
-
// See upstream license: https://github.com/d3/d3-sankey/blob/main/LICENSE
|
|
4
|
-
//
|
|
5
|
-
// Our CommonJS package relies on transpiled vendor files in `lib-vendor/d3-sankey`
|
|
6
|
-
module.exports = require("../lib-vendor/d3-sankey/src/index.js");
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Copyright 2015, Mike Bostock
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
-
are permitted provided that the following conditions are met:
|
|
6
|
-
|
|
7
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
-
list of conditions and the following disclaimer.
|
|
9
|
-
|
|
10
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
-
this list of conditions and the following disclaimer in the documentation
|
|
12
|
-
and/or other materials provided with the distribution.
|
|
13
|
-
|
|
14
|
-
* Neither the name of the author nor the names of contributors may be used to
|
|
15
|
-
endorse or promote products derived from this software without specific prior
|
|
16
|
-
written permission.
|
|
17
|
-
|
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
22
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
25
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// https://github.com/d3/d3-sankey v0.12.3 Copyright 2019 Mike Bostock
|
|
4
|
-
(function (global, factory) {
|
|
5
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require("../../../lib-vendor/d3-array/src/index.js"), require("../../../lib-vendor/d3-shape/src/index.js")) : typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-shape'], factory) : (global = global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3));
|
|
6
|
-
})(this, function (exports, d3Array, d3Shape) {
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
function targetDepth(d) {
|
|
10
|
-
return d.target.depth;
|
|
11
|
-
}
|
|
12
|
-
function left(node) {
|
|
13
|
-
return node.depth;
|
|
14
|
-
}
|
|
15
|
-
function right(node, n) {
|
|
16
|
-
return n - 1 - node.height;
|
|
17
|
-
}
|
|
18
|
-
function justify(node, n) {
|
|
19
|
-
return node.sourceLinks.length ? node.depth : n - 1;
|
|
20
|
-
}
|
|
21
|
-
function center(node) {
|
|
22
|
-
return node.targetLinks.length ? node.depth : node.sourceLinks.length ? d3Array.min(node.sourceLinks, targetDepth) - 1 : 0;
|
|
23
|
-
}
|
|
24
|
-
function constant(x) {
|
|
25
|
-
return function () {
|
|
26
|
-
return x;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function ascendingSourceBreadth(a, b) {
|
|
30
|
-
return ascendingBreadth(a.source, b.source) || a.index - b.index;
|
|
31
|
-
}
|
|
32
|
-
function ascendingTargetBreadth(a, b) {
|
|
33
|
-
return ascendingBreadth(a.target, b.target) || a.index - b.index;
|
|
34
|
-
}
|
|
35
|
-
function ascendingBreadth(a, b) {
|
|
36
|
-
return a.y0 - b.y0;
|
|
37
|
-
}
|
|
38
|
-
function value(d) {
|
|
39
|
-
return d.value;
|
|
40
|
-
}
|
|
41
|
-
function defaultId(d) {
|
|
42
|
-
return d.index;
|
|
43
|
-
}
|
|
44
|
-
function defaultNodes(graph) {
|
|
45
|
-
return graph.nodes;
|
|
46
|
-
}
|
|
47
|
-
function defaultLinks(graph) {
|
|
48
|
-
return graph.links;
|
|
49
|
-
}
|
|
50
|
-
function find(nodeById, id) {
|
|
51
|
-
const node = nodeById.get(id);
|
|
52
|
-
if (!node) throw new Error("missing: " + id);
|
|
53
|
-
return node;
|
|
54
|
-
}
|
|
55
|
-
function computeLinkBreadths({
|
|
56
|
-
nodes
|
|
57
|
-
}) {
|
|
58
|
-
for (const node of nodes) {
|
|
59
|
-
let y0 = node.y0;
|
|
60
|
-
let y1 = y0;
|
|
61
|
-
for (const link of node.sourceLinks) {
|
|
62
|
-
link.y0 = y0 + link.width / 2;
|
|
63
|
-
y0 += link.width;
|
|
64
|
-
}
|
|
65
|
-
for (const link of node.targetLinks) {
|
|
66
|
-
link.y1 = y1 + link.width / 2;
|
|
67
|
-
y1 += link.width;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function Sankey() {
|
|
72
|
-
let x0 = 0,
|
|
73
|
-
y0 = 0,
|
|
74
|
-
x1 = 1,
|
|
75
|
-
y1 = 1; // extent
|
|
76
|
-
let dx = 24; // nodeWidth
|
|
77
|
-
let dy = 8,
|
|
78
|
-
py; // nodePadding
|
|
79
|
-
let id = defaultId;
|
|
80
|
-
let align = justify;
|
|
81
|
-
let sort;
|
|
82
|
-
let linkSort;
|
|
83
|
-
let nodes = defaultNodes;
|
|
84
|
-
let links = defaultLinks;
|
|
85
|
-
let iterations = 6;
|
|
86
|
-
function sankey() {
|
|
87
|
-
const graph = {
|
|
88
|
-
nodes: nodes.apply(null, arguments),
|
|
89
|
-
links: links.apply(null, arguments)
|
|
90
|
-
};
|
|
91
|
-
computeNodeLinks(graph);
|
|
92
|
-
computeNodeValues(graph);
|
|
93
|
-
computeNodeDepths(graph);
|
|
94
|
-
computeNodeHeights(graph);
|
|
95
|
-
computeNodeBreadths(graph);
|
|
96
|
-
computeLinkBreadths(graph);
|
|
97
|
-
return graph;
|
|
98
|
-
}
|
|
99
|
-
sankey.update = function (graph) {
|
|
100
|
-
computeLinkBreadths(graph);
|
|
101
|
-
return graph;
|
|
102
|
-
};
|
|
103
|
-
sankey.nodeId = function (_) {
|
|
104
|
-
return arguments.length ? (id = typeof _ === "function" ? _ : constant(_), sankey) : id;
|
|
105
|
-
};
|
|
106
|
-
sankey.nodeAlign = function (_) {
|
|
107
|
-
return arguments.length ? (align = typeof _ === "function" ? _ : constant(_), sankey) : align;
|
|
108
|
-
};
|
|
109
|
-
sankey.nodeSort = function (_) {
|
|
110
|
-
return arguments.length ? (sort = _, sankey) : sort;
|
|
111
|
-
};
|
|
112
|
-
sankey.nodeWidth = function (_) {
|
|
113
|
-
return arguments.length ? (dx = +_, sankey) : dx;
|
|
114
|
-
};
|
|
115
|
-
sankey.nodePadding = function (_) {
|
|
116
|
-
return arguments.length ? (dy = py = +_, sankey) : dy;
|
|
117
|
-
};
|
|
118
|
-
sankey.nodes = function (_) {
|
|
119
|
-
return arguments.length ? (nodes = typeof _ === "function" ? _ : constant(_), sankey) : nodes;
|
|
120
|
-
};
|
|
121
|
-
sankey.links = function (_) {
|
|
122
|
-
return arguments.length ? (links = typeof _ === "function" ? _ : constant(_), sankey) : links;
|
|
123
|
-
};
|
|
124
|
-
sankey.linkSort = function (_) {
|
|
125
|
-
return arguments.length ? (linkSort = _, sankey) : linkSort;
|
|
126
|
-
};
|
|
127
|
-
sankey.size = function (_) {
|
|
128
|
-
return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];
|
|
129
|
-
};
|
|
130
|
-
sankey.extent = function (_) {
|
|
131
|
-
return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];
|
|
132
|
-
};
|
|
133
|
-
sankey.iterations = function (_) {
|
|
134
|
-
return arguments.length ? (iterations = +_, sankey) : iterations;
|
|
135
|
-
};
|
|
136
|
-
function computeNodeLinks({
|
|
137
|
-
nodes,
|
|
138
|
-
links
|
|
139
|
-
}) {
|
|
140
|
-
for (const [i, node] of nodes.entries()) {
|
|
141
|
-
node.index = i;
|
|
142
|
-
node.sourceLinks = [];
|
|
143
|
-
node.targetLinks = [];
|
|
144
|
-
}
|
|
145
|
-
const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d]));
|
|
146
|
-
for (const [i, link] of links.entries()) {
|
|
147
|
-
link.index = i;
|
|
148
|
-
let {
|
|
149
|
-
source,
|
|
150
|
-
target
|
|
151
|
-
} = link;
|
|
152
|
-
if (typeof source !== "object") source = link.source = find(nodeById, source);
|
|
153
|
-
if (typeof target !== "object") target = link.target = find(nodeById, target);
|
|
154
|
-
source.sourceLinks.push(link);
|
|
155
|
-
target.targetLinks.push(link);
|
|
156
|
-
}
|
|
157
|
-
if (linkSort != null) {
|
|
158
|
-
for (const {
|
|
159
|
-
sourceLinks,
|
|
160
|
-
targetLinks
|
|
161
|
-
} of nodes) {
|
|
162
|
-
sourceLinks.sort(linkSort);
|
|
163
|
-
targetLinks.sort(linkSort);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
function computeNodeValues({
|
|
168
|
-
nodes
|
|
169
|
-
}) {
|
|
170
|
-
for (const node of nodes) {
|
|
171
|
-
node.value = node.fixedValue === undefined ? Math.max(d3Array.sum(node.sourceLinks, value), d3Array.sum(node.targetLinks, value)) : node.fixedValue;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function computeNodeDepths({
|
|
175
|
-
nodes
|
|
176
|
-
}) {
|
|
177
|
-
const n = nodes.length;
|
|
178
|
-
let current = new Set(nodes);
|
|
179
|
-
let next = new Set();
|
|
180
|
-
let x = 0;
|
|
181
|
-
while (current.size) {
|
|
182
|
-
for (const node of current) {
|
|
183
|
-
node.depth = x;
|
|
184
|
-
for (const {
|
|
185
|
-
target
|
|
186
|
-
} of node.sourceLinks) {
|
|
187
|
-
next.add(target);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (++x > n) throw new Error("circular link");
|
|
191
|
-
current = next;
|
|
192
|
-
next = new Set();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function computeNodeHeights({
|
|
196
|
-
nodes
|
|
197
|
-
}) {
|
|
198
|
-
const n = nodes.length;
|
|
199
|
-
let current = new Set(nodes);
|
|
200
|
-
let next = new Set();
|
|
201
|
-
let x = 0;
|
|
202
|
-
while (current.size) {
|
|
203
|
-
for (const node of current) {
|
|
204
|
-
node.height = x;
|
|
205
|
-
for (const {
|
|
206
|
-
source
|
|
207
|
-
} of node.targetLinks) {
|
|
208
|
-
next.add(source);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
if (++x > n) throw new Error("circular link");
|
|
212
|
-
current = next;
|
|
213
|
-
next = new Set();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function computeNodeLayers({
|
|
217
|
-
nodes
|
|
218
|
-
}) {
|
|
219
|
-
const x = d3Array.max(nodes, d => d.depth) + 1;
|
|
220
|
-
const kx = (x1 - x0 - dx) / (x - 1);
|
|
221
|
-
const columns = new Array(x);
|
|
222
|
-
for (const node of nodes) {
|
|
223
|
-
const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));
|
|
224
|
-
node.layer = i;
|
|
225
|
-
node.x0 = x0 + i * kx;
|
|
226
|
-
node.x1 = node.x0 + dx;
|
|
227
|
-
if (columns[i]) columns[i].push(node);else columns[i] = [node];
|
|
228
|
-
}
|
|
229
|
-
if (sort) for (const column of columns) {
|
|
230
|
-
column.sort(sort);
|
|
231
|
-
}
|
|
232
|
-
return columns;
|
|
233
|
-
}
|
|
234
|
-
function initializeNodeBreadths(columns) {
|
|
235
|
-
const ky = d3Array.min(columns, c => (y1 - y0 - (c.length - 1) * py) / d3Array.sum(c, value));
|
|
236
|
-
for (const nodes of columns) {
|
|
237
|
-
let y = y0;
|
|
238
|
-
for (const node of nodes) {
|
|
239
|
-
node.y0 = y;
|
|
240
|
-
node.y1 = y + node.value * ky;
|
|
241
|
-
y = node.y1 + py;
|
|
242
|
-
for (const link of node.sourceLinks) {
|
|
243
|
-
link.width = link.value * ky;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
y = (y1 - y + py) / (nodes.length + 1);
|
|
247
|
-
for (let i = 0; i < nodes.length; ++i) {
|
|
248
|
-
const node = nodes[i];
|
|
249
|
-
node.y0 += y * (i + 1);
|
|
250
|
-
node.y1 += y * (i + 1);
|
|
251
|
-
}
|
|
252
|
-
reorderLinks(nodes);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function computeNodeBreadths(graph) {
|
|
256
|
-
const columns = computeNodeLayers(graph);
|
|
257
|
-
py = Math.min(dy, (y1 - y0) / (d3Array.max(columns, c => c.length) - 1));
|
|
258
|
-
initializeNodeBreadths(columns);
|
|
259
|
-
for (let i = 0; i < iterations; ++i) {
|
|
260
|
-
const alpha = Math.pow(0.99, i);
|
|
261
|
-
const beta = Math.max(1 - alpha, (i + 1) / iterations);
|
|
262
|
-
relaxRightToLeft(columns, alpha, beta);
|
|
263
|
-
relaxLeftToRight(columns, alpha, beta);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Reposition each node based on its incoming (target) links.
|
|
268
|
-
function relaxLeftToRight(columns, alpha, beta) {
|
|
269
|
-
for (let i = 1, n = columns.length; i < n; ++i) {
|
|
270
|
-
const column = columns[i];
|
|
271
|
-
for (const target of column) {
|
|
272
|
-
let y = 0;
|
|
273
|
-
let w = 0;
|
|
274
|
-
for (const {
|
|
275
|
-
source,
|
|
276
|
-
value
|
|
277
|
-
} of target.targetLinks) {
|
|
278
|
-
let v = value * (target.layer - source.layer);
|
|
279
|
-
y += targetTop(source, target) * v;
|
|
280
|
-
w += v;
|
|
281
|
-
}
|
|
282
|
-
if (!(w > 0)) continue;
|
|
283
|
-
let dy = (y / w - target.y0) * alpha;
|
|
284
|
-
target.y0 += dy;
|
|
285
|
-
target.y1 += dy;
|
|
286
|
-
reorderNodeLinks(target);
|
|
287
|
-
}
|
|
288
|
-
if (sort === undefined) column.sort(ascendingBreadth);
|
|
289
|
-
resolveCollisions(column, beta);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Reposition each node based on its outgoing (source) links.
|
|
294
|
-
function relaxRightToLeft(columns, alpha, beta) {
|
|
295
|
-
for (let n = columns.length, i = n - 2; i >= 0; --i) {
|
|
296
|
-
const column = columns[i];
|
|
297
|
-
for (const source of column) {
|
|
298
|
-
let y = 0;
|
|
299
|
-
let w = 0;
|
|
300
|
-
for (const {
|
|
301
|
-
target,
|
|
302
|
-
value
|
|
303
|
-
} of source.sourceLinks) {
|
|
304
|
-
let v = value * (target.layer - source.layer);
|
|
305
|
-
y += sourceTop(source, target) * v;
|
|
306
|
-
w += v;
|
|
307
|
-
}
|
|
308
|
-
if (!(w > 0)) continue;
|
|
309
|
-
let dy = (y / w - source.y0) * alpha;
|
|
310
|
-
source.y0 += dy;
|
|
311
|
-
source.y1 += dy;
|
|
312
|
-
reorderNodeLinks(source);
|
|
313
|
-
}
|
|
314
|
-
if (sort === undefined) column.sort(ascendingBreadth);
|
|
315
|
-
resolveCollisions(column, beta);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
function resolveCollisions(nodes, alpha) {
|
|
319
|
-
const i = nodes.length >> 1;
|
|
320
|
-
const subject = nodes[i];
|
|
321
|
-
resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha);
|
|
322
|
-
resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha);
|
|
323
|
-
resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha);
|
|
324
|
-
resolveCollisionsTopToBottom(nodes, y0, 0, alpha);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// Push any overlapping nodes down.
|
|
328
|
-
function resolveCollisionsTopToBottom(nodes, y, i, alpha) {
|
|
329
|
-
for (; i < nodes.length; ++i) {
|
|
330
|
-
const node = nodes[i];
|
|
331
|
-
const dy = (y - node.y0) * alpha;
|
|
332
|
-
if (dy > 1e-6) node.y0 += dy, node.y1 += dy;
|
|
333
|
-
y = node.y1 + py;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Push any overlapping nodes up.
|
|
338
|
-
function resolveCollisionsBottomToTop(nodes, y, i, alpha) {
|
|
339
|
-
for (; i >= 0; --i) {
|
|
340
|
-
const node = nodes[i];
|
|
341
|
-
const dy = (node.y1 - y) * alpha;
|
|
342
|
-
if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy;
|
|
343
|
-
y = node.y0 - py;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
function reorderNodeLinks({
|
|
347
|
-
sourceLinks,
|
|
348
|
-
targetLinks
|
|
349
|
-
}) {
|
|
350
|
-
if (linkSort === undefined) {
|
|
351
|
-
for (const {
|
|
352
|
-
source: {
|
|
353
|
-
sourceLinks
|
|
354
|
-
}
|
|
355
|
-
} of targetLinks) {
|
|
356
|
-
sourceLinks.sort(ascendingTargetBreadth);
|
|
357
|
-
}
|
|
358
|
-
for (const {
|
|
359
|
-
target: {
|
|
360
|
-
targetLinks
|
|
361
|
-
}
|
|
362
|
-
} of sourceLinks) {
|
|
363
|
-
targetLinks.sort(ascendingSourceBreadth);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
function reorderLinks(nodes) {
|
|
368
|
-
if (linkSort === undefined) {
|
|
369
|
-
for (const {
|
|
370
|
-
sourceLinks,
|
|
371
|
-
targetLinks
|
|
372
|
-
} of nodes) {
|
|
373
|
-
sourceLinks.sort(ascendingTargetBreadth);
|
|
374
|
-
targetLinks.sort(ascendingSourceBreadth);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// Returns the target.y0 that would produce an ideal link from source to target.
|
|
380
|
-
function targetTop(source, target) {
|
|
381
|
-
let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;
|
|
382
|
-
for (const {
|
|
383
|
-
target: node,
|
|
384
|
-
width
|
|
385
|
-
} of source.sourceLinks) {
|
|
386
|
-
if (node === target) break;
|
|
387
|
-
y += width + py;
|
|
388
|
-
}
|
|
389
|
-
for (const {
|
|
390
|
-
source: node,
|
|
391
|
-
width
|
|
392
|
-
} of target.targetLinks) {
|
|
393
|
-
if (node === source) break;
|
|
394
|
-
y -= width;
|
|
395
|
-
}
|
|
396
|
-
return y;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// Returns the source.y0 that would produce an ideal link from source to target.
|
|
400
|
-
function sourceTop(source, target) {
|
|
401
|
-
let y = target.y0 - (target.targetLinks.length - 1) * py / 2;
|
|
402
|
-
for (const {
|
|
403
|
-
source: node,
|
|
404
|
-
width
|
|
405
|
-
} of target.targetLinks) {
|
|
406
|
-
if (node === source) break;
|
|
407
|
-
y += width + py;
|
|
408
|
-
}
|
|
409
|
-
for (const {
|
|
410
|
-
target: node,
|
|
411
|
-
width
|
|
412
|
-
} of source.sourceLinks) {
|
|
413
|
-
if (node === target) break;
|
|
414
|
-
y -= width;
|
|
415
|
-
}
|
|
416
|
-
return y;
|
|
417
|
-
}
|
|
418
|
-
return sankey;
|
|
419
|
-
}
|
|
420
|
-
function horizontalSource(d) {
|
|
421
|
-
return [d.source.x1, d.y0];
|
|
422
|
-
}
|
|
423
|
-
function horizontalTarget(d) {
|
|
424
|
-
return [d.target.x0, d.y1];
|
|
425
|
-
}
|
|
426
|
-
function sankeyLinkHorizontal() {
|
|
427
|
-
return d3Shape.linkHorizontal().source(horizontalSource).target(horizontalTarget);
|
|
428
|
-
}
|
|
429
|
-
exports.sankey = Sankey;
|
|
430
|
-
exports.sankeyCenter = center;
|
|
431
|
-
exports.sankeyJustify = justify;
|
|
432
|
-
exports.sankeyLeft = left;
|
|
433
|
-
exports.sankeyLinkHorizontal = sankeyLinkHorizontal;
|
|
434
|
-
exports.sankeyRight = right;
|
|
435
|
-
Object.defineProperty(exports, '__esModule', {
|
|
436
|
-
value: true
|
|
437
|
-
});
|
|
438
|
-
});
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// https://github.com/d3/d3-sankey v0.12.3 Copyright 2019 Mike Bostock
|
|
4
|
-
!function (n, t) {
|
|
5
|
-
"object" == typeof exports && "undefined" != typeof module ? t(exports, require("../../../lib-vendor/d3-array/src/index.js"), require("../../../lib-vendor/d3-shape/src/index.js")) : "function" == typeof define && define.amd ? define(["exports", "d3-array", "d3-shape"], t) : t((n = n || self).d3 = n.d3 || {}, n.d3, n.d3);
|
|
6
|
-
}(this, function (n, t, e) {
|
|
7
|
-
"use strict";
|
|
8
|
-
|
|
9
|
-
function o(n) {
|
|
10
|
-
return n.target.depth;
|
|
11
|
-
}
|
|
12
|
-
function r(n, t) {
|
|
13
|
-
return n.sourceLinks.length ? n.depth : t - 1;
|
|
14
|
-
}
|
|
15
|
-
function i(n) {
|
|
16
|
-
return function () {
|
|
17
|
-
return n;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function s(n, t) {
|
|
21
|
-
return u(n.source, t.source) || n.index - t.index;
|
|
22
|
-
}
|
|
23
|
-
function f(n, t) {
|
|
24
|
-
return u(n.target, t.target) || n.index - t.index;
|
|
25
|
-
}
|
|
26
|
-
function u(n, t) {
|
|
27
|
-
return n.y0 - t.y0;
|
|
28
|
-
}
|
|
29
|
-
function c(n) {
|
|
30
|
-
return n.value;
|
|
31
|
-
}
|
|
32
|
-
function l(n) {
|
|
33
|
-
return n.index;
|
|
34
|
-
}
|
|
35
|
-
function a(n) {
|
|
36
|
-
return n.nodes;
|
|
37
|
-
}
|
|
38
|
-
function d(n) {
|
|
39
|
-
return n.links;
|
|
40
|
-
}
|
|
41
|
-
function h(n, t) {
|
|
42
|
-
const e = n.get(t);
|
|
43
|
-
if (!e) throw new Error("missing: " + t);
|
|
44
|
-
return e;
|
|
45
|
-
}
|
|
46
|
-
function g({
|
|
47
|
-
nodes: n
|
|
48
|
-
}) {
|
|
49
|
-
for (const t of n) {
|
|
50
|
-
let n = t.y0,
|
|
51
|
-
e = n;
|
|
52
|
-
for (const e of t.sourceLinks) e.y0 = n + e.width / 2, n += e.width;
|
|
53
|
-
for (const n of t.targetLinks) n.y1 = e + n.width / 2, e += n.width;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function y(n) {
|
|
57
|
-
return [n.source.x1, n.y0];
|
|
58
|
-
}
|
|
59
|
-
function k(n) {
|
|
60
|
-
return [n.target.x0, n.y1];
|
|
61
|
-
}
|
|
62
|
-
n.sankey = function () {
|
|
63
|
-
let n,
|
|
64
|
-
e,
|
|
65
|
-
o,
|
|
66
|
-
y = 0,
|
|
67
|
-
k = 0,
|
|
68
|
-
L = 1,
|
|
69
|
-
p = 1,
|
|
70
|
-
w = 24,
|
|
71
|
-
x = 8,
|
|
72
|
-
m = l,
|
|
73
|
-
v = r,
|
|
74
|
-
M = a,
|
|
75
|
-
b = d,
|
|
76
|
-
S = 6;
|
|
77
|
-
function z() {
|
|
78
|
-
const r = {
|
|
79
|
-
nodes: M.apply(null, arguments),
|
|
80
|
-
links: b.apply(null, arguments)
|
|
81
|
-
};
|
|
82
|
-
return function ({
|
|
83
|
-
nodes: n,
|
|
84
|
-
links: t
|
|
85
|
-
}) {
|
|
86
|
-
for (const [t, e] of n.entries()) e.index = t, e.sourceLinks = [], e.targetLinks = [];
|
|
87
|
-
const e = new Map(n.map((t, e) => [m(t, e, n), t]));
|
|
88
|
-
for (const [n, o] of t.entries()) {
|
|
89
|
-
o.index = n;
|
|
90
|
-
let {
|
|
91
|
-
source: t,
|
|
92
|
-
target: r
|
|
93
|
-
} = o;
|
|
94
|
-
"object" != typeof t && (t = o.source = h(e, t)), "object" != typeof r && (r = o.target = h(e, r)), t.sourceLinks.push(o), r.targetLinks.push(o);
|
|
95
|
-
}
|
|
96
|
-
if (null != o) for (const {
|
|
97
|
-
sourceLinks: t,
|
|
98
|
-
targetLinks: e
|
|
99
|
-
} of n) t.sort(o), e.sort(o);
|
|
100
|
-
}(r), function ({
|
|
101
|
-
nodes: n
|
|
102
|
-
}) {
|
|
103
|
-
for (const e of n) e.value = void 0 === e.fixedValue ? Math.max(t.sum(e.sourceLinks, c), t.sum(e.targetLinks, c)) : e.fixedValue;
|
|
104
|
-
}(r), function ({
|
|
105
|
-
nodes: n
|
|
106
|
-
}) {
|
|
107
|
-
const t = n.length;
|
|
108
|
-
let e = new Set(n),
|
|
109
|
-
o = new Set(),
|
|
110
|
-
r = 0;
|
|
111
|
-
for (; e.size;) {
|
|
112
|
-
for (const n of e) {
|
|
113
|
-
n.depth = r;
|
|
114
|
-
for (const {
|
|
115
|
-
target: t
|
|
116
|
-
} of n.sourceLinks) o.add(t);
|
|
117
|
-
}
|
|
118
|
-
if (++r > t) throw new Error("circular link");
|
|
119
|
-
e = o, o = new Set();
|
|
120
|
-
}
|
|
121
|
-
}(r), function ({
|
|
122
|
-
nodes: n
|
|
123
|
-
}) {
|
|
124
|
-
const t = n.length;
|
|
125
|
-
let e = new Set(n),
|
|
126
|
-
o = new Set(),
|
|
127
|
-
r = 0;
|
|
128
|
-
for (; e.size;) {
|
|
129
|
-
for (const n of e) {
|
|
130
|
-
n.height = r;
|
|
131
|
-
for (const {
|
|
132
|
-
source: t
|
|
133
|
-
} of n.targetLinks) o.add(t);
|
|
134
|
-
}
|
|
135
|
-
if (++r > t) throw new Error("circular link");
|
|
136
|
-
e = o, o = new Set();
|
|
137
|
-
}
|
|
138
|
-
}(r), function (o) {
|
|
139
|
-
const r = function ({
|
|
140
|
-
nodes: n
|
|
141
|
-
}) {
|
|
142
|
-
const o = t.max(n, n => n.depth) + 1,
|
|
143
|
-
r = (L - y - w) / (o - 1),
|
|
144
|
-
i = new Array(o);
|
|
145
|
-
for (const t of n) {
|
|
146
|
-
const n = Math.max(0, Math.min(o - 1, Math.floor(v.call(null, t, o))));
|
|
147
|
-
t.layer = n, t.x0 = y + n * r, t.x1 = t.x0 + w, i[n] ? i[n].push(t) : i[n] = [t];
|
|
148
|
-
}
|
|
149
|
-
if (e) for (const n of i) n.sort(e);
|
|
150
|
-
return i;
|
|
151
|
-
}(o);
|
|
152
|
-
n = Math.min(x, (p - k) / (t.max(r, n => n.length) - 1)), function (e) {
|
|
153
|
-
const o = t.min(e, e => (p - k - (e.length - 1) * n) / t.sum(e, c));
|
|
154
|
-
for (const t of e) {
|
|
155
|
-
let e = k;
|
|
156
|
-
for (const r of t) {
|
|
157
|
-
r.y0 = e, r.y1 = e + r.value * o, e = r.y1 + n;
|
|
158
|
-
for (const n of r.sourceLinks) n.width = n.value * o;
|
|
159
|
-
}
|
|
160
|
-
e = (p - e + n) / (t.length + 1);
|
|
161
|
-
for (let n = 0; n < t.length; ++n) {
|
|
162
|
-
const o = t[n];
|
|
163
|
-
o.y0 += e * (n + 1), o.y1 += e * (n + 1);
|
|
164
|
-
}
|
|
165
|
-
V(t);
|
|
166
|
-
}
|
|
167
|
-
}(r);
|
|
168
|
-
for (let n = 0; n < S; ++n) {
|
|
169
|
-
const t = Math.pow(.99, n),
|
|
170
|
-
e = Math.max(1 - t, (n + 1) / S);
|
|
171
|
-
E(r, t, e), j(r, t, e);
|
|
172
|
-
}
|
|
173
|
-
}(r), g(r), r;
|
|
174
|
-
}
|
|
175
|
-
function j(n, t, o) {
|
|
176
|
-
for (let r = 1, i = n.length; r < i; ++r) {
|
|
177
|
-
const i = n[r];
|
|
178
|
-
for (const n of i) {
|
|
179
|
-
let e = 0,
|
|
180
|
-
o = 0;
|
|
181
|
-
for (const {
|
|
182
|
-
source: t,
|
|
183
|
-
value: r
|
|
184
|
-
} of n.targetLinks) {
|
|
185
|
-
let i = r * (n.layer - t.layer);
|
|
186
|
-
e += _(t, n) * i, o += i;
|
|
187
|
-
}
|
|
188
|
-
if (!(o > 0)) continue;
|
|
189
|
-
let r = (e / o - n.y0) * t;
|
|
190
|
-
n.y0 += r, n.y1 += r, P(n);
|
|
191
|
-
}
|
|
192
|
-
void 0 === e && i.sort(u), q(i, o);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function E(n, t, o) {
|
|
196
|
-
for (let r = n.length - 2; r >= 0; --r) {
|
|
197
|
-
const i = n[r];
|
|
198
|
-
for (const n of i) {
|
|
199
|
-
let e = 0,
|
|
200
|
-
o = 0;
|
|
201
|
-
for (const {
|
|
202
|
-
target: t,
|
|
203
|
-
value: r
|
|
204
|
-
} of n.sourceLinks) {
|
|
205
|
-
let i = r * (t.layer - n.layer);
|
|
206
|
-
e += C(n, t) * i, o += i;
|
|
207
|
-
}
|
|
208
|
-
if (!(o > 0)) continue;
|
|
209
|
-
let r = (e / o - n.y0) * t;
|
|
210
|
-
n.y0 += r, n.y1 += r, P(n);
|
|
211
|
-
}
|
|
212
|
-
void 0 === e && i.sort(u), q(i, o);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function q(t, e) {
|
|
216
|
-
const o = t.length >> 1,
|
|
217
|
-
r = t[o];
|
|
218
|
-
H(t, r.y0 - n, o - 1, e), A(t, r.y1 + n, o + 1, e), H(t, p, t.length - 1, e), A(t, k, 0, e);
|
|
219
|
-
}
|
|
220
|
-
function A(t, e, o, r) {
|
|
221
|
-
for (; o < t.length; ++o) {
|
|
222
|
-
const i = t[o],
|
|
223
|
-
s = (e - i.y0) * r;
|
|
224
|
-
s > 1e-6 && (i.y0 += s, i.y1 += s), e = i.y1 + n;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function H(t, e, o, r) {
|
|
228
|
-
for (; o >= 0; --o) {
|
|
229
|
-
const i = t[o],
|
|
230
|
-
s = (i.y1 - e) * r;
|
|
231
|
-
s > 1e-6 && (i.y0 -= s, i.y1 -= s), e = i.y0 - n;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function P({
|
|
235
|
-
sourceLinks: n,
|
|
236
|
-
targetLinks: t
|
|
237
|
-
}) {
|
|
238
|
-
if (void 0 === o) {
|
|
239
|
-
for (const {
|
|
240
|
-
source: {
|
|
241
|
-
sourceLinks: n
|
|
242
|
-
}
|
|
243
|
-
} of t) n.sort(f);
|
|
244
|
-
for (const {
|
|
245
|
-
target: {
|
|
246
|
-
targetLinks: t
|
|
247
|
-
}
|
|
248
|
-
} of n) t.sort(s);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function V(n) {
|
|
252
|
-
if (void 0 === o) for (const {
|
|
253
|
-
sourceLinks: t,
|
|
254
|
-
targetLinks: e
|
|
255
|
-
} of n) t.sort(f), e.sort(s);
|
|
256
|
-
}
|
|
257
|
-
function _(t, e) {
|
|
258
|
-
let o = t.y0 - (t.sourceLinks.length - 1) * n / 2;
|
|
259
|
-
for (const {
|
|
260
|
-
target: r,
|
|
261
|
-
width: i
|
|
262
|
-
} of t.sourceLinks) {
|
|
263
|
-
if (r === e) break;
|
|
264
|
-
o += i + n;
|
|
265
|
-
}
|
|
266
|
-
for (const {
|
|
267
|
-
source: n,
|
|
268
|
-
width: r
|
|
269
|
-
} of e.targetLinks) {
|
|
270
|
-
if (n === t) break;
|
|
271
|
-
o -= r;
|
|
272
|
-
}
|
|
273
|
-
return o;
|
|
274
|
-
}
|
|
275
|
-
function C(t, e) {
|
|
276
|
-
let o = e.y0 - (e.targetLinks.length - 1) * n / 2;
|
|
277
|
-
for (const {
|
|
278
|
-
source: r,
|
|
279
|
-
width: i
|
|
280
|
-
} of e.targetLinks) {
|
|
281
|
-
if (r === t) break;
|
|
282
|
-
o += i + n;
|
|
283
|
-
}
|
|
284
|
-
for (const {
|
|
285
|
-
target: n,
|
|
286
|
-
width: r
|
|
287
|
-
} of t.sourceLinks) {
|
|
288
|
-
if (n === e) break;
|
|
289
|
-
o -= r;
|
|
290
|
-
}
|
|
291
|
-
return o;
|
|
292
|
-
}
|
|
293
|
-
return z.update = function (n) {
|
|
294
|
-
return g(n), n;
|
|
295
|
-
}, z.nodeId = function (n) {
|
|
296
|
-
return arguments.length ? (m = "function" == typeof n ? n : i(n), z) : m;
|
|
297
|
-
}, z.nodeAlign = function (n) {
|
|
298
|
-
return arguments.length ? (v = "function" == typeof n ? n : i(n), z) : v;
|
|
299
|
-
}, z.nodeSort = function (n) {
|
|
300
|
-
return arguments.length ? (e = n, z) : e;
|
|
301
|
-
}, z.nodeWidth = function (n) {
|
|
302
|
-
return arguments.length ? (w = +n, z) : w;
|
|
303
|
-
}, z.nodePadding = function (t) {
|
|
304
|
-
return arguments.length ? (x = n = +t, z) : x;
|
|
305
|
-
}, z.nodes = function (n) {
|
|
306
|
-
return arguments.length ? (M = "function" == typeof n ? n : i(n), z) : M;
|
|
307
|
-
}, z.links = function (n) {
|
|
308
|
-
return arguments.length ? (b = "function" == typeof n ? n : i(n), z) : b;
|
|
309
|
-
}, z.linkSort = function (n) {
|
|
310
|
-
return arguments.length ? (o = n, z) : o;
|
|
311
|
-
}, z.size = function (n) {
|
|
312
|
-
return arguments.length ? (y = k = 0, L = +n[0], p = +n[1], z) : [L - y, p - k];
|
|
313
|
-
}, z.extent = function (n) {
|
|
314
|
-
return arguments.length ? (y = +n[0][0], L = +n[1][0], k = +n[0][1], p = +n[1][1], z) : [[y, k], [L, p]];
|
|
315
|
-
}, z.iterations = function (n) {
|
|
316
|
-
return arguments.length ? (S = +n, z) : S;
|
|
317
|
-
}, z;
|
|
318
|
-
}, n.sankeyCenter = function (n) {
|
|
319
|
-
return n.targetLinks.length ? n.depth : n.sourceLinks.length ? t.min(n.sourceLinks, o) - 1 : 0;
|
|
320
|
-
}, n.sankeyJustify = r, n.sankeyLeft = function (n) {
|
|
321
|
-
return n.depth;
|
|
322
|
-
}, n.sankeyLinkHorizontal = function () {
|
|
323
|
-
return e.linkHorizontal().source(y).target(k);
|
|
324
|
-
}, n.sankeyRight = function (n, t) {
|
|
325
|
-
return t - 1 - n.height;
|
|
326
|
-
}, Object.defineProperty(n, "__esModule", {
|
|
327
|
-
value: !0
|
|
328
|
-
});
|
|
329
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.center = center;
|
|
7
|
-
exports.justify = justify;
|
|
8
|
-
exports.left = left;
|
|
9
|
-
exports.right = right;
|
|
10
|
-
var _index = require("../../../lib-vendor/d3-array/src/index.js");
|
|
11
|
-
function targetDepth(d) {
|
|
12
|
-
return d.target.depth;
|
|
13
|
-
}
|
|
14
|
-
function left(node) {
|
|
15
|
-
return node.depth;
|
|
16
|
-
}
|
|
17
|
-
function right(node, n) {
|
|
18
|
-
return n - 1 - node.height;
|
|
19
|
-
}
|
|
20
|
-
function justify(node, n) {
|
|
21
|
-
return node.sourceLinks.length ? node.depth : n - 1;
|
|
22
|
-
}
|
|
23
|
-
function center(node) {
|
|
24
|
-
return node.targetLinks.length ? node.depth : node.sourceLinks.length ? (0, _index.min)(node.sourceLinks, targetDepth) - 1 : 0;
|
|
25
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "sankey", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _sankey.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "sankeyCenter", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _align.center;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "sankeyJustify", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _align.justify;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "sankeyLeft", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _align.left;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "sankeyLinkHorizontal", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _sankeyLinkHorizontal.default;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "sankeyRight", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return _align.right;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
var _sankey = _interopRequireDefault(require("./sankey.js"));
|
|
44
|
-
var _align = require("./align.js");
|
|
45
|
-
var _sankeyLinkHorizontal = _interopRequireDefault(require("./sankeyLinkHorizontal.js"));
|
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = Sankey;
|
|
8
|
-
var _index = require("../../../lib-vendor/d3-array/src/index.js");
|
|
9
|
-
var _align = require("./align.js");
|
|
10
|
-
var _constant = _interopRequireDefault(require("./constant.js"));
|
|
11
|
-
function ascendingSourceBreadth(a, b) {
|
|
12
|
-
return ascendingBreadth(a.source, b.source) || a.index - b.index;
|
|
13
|
-
}
|
|
14
|
-
function ascendingTargetBreadth(a, b) {
|
|
15
|
-
return ascendingBreadth(a.target, b.target) || a.index - b.index;
|
|
16
|
-
}
|
|
17
|
-
function ascendingBreadth(a, b) {
|
|
18
|
-
return a.y0 - b.y0;
|
|
19
|
-
}
|
|
20
|
-
function value(d) {
|
|
21
|
-
return d.value;
|
|
22
|
-
}
|
|
23
|
-
function defaultId(d) {
|
|
24
|
-
return d.index;
|
|
25
|
-
}
|
|
26
|
-
function defaultNodes(graph) {
|
|
27
|
-
return graph.nodes;
|
|
28
|
-
}
|
|
29
|
-
function defaultLinks(graph) {
|
|
30
|
-
return graph.links;
|
|
31
|
-
}
|
|
32
|
-
function find(nodeById, id) {
|
|
33
|
-
const node = nodeById.get(id);
|
|
34
|
-
if (!node) throw new Error("missing: " + id);
|
|
35
|
-
return node;
|
|
36
|
-
}
|
|
37
|
-
function computeLinkBreadths({
|
|
38
|
-
nodes
|
|
39
|
-
}) {
|
|
40
|
-
for (const node of nodes) {
|
|
41
|
-
let y0 = node.y0;
|
|
42
|
-
let y1 = y0;
|
|
43
|
-
for (const link of node.sourceLinks) {
|
|
44
|
-
link.y0 = y0 + link.width / 2;
|
|
45
|
-
y0 += link.width;
|
|
46
|
-
}
|
|
47
|
-
for (const link of node.targetLinks) {
|
|
48
|
-
link.y1 = y1 + link.width / 2;
|
|
49
|
-
y1 += link.width;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function Sankey() {
|
|
54
|
-
let x0 = 0,
|
|
55
|
-
y0 = 0,
|
|
56
|
-
x1 = 1,
|
|
57
|
-
y1 = 1; // extent
|
|
58
|
-
let dx = 24; // nodeWidth
|
|
59
|
-
let dy = 8,
|
|
60
|
-
py; // nodePadding
|
|
61
|
-
let id = defaultId;
|
|
62
|
-
let align = _align.justify;
|
|
63
|
-
let sort;
|
|
64
|
-
let linkSort;
|
|
65
|
-
let nodes = defaultNodes;
|
|
66
|
-
let links = defaultLinks;
|
|
67
|
-
let iterations = 6;
|
|
68
|
-
function sankey() {
|
|
69
|
-
const graph = {
|
|
70
|
-
nodes: nodes.apply(null, arguments),
|
|
71
|
-
links: links.apply(null, arguments)
|
|
72
|
-
};
|
|
73
|
-
computeNodeLinks(graph);
|
|
74
|
-
computeNodeValues(graph);
|
|
75
|
-
computeNodeDepths(graph);
|
|
76
|
-
computeNodeHeights(graph);
|
|
77
|
-
computeNodeBreadths(graph);
|
|
78
|
-
computeLinkBreadths(graph);
|
|
79
|
-
return graph;
|
|
80
|
-
}
|
|
81
|
-
sankey.update = function (graph) {
|
|
82
|
-
computeLinkBreadths(graph);
|
|
83
|
-
return graph;
|
|
84
|
-
};
|
|
85
|
-
sankey.nodeId = function (_) {
|
|
86
|
-
return arguments.length ? (id = typeof _ === "function" ? _ : (0, _constant.default)(_), sankey) : id;
|
|
87
|
-
};
|
|
88
|
-
sankey.nodeAlign = function (_) {
|
|
89
|
-
return arguments.length ? (align = typeof _ === "function" ? _ : (0, _constant.default)(_), sankey) : align;
|
|
90
|
-
};
|
|
91
|
-
sankey.nodeSort = function (_) {
|
|
92
|
-
return arguments.length ? (sort = _, sankey) : sort;
|
|
93
|
-
};
|
|
94
|
-
sankey.nodeWidth = function (_) {
|
|
95
|
-
return arguments.length ? (dx = +_, sankey) : dx;
|
|
96
|
-
};
|
|
97
|
-
sankey.nodePadding = function (_) {
|
|
98
|
-
return arguments.length ? (dy = py = +_, sankey) : dy;
|
|
99
|
-
};
|
|
100
|
-
sankey.nodes = function (_) {
|
|
101
|
-
return arguments.length ? (nodes = typeof _ === "function" ? _ : (0, _constant.default)(_), sankey) : nodes;
|
|
102
|
-
};
|
|
103
|
-
sankey.links = function (_) {
|
|
104
|
-
return arguments.length ? (links = typeof _ === "function" ? _ : (0, _constant.default)(_), sankey) : links;
|
|
105
|
-
};
|
|
106
|
-
sankey.linkSort = function (_) {
|
|
107
|
-
return arguments.length ? (linkSort = _, sankey) : linkSort;
|
|
108
|
-
};
|
|
109
|
-
sankey.size = function (_) {
|
|
110
|
-
return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];
|
|
111
|
-
};
|
|
112
|
-
sankey.extent = function (_) {
|
|
113
|
-
return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];
|
|
114
|
-
};
|
|
115
|
-
sankey.iterations = function (_) {
|
|
116
|
-
return arguments.length ? (iterations = +_, sankey) : iterations;
|
|
117
|
-
};
|
|
118
|
-
function computeNodeLinks({
|
|
119
|
-
nodes,
|
|
120
|
-
links
|
|
121
|
-
}) {
|
|
122
|
-
for (const [i, node] of nodes.entries()) {
|
|
123
|
-
node.index = i;
|
|
124
|
-
node.sourceLinks = [];
|
|
125
|
-
node.targetLinks = [];
|
|
126
|
-
}
|
|
127
|
-
const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d]));
|
|
128
|
-
for (const [i, link] of links.entries()) {
|
|
129
|
-
link.index = i;
|
|
130
|
-
let {
|
|
131
|
-
source,
|
|
132
|
-
target
|
|
133
|
-
} = link;
|
|
134
|
-
if (typeof source !== "object") source = link.source = find(nodeById, source);
|
|
135
|
-
if (typeof target !== "object") target = link.target = find(nodeById, target);
|
|
136
|
-
source.sourceLinks.push(link);
|
|
137
|
-
target.targetLinks.push(link);
|
|
138
|
-
}
|
|
139
|
-
if (linkSort != null) {
|
|
140
|
-
for (const {
|
|
141
|
-
sourceLinks,
|
|
142
|
-
targetLinks
|
|
143
|
-
} of nodes) {
|
|
144
|
-
sourceLinks.sort(linkSort);
|
|
145
|
-
targetLinks.sort(linkSort);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function computeNodeValues({
|
|
150
|
-
nodes
|
|
151
|
-
}) {
|
|
152
|
-
for (const node of nodes) {
|
|
153
|
-
node.value = node.fixedValue === undefined ? Math.max((0, _index.sum)(node.sourceLinks, value), (0, _index.sum)(node.targetLinks, value)) : node.fixedValue;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function computeNodeDepths({
|
|
157
|
-
nodes
|
|
158
|
-
}) {
|
|
159
|
-
const n = nodes.length;
|
|
160
|
-
let current = new Set(nodes);
|
|
161
|
-
let next = new Set();
|
|
162
|
-
let x = 0;
|
|
163
|
-
while (current.size) {
|
|
164
|
-
for (const node of current) {
|
|
165
|
-
node.depth = x;
|
|
166
|
-
for (const {
|
|
167
|
-
target
|
|
168
|
-
} of node.sourceLinks) {
|
|
169
|
-
next.add(target);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (++x > n) throw new Error("circular link");
|
|
173
|
-
current = next;
|
|
174
|
-
next = new Set();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function computeNodeHeights({
|
|
178
|
-
nodes
|
|
179
|
-
}) {
|
|
180
|
-
const n = nodes.length;
|
|
181
|
-
let current = new Set(nodes);
|
|
182
|
-
let next = new Set();
|
|
183
|
-
let x = 0;
|
|
184
|
-
while (current.size) {
|
|
185
|
-
for (const node of current) {
|
|
186
|
-
node.height = x;
|
|
187
|
-
for (const {
|
|
188
|
-
source
|
|
189
|
-
} of node.targetLinks) {
|
|
190
|
-
next.add(source);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (++x > n) throw new Error("circular link");
|
|
194
|
-
current = next;
|
|
195
|
-
next = new Set();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function computeNodeLayers({
|
|
199
|
-
nodes
|
|
200
|
-
}) {
|
|
201
|
-
const x = (0, _index.max)(nodes, d => d.depth) + 1;
|
|
202
|
-
const kx = (x1 - x0 - dx) / (x - 1);
|
|
203
|
-
const columns = new Array(x);
|
|
204
|
-
for (const node of nodes) {
|
|
205
|
-
const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));
|
|
206
|
-
node.layer = i;
|
|
207
|
-
node.x0 = x0 + i * kx;
|
|
208
|
-
node.x1 = node.x0 + dx;
|
|
209
|
-
if (columns[i]) columns[i].push(node);else columns[i] = [node];
|
|
210
|
-
}
|
|
211
|
-
if (sort) for (const column of columns) {
|
|
212
|
-
column.sort(sort);
|
|
213
|
-
}
|
|
214
|
-
return columns;
|
|
215
|
-
}
|
|
216
|
-
function initializeNodeBreadths(columns) {
|
|
217
|
-
const ky = (0, _index.min)(columns, c => (y1 - y0 - (c.length - 1) * py) / (0, _index.sum)(c, value));
|
|
218
|
-
for (const nodes of columns) {
|
|
219
|
-
let y = y0;
|
|
220
|
-
for (const node of nodes) {
|
|
221
|
-
node.y0 = y;
|
|
222
|
-
node.y1 = y + node.value * ky;
|
|
223
|
-
y = node.y1 + py;
|
|
224
|
-
for (const link of node.sourceLinks) {
|
|
225
|
-
link.width = link.value * ky;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
y = (y1 - y + py) / (nodes.length + 1);
|
|
229
|
-
for (let i = 0; i < nodes.length; ++i) {
|
|
230
|
-
const node = nodes[i];
|
|
231
|
-
node.y0 += y * (i + 1);
|
|
232
|
-
node.y1 += y * (i + 1);
|
|
233
|
-
}
|
|
234
|
-
reorderLinks(nodes);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
function computeNodeBreadths(graph) {
|
|
238
|
-
const columns = computeNodeLayers(graph);
|
|
239
|
-
py = Math.min(dy, (y1 - y0) / ((0, _index.max)(columns, c => c.length) - 1));
|
|
240
|
-
initializeNodeBreadths(columns);
|
|
241
|
-
for (let i = 0; i < iterations; ++i) {
|
|
242
|
-
const alpha = Math.pow(0.99, i);
|
|
243
|
-
const beta = Math.max(1 - alpha, (i + 1) / iterations);
|
|
244
|
-
relaxRightToLeft(columns, alpha, beta);
|
|
245
|
-
relaxLeftToRight(columns, alpha, beta);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Reposition each node based on its incoming (target) links.
|
|
250
|
-
function relaxLeftToRight(columns, alpha, beta) {
|
|
251
|
-
for (let i = 1, n = columns.length; i < n; ++i) {
|
|
252
|
-
const column = columns[i];
|
|
253
|
-
for (const target of column) {
|
|
254
|
-
let y = 0;
|
|
255
|
-
let w = 0;
|
|
256
|
-
for (const {
|
|
257
|
-
source,
|
|
258
|
-
value
|
|
259
|
-
} of target.targetLinks) {
|
|
260
|
-
let v = value * (target.layer - source.layer);
|
|
261
|
-
y += targetTop(source, target) * v;
|
|
262
|
-
w += v;
|
|
263
|
-
}
|
|
264
|
-
if (!(w > 0)) continue;
|
|
265
|
-
let dy = (y / w - target.y0) * alpha;
|
|
266
|
-
target.y0 += dy;
|
|
267
|
-
target.y1 += dy;
|
|
268
|
-
reorderNodeLinks(target);
|
|
269
|
-
}
|
|
270
|
-
if (sort === undefined) column.sort(ascendingBreadth);
|
|
271
|
-
resolveCollisions(column, beta);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Reposition each node based on its outgoing (source) links.
|
|
276
|
-
function relaxRightToLeft(columns, alpha, beta) {
|
|
277
|
-
for (let n = columns.length, i = n - 2; i >= 0; --i) {
|
|
278
|
-
const column = columns[i];
|
|
279
|
-
for (const source of column) {
|
|
280
|
-
let y = 0;
|
|
281
|
-
let w = 0;
|
|
282
|
-
for (const {
|
|
283
|
-
target,
|
|
284
|
-
value
|
|
285
|
-
} of source.sourceLinks) {
|
|
286
|
-
let v = value * (target.layer - source.layer);
|
|
287
|
-
y += sourceTop(source, target) * v;
|
|
288
|
-
w += v;
|
|
289
|
-
}
|
|
290
|
-
if (!(w > 0)) continue;
|
|
291
|
-
let dy = (y / w - source.y0) * alpha;
|
|
292
|
-
source.y0 += dy;
|
|
293
|
-
source.y1 += dy;
|
|
294
|
-
reorderNodeLinks(source);
|
|
295
|
-
}
|
|
296
|
-
if (sort === undefined) column.sort(ascendingBreadth);
|
|
297
|
-
resolveCollisions(column, beta);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function resolveCollisions(nodes, alpha) {
|
|
301
|
-
const i = nodes.length >> 1;
|
|
302
|
-
const subject = nodes[i];
|
|
303
|
-
resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha);
|
|
304
|
-
resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha);
|
|
305
|
-
resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha);
|
|
306
|
-
resolveCollisionsTopToBottom(nodes, y0, 0, alpha);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Push any overlapping nodes down.
|
|
310
|
-
function resolveCollisionsTopToBottom(nodes, y, i, alpha) {
|
|
311
|
-
for (; i < nodes.length; ++i) {
|
|
312
|
-
const node = nodes[i];
|
|
313
|
-
const dy = (y - node.y0) * alpha;
|
|
314
|
-
if (dy > 1e-6) node.y0 += dy, node.y1 += dy;
|
|
315
|
-
y = node.y1 + py;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Push any overlapping nodes up.
|
|
320
|
-
function resolveCollisionsBottomToTop(nodes, y, i, alpha) {
|
|
321
|
-
for (; i >= 0; --i) {
|
|
322
|
-
const node = nodes[i];
|
|
323
|
-
const dy = (node.y1 - y) * alpha;
|
|
324
|
-
if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy;
|
|
325
|
-
y = node.y0 - py;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function reorderNodeLinks({
|
|
329
|
-
sourceLinks,
|
|
330
|
-
targetLinks
|
|
331
|
-
}) {
|
|
332
|
-
if (linkSort === undefined) {
|
|
333
|
-
for (const {
|
|
334
|
-
source: {
|
|
335
|
-
sourceLinks
|
|
336
|
-
}
|
|
337
|
-
} of targetLinks) {
|
|
338
|
-
sourceLinks.sort(ascendingTargetBreadth);
|
|
339
|
-
}
|
|
340
|
-
for (const {
|
|
341
|
-
target: {
|
|
342
|
-
targetLinks
|
|
343
|
-
}
|
|
344
|
-
} of sourceLinks) {
|
|
345
|
-
targetLinks.sort(ascendingSourceBreadth);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
function reorderLinks(nodes) {
|
|
350
|
-
if (linkSort === undefined) {
|
|
351
|
-
for (const {
|
|
352
|
-
sourceLinks,
|
|
353
|
-
targetLinks
|
|
354
|
-
} of nodes) {
|
|
355
|
-
sourceLinks.sort(ascendingTargetBreadth);
|
|
356
|
-
targetLinks.sort(ascendingSourceBreadth);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// Returns the target.y0 that would produce an ideal link from source to target.
|
|
362
|
-
function targetTop(source, target) {
|
|
363
|
-
let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;
|
|
364
|
-
for (const {
|
|
365
|
-
target: node,
|
|
366
|
-
width
|
|
367
|
-
} of source.sourceLinks) {
|
|
368
|
-
if (node === target) break;
|
|
369
|
-
y += width + py;
|
|
370
|
-
}
|
|
371
|
-
for (const {
|
|
372
|
-
source: node,
|
|
373
|
-
width
|
|
374
|
-
} of target.targetLinks) {
|
|
375
|
-
if (node === source) break;
|
|
376
|
-
y -= width;
|
|
377
|
-
}
|
|
378
|
-
return y;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Returns the source.y0 that would produce an ideal link from source to target.
|
|
382
|
-
function sourceTop(source, target) {
|
|
383
|
-
let y = target.y0 - (target.targetLinks.length - 1) * py / 2;
|
|
384
|
-
for (const {
|
|
385
|
-
source: node,
|
|
386
|
-
width
|
|
387
|
-
} of target.targetLinks) {
|
|
388
|
-
if (node === source) break;
|
|
389
|
-
y += width + py;
|
|
390
|
-
}
|
|
391
|
-
for (const {
|
|
392
|
-
target: node,
|
|
393
|
-
width
|
|
394
|
-
} of source.sourceLinks) {
|
|
395
|
-
if (node === target) break;
|
|
396
|
-
y -= width;
|
|
397
|
-
}
|
|
398
|
-
return y;
|
|
399
|
-
}
|
|
400
|
-
return sankey;
|
|
401
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
var _index = require("../../../lib-vendor/d3-shape/src/index.js");
|
|
8
|
-
function horizontalSource(d) {
|
|
9
|
-
return [d.source.x1, d.y0];
|
|
10
|
-
}
|
|
11
|
-
function horizontalTarget(d) {
|
|
12
|
-
return [d.target.x0, d.y1];
|
|
13
|
-
}
|
|
14
|
-
function _default() {
|
|
15
|
-
return (0, _index.linkHorizontal)().source(horizontalSource).target(horizontalTarget);
|
|
16
|
-
}
|