@mui/x-charts-vendor 8.19.0 → 8.22.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 ADDED
@@ -0,0 +1,5 @@
1
+
2
+ // `x-charts-vendor/d3-path` (TypeScript)
3
+ //
4
+ // Export the type definitions for this package:
5
+ export * from "d3-path";
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
@@ -1,5 +0,0 @@
1
-
2
- // `x-charts-vendor/d3-sankey` (TypeScript)
3
- //
4
- // Export the type definitions for this package:
5
- export * from "d3-sankey";
@@ -0,0 +1,8 @@
1
+
2
+ // `x-charts-vendor/flatqueue` (ESM)
3
+ // See upstream license: git+https://github.com/mourner/flatqueue/blob/main/LICENSE
4
+ //
5
+ // Our ESM package uses the underlying installed dependencies of `node_modules/flatqueue`
6
+ export * from "flatqueue";
7
+
8
+ export { default } from "flatqueue";
@@ -0,0 +1,6 @@
1
+
2
+ // `x-charts-vendor/flatqueue` (CommonJS)
3
+ // See upstream license: git+https://github.com/mourner/flatqueue/blob/main/LICENSE
4
+ //
5
+ // Our CommonJS package relies on transpiled vendor files in `lib-vendor/flatqueue`
6
+ module.exports = require("../lib-vendor/flatqueue/index.js");
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025, Volodymyr Agafonkin
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose
6
+ with or without fee is hereby granted, provided that the above copyright notice
7
+ and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
13
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
15
+ THIS SOFTWARE.
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /** @template T */
8
+ class FlatQueue {
9
+ constructor() {
10
+ /** @type T[] */
11
+ this.ids = [];
12
+
13
+ /** @type number[] */
14
+ this.values = [];
15
+
16
+ /** Number of items in the queue. */
17
+ this.length = 0;
18
+ }
19
+
20
+ /** Removes all items from the queue. */
21
+ clear() {
22
+ this.length = 0;
23
+ }
24
+
25
+ /**
26
+ * Adds `item` to the queue with the specified `priority`.
27
+ *
28
+ * `priority` must be a number. Items are sorted and returned from low to high priority. Multiple items
29
+ * with the same priority value can be added to the queue, but there is no guaranteed order between these items.
30
+ *
31
+ * @param {T} item
32
+ * @param {number} priority
33
+ */
34
+ push(item, priority) {
35
+ let pos = this.length++;
36
+ while (pos > 0) {
37
+ const parent = pos - 1 >> 1;
38
+ const parentValue = this.values[parent];
39
+ if (priority >= parentValue) break;
40
+ this.ids[pos] = this.ids[parent];
41
+ this.values[pos] = parentValue;
42
+ pos = parent;
43
+ }
44
+ this.ids[pos] = item;
45
+ this.values[pos] = priority;
46
+ }
47
+
48
+ /**
49
+ * Removes and returns the item from the head of this queue, which is one of
50
+ * the items with the lowest priority. If this queue is empty, returns `undefined`.
51
+ */
52
+ pop() {
53
+ if (this.length === 0) return undefined;
54
+ const ids = this.ids,
55
+ values = this.values,
56
+ top = ids[0],
57
+ last = --this.length;
58
+ if (last > 0) {
59
+ const id = ids[last];
60
+ const value = values[last];
61
+ let pos = 0;
62
+ const halfLen = last >> 1;
63
+ while (pos < halfLen) {
64
+ const left = (pos << 1) + 1;
65
+ const right = left + 1;
66
+ const child = left + (+(right < last) & +(values[right] < values[left]));
67
+ if (values[child] >= value) break;
68
+ ids[pos] = ids[child];
69
+ values[pos] = values[child];
70
+ pos = child;
71
+ }
72
+ ids[pos] = id;
73
+ values[pos] = value;
74
+ }
75
+ return top;
76
+ }
77
+
78
+ /** Returns the item from the head of this queue without removing it. If this queue is empty, returns `undefined`. */
79
+ peek() {
80
+ return this.length > 0 ? this.ids[0] : undefined;
81
+ }
82
+
83
+ /**
84
+ * Returns the priority value of the item at the head of this queue without
85
+ * removing it. If this queue is empty, returns `undefined`.
86
+ */
87
+ peekValue() {
88
+ return this.length > 0 ? this.values[0] : undefined;
89
+ }
90
+
91
+ /**
92
+ * Shrinks the internal arrays to `this.length`.
93
+ *
94
+ * `pop()` and `clear()` calls don't free memory automatically to avoid unnecessary resize operations.
95
+ * This also means that items that have been added to the queue can't be garbage collected until
96
+ * a new item is pushed in their place, or this method is called.
97
+ */
98
+ shrink() {
99
+ this.ids.length = this.values.length = this.length;
100
+ }
101
+ }
102
+ exports.default = FlatQueue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts-vendor",
3
- "version": "8.19.0",
3
+ "version": "8.22.0",
4
4
  "author": "MUI Team",
5
5
  "description": "Vendored dependencies for MUI X Charts.",
6
6
  "keywords": [
@@ -27,34 +27,34 @@
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.4",
30
+ "@types/d3-path": "^3.1.1",
31
+ "@types/d3-sankey": "^0.12.5",
31
32
  "@types/d3-scale": "^4.0.9",
32
33
  "@types/d3-shape": "^3.1.7",
33
34
  "@types/d3-time": "^3.0.4",
34
35
  "@types/d3-timer": "^3.0.2",
35
36
  "d3-color": "^3.1.0",
36
37
  "d3-interpolate": "^3.0.1",
37
- "d3-sankey": "^0.12.3",
38
+ "d3-path": "^3.1.0",
38
39
  "d3-scale": "^4.0.2",
39
40
  "d3-shape": "^3.2.0",
40
41
  "d3-time": "^3.1.0",
41
- "d3-timer": "^3.0.1"
42
+ "d3-timer": "^3.0.1",
43
+ "flatqueue": "^3.0.0"
42
44
  },
43
45
  "devDependencies": {
44
46
  "@babel/cli": "^7.28.3",
45
47
  "@babel/plugin-transform-runtime": "^7.28.5",
46
48
  "@types/d3-array": "^3.2.2",
47
49
  "@types/d3-format": "^3.0.4",
48
- "@types/d3-path": "^3.1.1",
49
50
  "@types/d3-time-format": "^4.0.3",
50
51
  "babel-plugin-module-resolver": "^5.0.2",
51
52
  "d3-array": "^3.2.4",
52
53
  "d3-format": "^3.1.0",
53
- "d3-path": "^3.1.0",
54
54
  "d3-time-format": "^4.1.0",
55
55
  "execa": "^9.6.0",
56
56
  "internmap": "^2.0.3",
57
- "rimraf": "^6.1.0"
57
+ "rimraf": "^6.1.2"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
package/es/d3-sankey.mjs DELETED
@@ -1,6 +0,0 @@
1
-
2
- // `x-charts-vendor/d3-sankey` (ESM)
3
- // See upstream license: https://github.com/d3/d3-sankey/blob/main/LICENSE
4
- //
5
- // Our ESM package uses the underlying installed dependencies of `node_modules/d3-sankey`
6
- export * from "d3-sankey";
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
- });