polly-graph 0.2.2 → 0.2.4
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/dist/index.cjs +351 -233
- package/dist/index.css +2 -0
- package/dist/index.d.cts +18 -19
- package/dist/index.d.ts +18 -19
- package/dist/index.js +351 -233
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -437,14 +437,14 @@ var CanvasUtils = {
|
|
|
437
437
|
/**
|
|
438
438
|
* Safe image data extraction
|
|
439
439
|
*/
|
|
440
|
-
getPixelData(ctx,
|
|
440
|
+
getPixelData(ctx, x3, y3, pixelRatio = window.devicePixelRatio || 1) {
|
|
441
441
|
try {
|
|
442
|
-
if (
|
|
442
|
+
if (x3 <= 0 || y3 <= 0) {
|
|
443
443
|
return null;
|
|
444
444
|
}
|
|
445
445
|
const imageData = ctx.getImageData(
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
x3 * pixelRatio,
|
|
447
|
+
y3 * pixelRatio,
|
|
448
448
|
1,
|
|
449
449
|
1
|
|
450
450
|
);
|
|
@@ -454,8 +454,8 @@ var CanvasUtils = {
|
|
|
454
454
|
return null;
|
|
455
455
|
}
|
|
456
456
|
ErrorHandler.logError(error, {
|
|
457
|
-
x:
|
|
458
|
-
y:
|
|
457
|
+
x: x3,
|
|
458
|
+
y: y3,
|
|
459
459
|
pixelRatio
|
|
460
460
|
});
|
|
461
461
|
return null;
|
|
@@ -1184,16 +1184,16 @@ var CanvasManager = class {
|
|
|
1184
1184
|
};
|
|
1185
1185
|
|
|
1186
1186
|
// node_modules/d3-force/src/center.js
|
|
1187
|
-
function center_default(
|
|
1187
|
+
function center_default(x3, y3) {
|
|
1188
1188
|
var nodes, strength = 1;
|
|
1189
|
-
if (
|
|
1190
|
-
if (
|
|
1189
|
+
if (x3 == null) x3 = 0;
|
|
1190
|
+
if (y3 == null) y3 = 0;
|
|
1191
1191
|
function force() {
|
|
1192
1192
|
var i, n = nodes.length, node, sx = 0, sy = 0;
|
|
1193
1193
|
for (i = 0; i < n; ++i) {
|
|
1194
1194
|
node = nodes[i], sx += node.x, sy += node.y;
|
|
1195
1195
|
}
|
|
1196
|
-
for (sx = (sx / n -
|
|
1196
|
+
for (sx = (sx / n - x3) * strength, sy = (sy / n - y3) * strength, i = 0; i < n; ++i) {
|
|
1197
1197
|
node = nodes[i], node.x -= sx, node.y -= sy;
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
@@ -1201,10 +1201,10 @@ function center_default(x2, y2) {
|
|
|
1201
1201
|
nodes = _;
|
|
1202
1202
|
};
|
|
1203
1203
|
force.x = function(_) {
|
|
1204
|
-
return arguments.length ? (
|
|
1204
|
+
return arguments.length ? (x3 = +_, force) : x3;
|
|
1205
1205
|
};
|
|
1206
1206
|
force.y = function(_) {
|
|
1207
|
-
return arguments.length ? (
|
|
1207
|
+
return arguments.length ? (y3 = +_, force) : y3;
|
|
1208
1208
|
};
|
|
1209
1209
|
force.strength = function(_) {
|
|
1210
1210
|
return arguments.length ? (strength = +_, force) : strength;
|
|
@@ -1214,42 +1214,42 @@ function center_default(x2, y2) {
|
|
|
1214
1214
|
|
|
1215
1215
|
// node_modules/d3-quadtree/src/add.js
|
|
1216
1216
|
function add_default(d) {
|
|
1217
|
-
const
|
|
1218
|
-
return add(this.cover(
|
|
1217
|
+
const x3 = +this._x.call(null, d), y3 = +this._y.call(null, d);
|
|
1218
|
+
return add(this.cover(x3, y3), x3, y3, d);
|
|
1219
1219
|
}
|
|
1220
|
-
function add(tree,
|
|
1221
|
-
if (isNaN(
|
|
1220
|
+
function add(tree, x3, y3, d) {
|
|
1221
|
+
if (isNaN(x3) || isNaN(y3)) return tree;
|
|
1222
1222
|
var parent, node = tree._root, leaf = { data: d }, x0 = tree._x0, y0 = tree._y0, x1 = tree._x1, y1 = tree._y1, xm, ym, xp, yp, right, bottom, i, j;
|
|
1223
1223
|
if (!node) return tree._root = leaf, tree;
|
|
1224
1224
|
while (node.length) {
|
|
1225
|
-
if (right =
|
|
1225
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
1226
1226
|
else x1 = xm;
|
|
1227
|
-
if (bottom =
|
|
1227
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
1228
1228
|
else y1 = ym;
|
|
1229
1229
|
if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
|
|
1230
1230
|
}
|
|
1231
1231
|
xp = +tree._x.call(null, node.data);
|
|
1232
1232
|
yp = +tree._y.call(null, node.data);
|
|
1233
|
-
if (
|
|
1233
|
+
if (x3 === xp && y3 === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
|
|
1234
1234
|
do {
|
|
1235
1235
|
parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
|
|
1236
|
-
if (right =
|
|
1236
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
1237
1237
|
else x1 = xm;
|
|
1238
|
-
if (bottom =
|
|
1238
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
1239
1239
|
else y1 = ym;
|
|
1240
1240
|
} while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm));
|
|
1241
1241
|
return parent[j] = node, parent[i] = leaf, tree;
|
|
1242
1242
|
}
|
|
1243
1243
|
function addAll(data) {
|
|
1244
|
-
var d, i, n = data.length,
|
|
1244
|
+
var d, i, n = data.length, x3, y3, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
1245
1245
|
for (i = 0; i < n; ++i) {
|
|
1246
|
-
if (isNaN(
|
|
1247
|
-
xz[i] =
|
|
1248
|
-
yz[i] =
|
|
1249
|
-
if (
|
|
1250
|
-
if (
|
|
1251
|
-
if (
|
|
1252
|
-
if (
|
|
1246
|
+
if (isNaN(x3 = +this._x.call(null, d = data[i])) || isNaN(y3 = +this._y.call(null, d))) continue;
|
|
1247
|
+
xz[i] = x3;
|
|
1248
|
+
yz[i] = y3;
|
|
1249
|
+
if (x3 < x0) x0 = x3;
|
|
1250
|
+
if (x3 > x1) x1 = x3;
|
|
1251
|
+
if (y3 < y0) y0 = y3;
|
|
1252
|
+
if (y3 > y1) y1 = y3;
|
|
1253
1253
|
}
|
|
1254
1254
|
if (x0 > x1 || y0 > y1) return this;
|
|
1255
1255
|
this.cover(x0, y0).cover(x1, y1);
|
|
@@ -1260,16 +1260,16 @@ function addAll(data) {
|
|
|
1260
1260
|
}
|
|
1261
1261
|
|
|
1262
1262
|
// node_modules/d3-quadtree/src/cover.js
|
|
1263
|
-
function cover_default(
|
|
1264
|
-
if (isNaN(
|
|
1263
|
+
function cover_default(x3, y3) {
|
|
1264
|
+
if (isNaN(x3 = +x3) || isNaN(y3 = +y3)) return this;
|
|
1265
1265
|
var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1;
|
|
1266
1266
|
if (isNaN(x0)) {
|
|
1267
|
-
x1 = (x0 = Math.floor(
|
|
1268
|
-
y1 = (y0 = Math.floor(
|
|
1267
|
+
x1 = (x0 = Math.floor(x3)) + 1;
|
|
1268
|
+
y1 = (y0 = Math.floor(y3)) + 1;
|
|
1269
1269
|
} else {
|
|
1270
1270
|
var z = x1 - x0 || 1, node = this._root, parent, i;
|
|
1271
|
-
while (x0 >
|
|
1272
|
-
i = (
|
|
1271
|
+
while (x0 > x3 || x3 >= x1 || y0 > y3 || y3 >= y1) {
|
|
1272
|
+
i = (y3 < y0) << 1 | x3 < x0;
|
|
1273
1273
|
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
|
|
1274
1274
|
switch (i) {
|
|
1275
1275
|
case 0:
|
|
@@ -1321,17 +1321,17 @@ function quad_default(node, x0, y0, x1, y1) {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
1323
|
// node_modules/d3-quadtree/src/find.js
|
|
1324
|
-
function find_default(
|
|
1325
|
-
var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22,
|
|
1326
|
-
if (node) quads.push(new quad_default(node, x0, y0,
|
|
1324
|
+
function find_default(x3, y3, radius) {
|
|
1325
|
+
var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22, x32 = this._x1, y32 = this._y1, quads = [], node = this._root, q, i;
|
|
1326
|
+
if (node) quads.push(new quad_default(node, x0, y0, x32, y32));
|
|
1327
1327
|
if (radius == null) radius = Infinity;
|
|
1328
1328
|
else {
|
|
1329
|
-
x0 =
|
|
1330
|
-
|
|
1329
|
+
x0 = x3 - radius, y0 = y3 - radius;
|
|
1330
|
+
x32 = x3 + radius, y32 = y3 + radius;
|
|
1331
1331
|
radius *= radius;
|
|
1332
1332
|
}
|
|
1333
1333
|
while (q = quads.pop()) {
|
|
1334
|
-
if (!(node = q.node) || (x1 = q.x0) >
|
|
1334
|
+
if (!(node = q.node) || (x1 = q.x0) > x32 || (y1 = q.y0) > y32 || (x22 = q.x1) < x0 || (y22 = q.y1) < y0) continue;
|
|
1335
1335
|
if (node.length) {
|
|
1336
1336
|
var xm = (x1 + x22) / 2, ym = (y1 + y22) / 2;
|
|
1337
1337
|
quads.push(
|
|
@@ -1340,17 +1340,17 @@ function find_default(x2, y2, radius) {
|
|
|
1340
1340
|
new quad_default(node[1], xm, y1, x22, ym),
|
|
1341
1341
|
new quad_default(node[0], x1, y1, xm, ym)
|
|
1342
1342
|
);
|
|
1343
|
-
if (i = (
|
|
1343
|
+
if (i = (y3 >= ym) << 1 | x3 >= xm) {
|
|
1344
1344
|
q = quads[quads.length - 1];
|
|
1345
1345
|
quads[quads.length - 1] = quads[quads.length - 1 - i];
|
|
1346
1346
|
quads[quads.length - 1 - i] = q;
|
|
1347
1347
|
}
|
|
1348
1348
|
} else {
|
|
1349
|
-
var dx =
|
|
1349
|
+
var dx = x3 - +this._x.call(null, node.data), dy = y3 - +this._y.call(null, node.data), d2 = dx * dx + dy * dy;
|
|
1350
1350
|
if (d2 < radius) {
|
|
1351
1351
|
var d = Math.sqrt(radius = d2);
|
|
1352
|
-
x0 =
|
|
1353
|
-
|
|
1352
|
+
x0 = x3 - d, y0 = y3 - d;
|
|
1353
|
+
x32 = x3 + d, y32 = y3 + d;
|
|
1354
1354
|
data = node.data;
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
@@ -1360,13 +1360,13 @@ function find_default(x2, y2, radius) {
|
|
|
1360
1360
|
|
|
1361
1361
|
// node_modules/d3-quadtree/src/remove.js
|
|
1362
1362
|
function remove_default(d) {
|
|
1363
|
-
if (isNaN(
|
|
1364
|
-
var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1,
|
|
1363
|
+
if (isNaN(x3 = +this._x.call(null, d)) || isNaN(y3 = +this._y.call(null, d))) return this;
|
|
1364
|
+
var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1, x3, y3, xm, ym, right, bottom, i, j;
|
|
1365
1365
|
if (!node) return this;
|
|
1366
1366
|
if (node.length) while (true) {
|
|
1367
|
-
if (right =
|
|
1367
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
1368
1368
|
else x1 = xm;
|
|
1369
|
-
if (bottom =
|
|
1369
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
1370
1370
|
else y1 = ym;
|
|
1371
1371
|
if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
|
|
1372
1372
|
if (!node.length) break;
|
|
@@ -1458,13 +1458,13 @@ function y_default(_) {
|
|
|
1458
1458
|
}
|
|
1459
1459
|
|
|
1460
1460
|
// node_modules/d3-quadtree/src/quadtree.js
|
|
1461
|
-
function quadtree(nodes,
|
|
1462
|
-
var tree = new Quadtree(
|
|
1461
|
+
function quadtree(nodes, x3, y3) {
|
|
1462
|
+
var tree = new Quadtree(x3 == null ? defaultX : x3, y3 == null ? defaultY : y3, NaN, NaN, NaN, NaN);
|
|
1463
1463
|
return nodes == null ? tree : tree.addAll(nodes);
|
|
1464
1464
|
}
|
|
1465
|
-
function Quadtree(
|
|
1466
|
-
this._x =
|
|
1467
|
-
this._y =
|
|
1465
|
+
function Quadtree(x3, y3, x0, y0, x1, y1) {
|
|
1466
|
+
this._x = x3;
|
|
1467
|
+
this._y = y3;
|
|
1468
1468
|
this._x0 = x0;
|
|
1469
1469
|
this._y0 = y0;
|
|
1470
1470
|
this._x1 = x1;
|
|
@@ -1508,9 +1508,9 @@ treeProto.x = x_default;
|
|
|
1508
1508
|
treeProto.y = y_default;
|
|
1509
1509
|
|
|
1510
1510
|
// node_modules/d3-force/src/constant.js
|
|
1511
|
-
function constant_default(
|
|
1511
|
+
function constant_default(x3) {
|
|
1512
1512
|
return function() {
|
|
1513
|
-
return
|
|
1513
|
+
return x3;
|
|
1514
1514
|
};
|
|
1515
1515
|
}
|
|
1516
1516
|
|
|
@@ -1519,6 +1519,79 @@ function jiggle_default(random) {
|
|
|
1519
1519
|
return (random() - 0.5) * 1e-6;
|
|
1520
1520
|
}
|
|
1521
1521
|
|
|
1522
|
+
// node_modules/d3-force/src/collide.js
|
|
1523
|
+
function x(d) {
|
|
1524
|
+
return d.x + d.vx;
|
|
1525
|
+
}
|
|
1526
|
+
function y(d) {
|
|
1527
|
+
return d.y + d.vy;
|
|
1528
|
+
}
|
|
1529
|
+
function collide_default(radius) {
|
|
1530
|
+
var nodes, radii, random, strength = 1, iterations = 1;
|
|
1531
|
+
if (typeof radius !== "function") radius = constant_default(radius == null ? 1 : +radius);
|
|
1532
|
+
function force() {
|
|
1533
|
+
var i, n = nodes.length, tree, node, xi, yi, ri, ri2;
|
|
1534
|
+
for (var k = 0; k < iterations; ++k) {
|
|
1535
|
+
tree = quadtree(nodes, x, y).visitAfter(prepare);
|
|
1536
|
+
for (i = 0; i < n; ++i) {
|
|
1537
|
+
node = nodes[i];
|
|
1538
|
+
ri = radii[node.index], ri2 = ri * ri;
|
|
1539
|
+
xi = node.x + node.vx;
|
|
1540
|
+
yi = node.y + node.vy;
|
|
1541
|
+
tree.visit(apply);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
function apply(quad, x0, y0, x1, y1) {
|
|
1545
|
+
var data = quad.data, rj = quad.r, r = ri + rj;
|
|
1546
|
+
if (data) {
|
|
1547
|
+
if (data.index > node.index) {
|
|
1548
|
+
var x3 = xi - data.x - data.vx, y3 = yi - data.y - data.vy, l = x3 * x3 + y3 * y3;
|
|
1549
|
+
if (l < r * r) {
|
|
1550
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
1551
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
1552
|
+
l = (r - (l = Math.sqrt(l))) / l * strength;
|
|
1553
|
+
node.vx += (x3 *= l) * (r = (rj *= rj) / (ri2 + rj));
|
|
1554
|
+
node.vy += (y3 *= l) * r;
|
|
1555
|
+
data.vx -= x3 * (r = 1 - r);
|
|
1556
|
+
data.vy -= y3 * r;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function prepare(quad) {
|
|
1565
|
+
if (quad.data) return quad.r = radii[quad.data.index];
|
|
1566
|
+
for (var i = quad.r = 0; i < 4; ++i) {
|
|
1567
|
+
if (quad[i] && quad[i].r > quad.r) {
|
|
1568
|
+
quad.r = quad[i].r;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
function initialize() {
|
|
1573
|
+
if (!nodes) return;
|
|
1574
|
+
var i, n = nodes.length, node;
|
|
1575
|
+
radii = new Array(n);
|
|
1576
|
+
for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
|
|
1577
|
+
}
|
|
1578
|
+
force.initialize = function(_nodes, _random) {
|
|
1579
|
+
nodes = _nodes;
|
|
1580
|
+
random = _random;
|
|
1581
|
+
initialize();
|
|
1582
|
+
};
|
|
1583
|
+
force.iterations = function(_) {
|
|
1584
|
+
return arguments.length ? (iterations = +_, force) : iterations;
|
|
1585
|
+
};
|
|
1586
|
+
force.strength = function(_) {
|
|
1587
|
+
return arguments.length ? (strength = +_, force) : strength;
|
|
1588
|
+
};
|
|
1589
|
+
force.radius = function(_) {
|
|
1590
|
+
return arguments.length ? (radius = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : radius;
|
|
1591
|
+
};
|
|
1592
|
+
return force;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1522
1595
|
// node_modules/d3-force/src/link.js
|
|
1523
1596
|
function index(d) {
|
|
1524
1597
|
return d.index;
|
|
@@ -1536,17 +1609,17 @@ function link_default(links) {
|
|
|
1536
1609
|
}
|
|
1537
1610
|
function force(alpha) {
|
|
1538
1611
|
for (var k = 0, n = links.length; k < iterations; ++k) {
|
|
1539
|
-
for (var i = 0, link, source, target,
|
|
1612
|
+
for (var i = 0, link, source, target, x3, y3, l, b; i < n; ++i) {
|
|
1540
1613
|
link = links[i], source = link.source, target = link.target;
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
l = Math.sqrt(
|
|
1614
|
+
x3 = target.x + target.vx - source.x - source.vx || jiggle_default(random);
|
|
1615
|
+
y3 = target.y + target.vy - source.y - source.vy || jiggle_default(random);
|
|
1616
|
+
l = Math.sqrt(x3 * x3 + y3 * y3);
|
|
1544
1617
|
l = (l - distances[i]) / l * alpha * strengths[i];
|
|
1545
|
-
|
|
1546
|
-
target.vx -=
|
|
1547
|
-
target.vy -=
|
|
1548
|
-
source.vx +=
|
|
1549
|
-
source.vy +=
|
|
1618
|
+
x3 *= l, y3 *= l;
|
|
1619
|
+
target.vx -= x3 * (b = bias[i]);
|
|
1620
|
+
target.vy -= y3 * b;
|
|
1621
|
+
source.vx += x3 * (b = 1 - b);
|
|
1622
|
+
source.vy += y3 * b;
|
|
1550
1623
|
}
|
|
1551
1624
|
}
|
|
1552
1625
|
}
|
|
@@ -1794,10 +1867,10 @@ function lcg_default() {
|
|
|
1794
1867
|
}
|
|
1795
1868
|
|
|
1796
1869
|
// node_modules/d3-force/src/simulation.js
|
|
1797
|
-
function
|
|
1870
|
+
function x2(d) {
|
|
1798
1871
|
return d.x;
|
|
1799
1872
|
}
|
|
1800
|
-
function
|
|
1873
|
+
function y2(d) {
|
|
1801
1874
|
return d.y;
|
|
1802
1875
|
}
|
|
1803
1876
|
var initialRadius = 10;
|
|
@@ -1883,14 +1956,14 @@ function simulation_default(nodes) {
|
|
|
1883
1956
|
force: function(name, _) {
|
|
1884
1957
|
return arguments.length > 1 ? (_ == null ? forces.delete(name) : forces.set(name, initializeForce(_)), simulation) : forces.get(name);
|
|
1885
1958
|
},
|
|
1886
|
-
find: function(
|
|
1959
|
+
find: function(x3, y3, radius) {
|
|
1887
1960
|
var i = 0, n = nodes.length, dx, dy, d2, node, closest;
|
|
1888
1961
|
if (radius == null) radius = Infinity;
|
|
1889
1962
|
else radius *= radius;
|
|
1890
1963
|
for (i = 0; i < n; ++i) {
|
|
1891
1964
|
node = nodes[i];
|
|
1892
|
-
dx =
|
|
1893
|
-
dy =
|
|
1965
|
+
dx = x3 - node.x;
|
|
1966
|
+
dy = y3 - node.y;
|
|
1894
1967
|
d2 = dx * dx + dy * dy;
|
|
1895
1968
|
if (d2 < radius) closest = node, radius = d2;
|
|
1896
1969
|
}
|
|
@@ -1906,7 +1979,7 @@ function simulation_default(nodes) {
|
|
|
1906
1979
|
function manyBody_default() {
|
|
1907
1980
|
var nodes, node, random, alpha, strength = constant_default(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81;
|
|
1908
1981
|
function force(_) {
|
|
1909
|
-
var i, n = nodes.length, tree = quadtree(nodes,
|
|
1982
|
+
var i, n = nodes.length, tree = quadtree(nodes, x2, y2).visitAfter(accumulate);
|
|
1910
1983
|
for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
|
|
1911
1984
|
}
|
|
1912
1985
|
function initialize() {
|
|
@@ -1916,15 +1989,15 @@ function manyBody_default() {
|
|
|
1916
1989
|
for (i = 0; i < n; ++i) node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes);
|
|
1917
1990
|
}
|
|
1918
1991
|
function accumulate(quad) {
|
|
1919
|
-
var strength2 = 0, q, c2, weight = 0,
|
|
1992
|
+
var strength2 = 0, q, c2, weight = 0, x3, y3, i;
|
|
1920
1993
|
if (quad.length) {
|
|
1921
|
-
for (
|
|
1994
|
+
for (x3 = y3 = i = 0; i < 4; ++i) {
|
|
1922
1995
|
if ((q = quad[i]) && (c2 = Math.abs(q.value))) {
|
|
1923
|
-
strength2 += q.value, weight += c2,
|
|
1996
|
+
strength2 += q.value, weight += c2, x3 += c2 * q.x, y3 += c2 * q.y;
|
|
1924
1997
|
}
|
|
1925
1998
|
}
|
|
1926
|
-
quad.x =
|
|
1927
|
-
quad.y =
|
|
1999
|
+
quad.x = x3 / weight;
|
|
2000
|
+
quad.y = y3 / weight;
|
|
1928
2001
|
} else {
|
|
1929
2002
|
q = quad;
|
|
1930
2003
|
q.x = q.data.x;
|
|
@@ -1935,29 +2008,29 @@ function manyBody_default() {
|
|
|
1935
2008
|
}
|
|
1936
2009
|
quad.value = strength2;
|
|
1937
2010
|
}
|
|
1938
|
-
function apply(quad, x1, _,
|
|
2011
|
+
function apply(quad, x1, _, x22) {
|
|
1939
2012
|
if (!quad.value) return true;
|
|
1940
|
-
var x3 = quad.x - node.x,
|
|
2013
|
+
var x3 = quad.x - node.x, y3 = quad.y - node.y, w = x22 - x1, l = x3 * x3 + y3 * y3;
|
|
1941
2014
|
if (w * w / theta2 < l) {
|
|
1942
2015
|
if (l < distanceMax2) {
|
|
1943
2016
|
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
1944
|
-
if (
|
|
2017
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
1945
2018
|
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
1946
2019
|
node.vx += x3 * quad.value * alpha / l;
|
|
1947
|
-
node.vy +=
|
|
2020
|
+
node.vy += y3 * quad.value * alpha / l;
|
|
1948
2021
|
}
|
|
1949
2022
|
return true;
|
|
1950
2023
|
} else if (quad.length || l >= distanceMax2) return;
|
|
1951
2024
|
if (quad.data !== node || quad.next) {
|
|
1952
2025
|
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
1953
|
-
if (
|
|
2026
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
1954
2027
|
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
1955
2028
|
}
|
|
1956
2029
|
do
|
|
1957
2030
|
if (quad.data !== node) {
|
|
1958
2031
|
w = strengths[quad.data.index] * alpha / l;
|
|
1959
2032
|
node.vx += x3 * w;
|
|
1960
|
-
node.vy +=
|
|
2033
|
+
node.vy += y3 * w;
|
|
1961
2034
|
}
|
|
1962
2035
|
while (quad = quad.next);
|
|
1963
2036
|
}
|
|
@@ -1987,9 +2060,10 @@ var PhysicsManager = class {
|
|
|
1987
2060
|
config;
|
|
1988
2061
|
simulationStartTime;
|
|
1989
2062
|
simulationEndTime;
|
|
1990
|
-
cooldownTimer;
|
|
1991
2063
|
hasInitialAutoFitCompleted = false;
|
|
1992
2064
|
timerManager;
|
|
2065
|
+
isVisibilityListenerAttached = false;
|
|
2066
|
+
nodeMap = /* @__PURE__ */ new Map();
|
|
1993
2067
|
constructor(timerManager) {
|
|
1994
2068
|
this.timerManager = timerManager;
|
|
1995
2069
|
}
|
|
@@ -2003,43 +2077,49 @@ var PhysicsManager = class {
|
|
|
2003
2077
|
if (typeof config.onTick !== "function") {
|
|
2004
2078
|
throw new ValidationError("onTick callback is required and must be a function");
|
|
2005
2079
|
}
|
|
2080
|
+
if (!this.isVisibilityListenerAttached) {
|
|
2081
|
+
document.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
2082
|
+
this.isVisibilityListenerAttached = true;
|
|
2083
|
+
}
|
|
2006
2084
|
this.config = config;
|
|
2007
2085
|
this.simulationStartTime = performance.now();
|
|
2008
2086
|
const nodeCount = config.nodes.length;
|
|
2009
|
-
const
|
|
2010
|
-
const graphArea = config.width * config.height;
|
|
2011
|
-
const baseChargeStrength = -600;
|
|
2087
|
+
const graphArea = Math.max(config.width * config.height, 1);
|
|
2012
2088
|
const nodeDensity = nodeCount / (graphArea / 1e5);
|
|
2013
2089
|
const densityFactor = Math.min(nodeDensity, 2);
|
|
2014
|
-
const adaptiveChargeStrength = baseChargeStrength / (1 + densityFactor * 0.4);
|
|
2015
2090
|
const baseVelocityDecay = 0.4;
|
|
2016
2091
|
const adaptiveVelocityDecay = Math.min(baseVelocityDecay + densityFactor * 0.2, 0.8);
|
|
2017
2092
|
const baseAlphaDecay = 0.02;
|
|
2018
2093
|
const adaptiveAlphaDecay = Math.min(baseAlphaDecay + densityFactor * 0.01, 0.05);
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
});
|
|
2094
|
+
if (this.simulation) {
|
|
2095
|
+
this.simulation.stop();
|
|
2096
|
+
}
|
|
2097
|
+
this.buildNodeIndex();
|
|
2098
|
+
const linkDistance = nodeCount > 1e4 ? 220 : nodeCount > 5e3 ? 190 : nodeCount > 2e3 ? 170 : 150;
|
|
2099
|
+
const chargeStrength = nodeCount > 1e4 ? -350 : nodeCount > 5e3 ? -400 : nodeCount > 2e3 ? -450 : -500;
|
|
2100
|
+
const collisionRadius = nodeCount > 1e4 ? 1 : nodeCount > 5e3 ? 2 : 2;
|
|
2101
|
+
const collisionIterations = nodeCount > 1e4 ? 1 : nodeCount > 5e3 ? 1 : 2;
|
|
2102
|
+
const centerStrength = nodeCount > 5e3 ? 0.15 : 0.5;
|
|
2103
|
+
const linkStrength = nodeCount > 1e4 ? 0.15 : nodeCount > 5e3 ? 0.25 : 0.4;
|
|
2030
2104
|
this.simulation = simulation_default(config.nodes).force(
|
|
2031
2105
|
"link",
|
|
2032
|
-
link_default(config.links).id((d) => d.id).distance(
|
|
2033
|
-
// Much weaker link strength to allow repulsion to work
|
|
2106
|
+
link_default(config.links).id((d) => d.id).distance(linkDistance).strength(linkStrength).iterations(1)
|
|
2034
2107
|
).force(
|
|
2035
2108
|
"charge",
|
|
2036
|
-
manyBody_default().strength(
|
|
2037
|
-
|
|
2109
|
+
manyBody_default().strength(chargeStrength).theta(nodeCount > 5e3 ? 1.2 : 0.9).distanceMax(nodeCount > 5e3 ? 500 : 1e3)
|
|
2110
|
+
).force(
|
|
2111
|
+
"collision",
|
|
2112
|
+
collide_default().radius((node) => (node.style?.radius ?? 20) + collisionRadius).strength(1).iterations(collisionIterations)
|
|
2038
2113
|
).force(
|
|
2039
2114
|
"center",
|
|
2040
|
-
center_default(0, 0).strength(
|
|
2041
|
-
|
|
2042
|
-
|
|
2115
|
+
center_default(0, 0).strength(centerStrength)
|
|
2116
|
+
).velocityDecay(
|
|
2117
|
+
nodeCount > 5e3 ? 0.65 : adaptiveVelocityDecay
|
|
2118
|
+
).alphaDecay(
|
|
2119
|
+
nodeCount > 5e3 ? 0.05 : adaptiveAlphaDecay
|
|
2120
|
+
).alphaMin(
|
|
2121
|
+
nodeCount > 5e3 ? 0.05 : 1e-3
|
|
2122
|
+
).on("tick", config.onTick).on("end", () => this.handleSimulationEnd());
|
|
2043
2123
|
if (config.cooldownTime) {
|
|
2044
2124
|
this.setupCooldownTimer(config.cooldownTime);
|
|
2045
2125
|
}
|
|
@@ -2092,6 +2172,34 @@ var PhysicsManager = class {
|
|
|
2092
2172
|
ErrorHandler.logError(error, { cooldownTime });
|
|
2093
2173
|
}
|
|
2094
2174
|
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Build node index for O(1) lookups (Step 3 optimization)
|
|
2177
|
+
*/
|
|
2178
|
+
buildNodeIndex() {
|
|
2179
|
+
if (!this.config) return;
|
|
2180
|
+
try {
|
|
2181
|
+
this.nodeMap.clear();
|
|
2182
|
+
for (const node of this.config.nodes) {
|
|
2183
|
+
this.nodeMap.set(node.id, node);
|
|
2184
|
+
}
|
|
2185
|
+
for (const link of this.config.links) {
|
|
2186
|
+
if (typeof link.source === "string") {
|
|
2187
|
+
const sourceNode = this.nodeMap.get(link.source);
|
|
2188
|
+
if (sourceNode) {
|
|
2189
|
+
link.source = sourceNode;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
if (typeof link.target === "string") {
|
|
2193
|
+
const targetNode = this.nodeMap.get(link.target);
|
|
2194
|
+
if (targetNode) {
|
|
2195
|
+
link.target = targetNode;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
} catch (error) {
|
|
2200
|
+
ErrorHandler.logError(error);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2095
2203
|
/**
|
|
2096
2204
|
* Get simulation instance
|
|
2097
2205
|
*/
|
|
@@ -2104,11 +2212,15 @@ var PhysicsManager = class {
|
|
|
2104
2212
|
/**
|
|
2105
2213
|
* Reheat simulation for drag interactions
|
|
2106
2214
|
*/
|
|
2107
|
-
reheat(alphaTarget
|
|
2108
|
-
if (!this.simulation)
|
|
2215
|
+
reheat(alphaTarget) {
|
|
2216
|
+
if (!this.simulation || !this.config) {
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
const nodeCount = this.config.nodes.length;
|
|
2220
|
+
const effectiveAlpha = alphaTarget ?? (nodeCount > 1e4 ? 5e-3 : nodeCount > 5e3 ? 0.01 : nodeCount > 2e3 ? 0.02 : 0.1);
|
|
2109
2221
|
try {
|
|
2110
|
-
this.simulation.alphaTarget(
|
|
2111
|
-
if (this.config
|
|
2222
|
+
this.simulation.alphaTarget(effectiveAlpha).restart();
|
|
2223
|
+
if (this.config.cooldownTime) {
|
|
2112
2224
|
this.setupCooldownTimer(this.config.cooldownTime);
|
|
2113
2225
|
}
|
|
2114
2226
|
} catch (error) {
|
|
@@ -2164,12 +2276,12 @@ var PhysicsManager = class {
|
|
|
2164
2276
|
* Update center force position for new canvas dimensions
|
|
2165
2277
|
* Following force-graph pattern for container resizing
|
|
2166
2278
|
*/
|
|
2167
|
-
updateCenterForce(
|
|
2279
|
+
updateCenterForce(x3, y3) {
|
|
2168
2280
|
if (!this.simulation) return;
|
|
2169
2281
|
try {
|
|
2170
|
-
this.simulation.force("center", center_default(
|
|
2282
|
+
this.simulation.force("center", center_default(x3, y3).strength(0.1));
|
|
2171
2283
|
} catch (error) {
|
|
2172
|
-
ErrorHandler.logError(error, { x:
|
|
2284
|
+
ErrorHandler.logError(error, { x: x3, y: y3 });
|
|
2173
2285
|
}
|
|
2174
2286
|
}
|
|
2175
2287
|
/**
|
|
@@ -2178,14 +2290,14 @@ var PhysicsManager = class {
|
|
|
2178
2290
|
adjustLinkDistancesForVisualShortening() {
|
|
2179
2291
|
if (!this.simulation || !this.config) return;
|
|
2180
2292
|
try {
|
|
2293
|
+
const baseDistance = this.calculateBaseDistance();
|
|
2181
2294
|
const linkForce = this.simulation.force("link");
|
|
2182
2295
|
if (linkForce) {
|
|
2183
2296
|
linkForce.distance((link) => {
|
|
2184
|
-
const
|
|
2185
|
-
const
|
|
2186
|
-
const
|
|
2187
|
-
const
|
|
2188
|
-
const targetRadius = this.getNodeRadius(targetNode);
|
|
2297
|
+
const sourceNode = typeof link.source === "string" ? this.nodeMap.get(link.source) : link.source;
|
|
2298
|
+
const targetNode = typeof link.target === "string" ? this.nodeMap.get(link.target) : link.target;
|
|
2299
|
+
const sourceRadius = sourceNode?.style?.radius ?? 20;
|
|
2300
|
+
const targetRadius = targetNode?.style?.radius ?? 20;
|
|
2189
2301
|
const arrowLength = this.getLinkArrowLength(link);
|
|
2190
2302
|
const visualCompensation = sourceRadius + targetRadius + arrowLength;
|
|
2191
2303
|
const spacingBuffer = Math.max(20, (sourceRadius + targetRadius) * 0.5);
|
|
@@ -2203,23 +2315,10 @@ var PhysicsManager = class {
|
|
|
2203
2315
|
calculateBaseDistance() {
|
|
2204
2316
|
if (!this.config) return 120;
|
|
2205
2317
|
const nodeCount = this.config.nodes.length;
|
|
2206
|
-
const graphArea = this.config.width * this.config.height;
|
|
2318
|
+
const graphArea = Math.max(this.config.width * this.config.height, 1);
|
|
2207
2319
|
const nodeAreaRatio = nodeCount / (graphArea / 1e4);
|
|
2208
2320
|
return Math.max(80, Math.min(200, 120 + nodeAreaRatio * 20));
|
|
2209
2321
|
}
|
|
2210
|
-
/**
|
|
2211
|
-
* Find node by ID
|
|
2212
|
-
*/
|
|
2213
|
-
findNodeById(id2) {
|
|
2214
|
-
return this.config?.nodes.find((node) => node.id === id2);
|
|
2215
|
-
}
|
|
2216
|
-
/**
|
|
2217
|
-
* Get node radius from style or default
|
|
2218
|
-
*/
|
|
2219
|
-
getNodeRadius(node) {
|
|
2220
|
-
if (!node) return 20;
|
|
2221
|
-
return node.style?.radius ?? 20;
|
|
2222
|
-
}
|
|
2223
2322
|
/**
|
|
2224
2323
|
* Get arrow length from link style or default
|
|
2225
2324
|
*/
|
|
@@ -2236,7 +2335,7 @@ var PhysicsManager = class {
|
|
|
2236
2335
|
if (!this.config) return;
|
|
2237
2336
|
try {
|
|
2238
2337
|
for (const node of this.config.nodes) {
|
|
2239
|
-
if (
|
|
2338
|
+
if (node.x == null || node.y == null) {
|
|
2240
2339
|
node.x = Math.random() * this.config.width;
|
|
2241
2340
|
node.y = Math.random() * this.config.height;
|
|
2242
2341
|
}
|
|
@@ -2284,30 +2383,49 @@ var PhysicsManager = class {
|
|
|
2284
2383
|
* Pause the simulation
|
|
2285
2384
|
*/
|
|
2286
2385
|
pause() {
|
|
2287
|
-
if (this.simulation) {
|
|
2288
|
-
|
|
2386
|
+
if (!this.simulation) {
|
|
2387
|
+
return;
|
|
2289
2388
|
}
|
|
2389
|
+
this.timerManager.clearTimer("simulationCooldown");
|
|
2390
|
+
this.simulation.stop();
|
|
2290
2391
|
}
|
|
2291
2392
|
/**
|
|
2292
2393
|
* Resume the simulation
|
|
2293
2394
|
*/
|
|
2294
2395
|
resume() {
|
|
2295
|
-
if (this.simulation) {
|
|
2296
|
-
|
|
2396
|
+
if (!this.simulation) {
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
const nodeCount = this.config?.nodes.length ?? 0;
|
|
2400
|
+
const alpha = nodeCount > 1e4 ? 0.01 : nodeCount > 5e3 ? 0.02 : nodeCount > 2e3 ? 0.05 : 0.3;
|
|
2401
|
+
this.simulation.alpha(alpha).alphaTarget(0).restart();
|
|
2402
|
+
if (this.config?.cooldownTime) {
|
|
2403
|
+
this.setupCooldownTimer(this.config.cooldownTime);
|
|
2297
2404
|
}
|
|
2298
2405
|
}
|
|
2406
|
+
handleVisibilityChange = () => {
|
|
2407
|
+
if (document.visibilityState !== "visible") {
|
|
2408
|
+
this.pause();
|
|
2409
|
+
} else {
|
|
2410
|
+
this.resume();
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2299
2413
|
/**
|
|
2300
2414
|
* Destroy physics simulation
|
|
2301
2415
|
*/
|
|
2302
2416
|
destroy() {
|
|
2303
2417
|
try {
|
|
2418
|
+
if (this.isVisibilityListenerAttached) {
|
|
2419
|
+
document.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
2420
|
+
this.isVisibilityListenerAttached = false;
|
|
2421
|
+
}
|
|
2304
2422
|
this.timerManager.clearTimer("simulationCooldown");
|
|
2305
|
-
this.cooldownTimer = void 0;
|
|
2306
2423
|
if (this.simulation) {
|
|
2307
2424
|
this.simulation.stop();
|
|
2308
2425
|
this.simulation = void 0;
|
|
2309
2426
|
}
|
|
2310
2427
|
this.config = void 0;
|
|
2428
|
+
this.nodeMap.clear();
|
|
2311
2429
|
this.simulationStartTime = void 0;
|
|
2312
2430
|
this.simulationEndTime = void 0;
|
|
2313
2431
|
this.hasInitialAutoFitCompleted = false;
|
|
@@ -2386,8 +2504,8 @@ function select_default(select) {
|
|
|
2386
2504
|
}
|
|
2387
2505
|
|
|
2388
2506
|
// node_modules/d3-selection/src/array.js
|
|
2389
|
-
function array(
|
|
2390
|
-
return
|
|
2507
|
+
function array(x3) {
|
|
2508
|
+
return x3 == null ? [] : Array.isArray(x3) ? x3 : Array.from(x3);
|
|
2391
2509
|
}
|
|
2392
2510
|
|
|
2393
2511
|
// node_modules/d3-selection/src/selectorAll.js
|
|
@@ -2506,9 +2624,9 @@ EnterNode.prototype = {
|
|
|
2506
2624
|
};
|
|
2507
2625
|
|
|
2508
2626
|
// node_modules/d3-selection/src/constant.js
|
|
2509
|
-
function constant_default2(
|
|
2627
|
+
function constant_default2(x3) {
|
|
2510
2628
|
return function() {
|
|
2511
|
-
return
|
|
2629
|
+
return x3;
|
|
2512
2630
|
};
|
|
2513
2631
|
}
|
|
2514
2632
|
|
|
@@ -3181,7 +3299,7 @@ function yesdrag(view, noclick) {
|
|
|
3181
3299
|
}
|
|
3182
3300
|
|
|
3183
3301
|
// node_modules/d3-drag/src/constant.js
|
|
3184
|
-
var constant_default3 = (
|
|
3302
|
+
var constant_default3 = (x3) => () => x3;
|
|
3185
3303
|
|
|
3186
3304
|
// node_modules/d3-drag/src/event.js
|
|
3187
3305
|
function DragEvent(type, {
|
|
@@ -3190,8 +3308,8 @@ function DragEvent(type, {
|
|
|
3190
3308
|
target,
|
|
3191
3309
|
identifier,
|
|
3192
3310
|
active,
|
|
3193
|
-
x:
|
|
3194
|
-
y:
|
|
3311
|
+
x: x3,
|
|
3312
|
+
y: y3,
|
|
3195
3313
|
dx,
|
|
3196
3314
|
dy,
|
|
3197
3315
|
dispatch: dispatch2
|
|
@@ -3203,8 +3321,8 @@ function DragEvent(type, {
|
|
|
3203
3321
|
target: { value: target, enumerable: true, configurable: true },
|
|
3204
3322
|
identifier: { value: identifier, enumerable: true, configurable: true },
|
|
3205
3323
|
active: { value: active, enumerable: true, configurable: true },
|
|
3206
|
-
x: { value:
|
|
3207
|
-
y: { value:
|
|
3324
|
+
x: { value: x3, enumerable: true, configurable: true },
|
|
3325
|
+
y: { value: y3, enumerable: true, configurable: true },
|
|
3208
3326
|
dx: { value: dx, enumerable: true, configurable: true },
|
|
3209
3327
|
dy: { value: dy, enumerable: true, configurable: true },
|
|
3210
3328
|
_: { value: dispatch2 }
|
|
@@ -3731,7 +3849,7 @@ function basisClosed_default(values) {
|
|
|
3731
3849
|
}
|
|
3732
3850
|
|
|
3733
3851
|
// node_modules/d3-interpolate/src/constant.js
|
|
3734
|
-
var constant_default4 = (
|
|
3852
|
+
var constant_default4 = (x3) => () => x3;
|
|
3735
3853
|
|
|
3736
3854
|
// node_modules/d3-interpolate/src/color.js
|
|
3737
3855
|
function linear(a2, d) {
|
|
@@ -3739,14 +3857,14 @@ function linear(a2, d) {
|
|
|
3739
3857
|
return a2 + t * d;
|
|
3740
3858
|
};
|
|
3741
3859
|
}
|
|
3742
|
-
function exponential(a2, b,
|
|
3743
|
-
return a2 = Math.pow(a2,
|
|
3744
|
-
return Math.pow(a2 + t * b,
|
|
3860
|
+
function exponential(a2, b, y3) {
|
|
3861
|
+
return a2 = Math.pow(a2, y3), b = Math.pow(b, y3) - a2, y3 = 1 / y3, function(t) {
|
|
3862
|
+
return Math.pow(a2 + t * b, y3);
|
|
3745
3863
|
};
|
|
3746
3864
|
}
|
|
3747
|
-
function gamma(
|
|
3748
|
-
return (
|
|
3749
|
-
return b - a2 ? exponential(a2, b,
|
|
3865
|
+
function gamma(y3) {
|
|
3866
|
+
return (y3 = +y3) === 1 ? nogamma : function(a2, b) {
|
|
3867
|
+
return b - a2 ? exponential(a2, b, y3) : constant_default4(isNaN(a2) ? b : a2);
|
|
3750
3868
|
};
|
|
3751
3869
|
}
|
|
3752
3870
|
function nogamma(a2, b) {
|
|
@@ -3755,8 +3873,8 @@ function nogamma(a2, b) {
|
|
|
3755
3873
|
}
|
|
3756
3874
|
|
|
3757
3875
|
// node_modules/d3-interpolate/src/rgb.js
|
|
3758
|
-
var rgb_default = (function rgbGamma(
|
|
3759
|
-
var color2 = gamma(
|
|
3876
|
+
var rgb_default = (function rgbGamma(y3) {
|
|
3877
|
+
var color2 = gamma(y3);
|
|
3760
3878
|
function rgb2(start2, end) {
|
|
3761
3879
|
var r = color2((start2 = rgb(start2)).r, (end = rgb(end)).r), g = color2(start2.g, end.g), b = color2(start2.b, end.b), opacity = nogamma(start2.opacity, end.opacity);
|
|
3762
3880
|
return function(t) {
|
|
@@ -3941,14 +4059,14 @@ var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
|
|
|
3941
4059
|
|
|
3942
4060
|
// node_modules/d3-interpolate/src/zoom.js
|
|
3943
4061
|
var epsilon2 = 1e-12;
|
|
3944
|
-
function cosh(
|
|
3945
|
-
return ((
|
|
4062
|
+
function cosh(x3) {
|
|
4063
|
+
return ((x3 = Math.exp(x3)) + 1 / x3) / 2;
|
|
3946
4064
|
}
|
|
3947
|
-
function sinh(
|
|
3948
|
-
return ((
|
|
4065
|
+
function sinh(x3) {
|
|
4066
|
+
return ((x3 = Math.exp(x3)) - 1 / x3) / 2;
|
|
3949
4067
|
}
|
|
3950
|
-
function tanh(
|
|
3951
|
-
return ((
|
|
4068
|
+
function tanh(x3) {
|
|
4069
|
+
return ((x3 = Math.exp(2 * x3)) - 1) / (x3 + 1);
|
|
3952
4070
|
}
|
|
3953
4071
|
var zoom_default = (function zoomRho(rho, rho2, rho4) {
|
|
3954
4072
|
function zoom(p0, p1) {
|
|
@@ -4676,7 +4794,7 @@ selection_default.prototype.interrupt = interrupt_default2;
|
|
|
4676
4794
|
selection_default.prototype.transition = transition_default2;
|
|
4677
4795
|
|
|
4678
4796
|
// node_modules/d3-zoom/src/constant.js
|
|
4679
|
-
var constant_default5 = (
|
|
4797
|
+
var constant_default5 = (x3) => () => x3;
|
|
4680
4798
|
|
|
4681
4799
|
// node_modules/d3-zoom/src/event.js
|
|
4682
4800
|
function ZoomEvent(type, {
|
|
@@ -4695,42 +4813,42 @@ function ZoomEvent(type, {
|
|
|
4695
4813
|
}
|
|
4696
4814
|
|
|
4697
4815
|
// node_modules/d3-zoom/src/transform.js
|
|
4698
|
-
function Transform(k,
|
|
4816
|
+
function Transform(k, x3, y3) {
|
|
4699
4817
|
this.k = k;
|
|
4700
|
-
this.x =
|
|
4701
|
-
this.y =
|
|
4818
|
+
this.x = x3;
|
|
4819
|
+
this.y = y3;
|
|
4702
4820
|
}
|
|
4703
4821
|
Transform.prototype = {
|
|
4704
4822
|
constructor: Transform,
|
|
4705
4823
|
scale: function(k) {
|
|
4706
4824
|
return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
|
|
4707
4825
|
},
|
|
4708
|
-
translate: function(
|
|
4709
|
-
return
|
|
4826
|
+
translate: function(x3, y3) {
|
|
4827
|
+
return x3 === 0 & y3 === 0 ? this : new Transform(this.k, this.x + this.k * x3, this.y + this.k * y3);
|
|
4710
4828
|
},
|
|
4711
4829
|
apply: function(point) {
|
|
4712
4830
|
return [point[0] * this.k + this.x, point[1] * this.k + this.y];
|
|
4713
4831
|
},
|
|
4714
|
-
applyX: function(
|
|
4715
|
-
return
|
|
4832
|
+
applyX: function(x3) {
|
|
4833
|
+
return x3 * this.k + this.x;
|
|
4716
4834
|
},
|
|
4717
|
-
applyY: function(
|
|
4718
|
-
return
|
|
4835
|
+
applyY: function(y3) {
|
|
4836
|
+
return y3 * this.k + this.y;
|
|
4719
4837
|
},
|
|
4720
4838
|
invert: function(location) {
|
|
4721
4839
|
return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
|
|
4722
4840
|
},
|
|
4723
|
-
invertX: function(
|
|
4724
|
-
return (
|
|
4841
|
+
invertX: function(x3) {
|
|
4842
|
+
return (x3 - this.x) / this.k;
|
|
4725
4843
|
},
|
|
4726
|
-
invertY: function(
|
|
4727
|
-
return (
|
|
4844
|
+
invertY: function(y3) {
|
|
4845
|
+
return (y3 - this.y) / this.k;
|
|
4728
4846
|
},
|
|
4729
|
-
rescaleX: function(
|
|
4730
|
-
return
|
|
4847
|
+
rescaleX: function(x3) {
|
|
4848
|
+
return x3.copy().domain(x3.range().map(this.invertX, this).map(x3.invert, x3));
|
|
4731
4849
|
},
|
|
4732
|
-
rescaleY: function(
|
|
4733
|
-
return
|
|
4850
|
+
rescaleY: function(y3) {
|
|
4851
|
+
return y3.copy().domain(y3.range().map(this.invertY, this).map(y3.invert, y3));
|
|
4734
4852
|
},
|
|
4735
4853
|
toString: function() {
|
|
4736
4854
|
return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
|
|
@@ -4812,20 +4930,20 @@ function zoom_default2() {
|
|
|
4812
4930
|
return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent);
|
|
4813
4931
|
}, p, event);
|
|
4814
4932
|
};
|
|
4815
|
-
zoom.translateBy = function(selection2,
|
|
4933
|
+
zoom.translateBy = function(selection2, x3, y3, event) {
|
|
4816
4934
|
zoom.transform(selection2, function() {
|
|
4817
4935
|
return constrain(this.__zoom.translate(
|
|
4818
|
-
typeof
|
|
4819
|
-
typeof
|
|
4936
|
+
typeof x3 === "function" ? x3.apply(this, arguments) : x3,
|
|
4937
|
+
typeof y3 === "function" ? y3.apply(this, arguments) : y3
|
|
4820
4938
|
), extent.apply(this, arguments), translateExtent);
|
|
4821
4939
|
}, null, event);
|
|
4822
4940
|
};
|
|
4823
|
-
zoom.translateTo = function(selection2,
|
|
4941
|
+
zoom.translateTo = function(selection2, x3, y3, p, event) {
|
|
4824
4942
|
zoom.transform(selection2, function() {
|
|
4825
4943
|
var e = extent.apply(this, arguments), t = this.__zoom, p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p;
|
|
4826
4944
|
return constrain(identity2.translate(p0[0], p0[1]).scale(t.k).translate(
|
|
4827
|
-
typeof
|
|
4828
|
-
typeof
|
|
4945
|
+
typeof x3 === "function" ? -x3.apply(this, arguments) : -x3,
|
|
4946
|
+
typeof y3 === "function" ? -y3.apply(this, arguments) : -y3
|
|
4829
4947
|
), e, translateExtent);
|
|
4830
4948
|
}, p, event);
|
|
4831
4949
|
};
|
|
@@ -4834,8 +4952,8 @@ function zoom_default2() {
|
|
|
4834
4952
|
return k === transform2.k ? transform2 : new Transform(k, transform2.x, transform2.y);
|
|
4835
4953
|
}
|
|
4836
4954
|
function translate(transform2, p0, p1) {
|
|
4837
|
-
var
|
|
4838
|
-
return
|
|
4955
|
+
var x3 = p0[0] - p1[0] * transform2.k, y3 = p0[1] - p1[1] * transform2.k;
|
|
4956
|
+
return x3 === transform2.x && y3 === transform2.y ? transform2 : new Transform(transform2.k, x3, y3);
|
|
4839
4957
|
}
|
|
4840
4958
|
function centroid(extent2) {
|
|
4841
4959
|
return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
|
|
@@ -5140,7 +5258,7 @@ var DragManager = class {
|
|
|
5140
5258
|
fy: obj.fy
|
|
5141
5259
|
};
|
|
5142
5260
|
if (!event.active) {
|
|
5143
|
-
this.config.physicsManager.reheat(
|
|
5261
|
+
this.config.physicsManager.reheat();
|
|
5144
5262
|
obj.fx = obj.x;
|
|
5145
5263
|
obj.fy = obj.y;
|
|
5146
5264
|
}
|
|
@@ -5869,9 +5987,9 @@ var SelectionManager = class {
|
|
|
5869
5987
|
if (!this.canvasState) return;
|
|
5870
5988
|
try {
|
|
5871
5989
|
const rect = this.container.getBoundingClientRect();
|
|
5872
|
-
const
|
|
5873
|
-
const
|
|
5874
|
-
const obj = this.getObjUnderPointer(
|
|
5990
|
+
const x3 = event.clientX - rect.left;
|
|
5991
|
+
const y3 = event.clientY - rect.top;
|
|
5992
|
+
const obj = this.getObjUnderPointer(x3, y3);
|
|
5875
5993
|
if (obj) {
|
|
5876
5994
|
if (obj.d.entityType === "Node") {
|
|
5877
5995
|
this.selectNode(obj.d);
|
|
@@ -5891,19 +6009,19 @@ var SelectionManager = class {
|
|
|
5891
6009
|
/**
|
|
5892
6010
|
* Get object under pointer coordinates (using shadow canvas)
|
|
5893
6011
|
*/
|
|
5894
|
-
getObjUnderPointer(
|
|
6012
|
+
getObjUnderPointer(x3, y3) {
|
|
5895
6013
|
if (!this.canvasState) return null;
|
|
5896
6014
|
try {
|
|
5897
6015
|
const { shadowCtx, colorTracker } = this.canvasState;
|
|
5898
6016
|
const pxScale = window.devicePixelRatio;
|
|
5899
|
-
const px =
|
|
6017
|
+
const px = x3 > 0 && y3 > 0 ? shadowCtx.getImageData(x3 * pxScale, y3 * pxScale, 1, 1) : null;
|
|
5900
6018
|
if (px && px.data.length >= 3) {
|
|
5901
6019
|
const rgb2 = [px.data[0] ?? 0, px.data[1] ?? 0, px.data[2] ?? 0];
|
|
5902
6020
|
return colorTracker.lookup(rgb2);
|
|
5903
6021
|
}
|
|
5904
6022
|
return null;
|
|
5905
6023
|
} catch (error) {
|
|
5906
|
-
ErrorHandler.logError(error, { x:
|
|
6024
|
+
ErrorHandler.logError(error, { x: x3, y: y3 });
|
|
5907
6025
|
return null;
|
|
5908
6026
|
}
|
|
5909
6027
|
}
|
|
@@ -6121,8 +6239,8 @@ var NodesRenderer = class {
|
|
|
6121
6239
|
static renderWithOptimizedStates(ctx, nodes, styleResolver, hoveredNodeId, selectedNodeId) {
|
|
6122
6240
|
try {
|
|
6123
6241
|
for (const node of nodes) {
|
|
6124
|
-
const
|
|
6125
|
-
const
|
|
6242
|
+
const x3 = node.x;
|
|
6243
|
+
const y3 = node.y;
|
|
6126
6244
|
const isHovered = hoveredNodeId === node.id;
|
|
6127
6245
|
const isSelected = selectedNodeId === node.id;
|
|
6128
6246
|
const style = styleResolver.resolveNodeStyle({
|
|
@@ -6131,7 +6249,7 @@ var NodesRenderer = class {
|
|
|
6131
6249
|
isSelected
|
|
6132
6250
|
});
|
|
6133
6251
|
ctx.beginPath();
|
|
6134
|
-
ctx.arc(
|
|
6252
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6135
6253
|
ctx.fillStyle = style.fill;
|
|
6136
6254
|
ctx.globalAlpha = style.opacity;
|
|
6137
6255
|
ctx.fill();
|
|
@@ -6153,12 +6271,12 @@ var NodesRenderer = class {
|
|
|
6153
6271
|
static render(ctx, nodes, nodeStyle, hoverNodeStyle, isNodeHovered) {
|
|
6154
6272
|
try {
|
|
6155
6273
|
for (const node of nodes) {
|
|
6156
|
-
const
|
|
6157
|
-
const
|
|
6274
|
+
const x3 = node.x;
|
|
6275
|
+
const y3 = node.y;
|
|
6158
6276
|
const isHovered = isNodeHovered(node.id);
|
|
6159
6277
|
const style = isHovered ? hoverNodeStyle : nodeStyle;
|
|
6160
6278
|
ctx.beginPath();
|
|
6161
|
-
ctx.arc(
|
|
6279
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6162
6280
|
ctx.fillStyle = style.fill;
|
|
6163
6281
|
ctx.globalAlpha = style.opacity;
|
|
6164
6282
|
ctx.fill();
|
|
@@ -6180,8 +6298,8 @@ var NodesRenderer = class {
|
|
|
6180
6298
|
static renderWithStyleResolver(ctx, nodes, styleResolver, isNodeHovered, isNodeSelected, performanceMetrics) {
|
|
6181
6299
|
try {
|
|
6182
6300
|
for (const node of nodes) {
|
|
6183
|
-
const
|
|
6184
|
-
const
|
|
6301
|
+
const x3 = node.x;
|
|
6302
|
+
const y3 = node.y;
|
|
6185
6303
|
const hoverStart = performance.now();
|
|
6186
6304
|
const isHovered = isNodeHovered(node.id);
|
|
6187
6305
|
const isSelected = isNodeSelected ? isNodeSelected(node.id) : false;
|
|
@@ -6199,7 +6317,7 @@ var NodesRenderer = class {
|
|
|
6199
6317
|
}
|
|
6200
6318
|
const canvasStart = performance.now();
|
|
6201
6319
|
ctx.beginPath();
|
|
6202
|
-
ctx.arc(
|
|
6320
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6203
6321
|
ctx.fillStyle = style.fill;
|
|
6204
6322
|
ctx.globalAlpha = style.opacity;
|
|
6205
6323
|
ctx.fill();
|
|
@@ -6225,14 +6343,14 @@ var NodesRenderer = class {
|
|
|
6225
6343
|
try {
|
|
6226
6344
|
for (const node of nodes) {
|
|
6227
6345
|
if (!node.__indexColorRGB) continue;
|
|
6228
|
-
const
|
|
6229
|
-
const
|
|
6346
|
+
const x3 = node.x;
|
|
6347
|
+
const y3 = node.y;
|
|
6230
6348
|
const [r, g, b] = node.__indexColorRGB;
|
|
6231
6349
|
const rgbColor = `rgb(${r},${g},${b})`;
|
|
6232
6350
|
const hitRadius = nodeRadius + 0.5 + 0.1;
|
|
6233
6351
|
shadowCtx.fillStyle = rgbColor;
|
|
6234
6352
|
shadowCtx.beginPath();
|
|
6235
|
-
shadowCtx.arc(
|
|
6353
|
+
shadowCtx.arc(x3, y3, hitRadius, 0, 2 * Math.PI);
|
|
6236
6354
|
shadowCtx.fill();
|
|
6237
6355
|
}
|
|
6238
6356
|
} catch (error) {
|
|
@@ -6267,13 +6385,13 @@ var NodeLabelsRenderer = class {
|
|
|
6267
6385
|
ctx.textBaseline = resolvedStyle.textBaseline;
|
|
6268
6386
|
ctx.fillStyle = resolvedStyle.fillStyle;
|
|
6269
6387
|
for (const node of nodes) {
|
|
6270
|
-
const
|
|
6271
|
-
const
|
|
6388
|
+
const x3 = node.x;
|
|
6389
|
+
const y3 = node.y;
|
|
6272
6390
|
const fullLabel = node.label || node.id;
|
|
6273
6391
|
const maxWidth = nodeRadius * 2 - 6;
|
|
6274
6392
|
const truncatedLabel = this.truncateLabel(ctx, fullLabel, maxWidth);
|
|
6275
|
-
const labelY =
|
|
6276
|
-
ctx.fillText(truncatedLabel,
|
|
6393
|
+
const labelY = y3 + resolvedStyle.offsetY;
|
|
6394
|
+
ctx.fillText(truncatedLabel, x3, labelY);
|
|
6277
6395
|
}
|
|
6278
6396
|
} catch (error) {
|
|
6279
6397
|
ErrorHandler.logError(error);
|
|
@@ -6456,15 +6574,15 @@ var LinkLabelsRenderer = class {
|
|
|
6456
6574
|
/**
|
|
6457
6575
|
* Render a single label at given coordinates
|
|
6458
6576
|
*/
|
|
6459
|
-
static renderSingleLabel(ctx, text,
|
|
6577
|
+
static renderSingleLabel(ctx, text, x3, y3, style) {
|
|
6460
6578
|
ctx.font = style.font ?? "10px Arial";
|
|
6461
6579
|
const metrics = ctx.measureText(text);
|
|
6462
6580
|
const textWidth = metrics.width;
|
|
6463
6581
|
const textHeight = (metrics.actualBoundingBoxAscent || 10) + (metrics.actualBoundingBoxDescent || 4);
|
|
6464
6582
|
const rectWidth = textWidth + (style.paddingX ?? 8) * 2;
|
|
6465
6583
|
const rectHeight = textHeight + (style.paddingY ?? 4) * 2;
|
|
6466
|
-
const rectX =
|
|
6467
|
-
const rectY =
|
|
6584
|
+
const rectX = x3 - rectWidth / 2;
|
|
6585
|
+
const rectY = y3 - rectHeight / 2;
|
|
6468
6586
|
if (style.backgroundColor && style.backgroundColor !== "transparent") {
|
|
6469
6587
|
ctx.fillStyle = style.backgroundColor;
|
|
6470
6588
|
this.roundRect(ctx, rectX, rectY, rectWidth, rectHeight, style.borderRadius ?? 4);
|
|
@@ -6479,26 +6597,26 @@ var LinkLabelsRenderer = class {
|
|
|
6479
6597
|
ctx.fillStyle = style.textColor ?? "#000000";
|
|
6480
6598
|
ctx.textAlign = "center";
|
|
6481
6599
|
ctx.textBaseline = "middle";
|
|
6482
|
-
ctx.fillText(text,
|
|
6600
|
+
ctx.fillText(text, x3, y3);
|
|
6483
6601
|
}
|
|
6484
6602
|
/**
|
|
6485
6603
|
* Helper to draw rounded rectangle
|
|
6486
6604
|
*/
|
|
6487
|
-
static roundRect(ctx,
|
|
6605
|
+
static roundRect(ctx, x3, y3, width, height, radius) {
|
|
6488
6606
|
if (radius === 0) {
|
|
6489
|
-
ctx.rect(
|
|
6607
|
+
ctx.rect(x3, y3, width, height);
|
|
6490
6608
|
return;
|
|
6491
6609
|
}
|
|
6492
6610
|
ctx.beginPath();
|
|
6493
|
-
ctx.moveTo(
|
|
6494
|
-
ctx.lineTo(
|
|
6495
|
-
ctx.quadraticCurveTo(
|
|
6496
|
-
ctx.lineTo(
|
|
6497
|
-
ctx.quadraticCurveTo(
|
|
6498
|
-
ctx.lineTo(
|
|
6499
|
-
ctx.quadraticCurveTo(
|
|
6500
|
-
ctx.lineTo(
|
|
6501
|
-
ctx.quadraticCurveTo(
|
|
6611
|
+
ctx.moveTo(x3 + radius, y3);
|
|
6612
|
+
ctx.lineTo(x3 + width - radius, y3);
|
|
6613
|
+
ctx.quadraticCurveTo(x3 + width, y3, x3 + width, y3 + radius);
|
|
6614
|
+
ctx.lineTo(x3 + width, y3 + height - radius);
|
|
6615
|
+
ctx.quadraticCurveTo(x3 + width, y3 + height, x3 + width - radius, y3 + height);
|
|
6616
|
+
ctx.lineTo(x3 + radius, y3 + height);
|
|
6617
|
+
ctx.quadraticCurveTo(x3, y3 + height, x3, y3 + height - radius);
|
|
6618
|
+
ctx.lineTo(x3, y3 + radius);
|
|
6619
|
+
ctx.quadraticCurveTo(x3, y3, x3 + radius, y3);
|
|
6502
6620
|
ctx.closePath();
|
|
6503
6621
|
}
|
|
6504
6622
|
/**
|
|
@@ -7139,13 +7257,13 @@ var Renderer = class {
|
|
|
7139
7257
|
const arrowTipY = targetPoint.y + arrowLength * Math.sin(angle);
|
|
7140
7258
|
const x1 = arrowTipX - arrowLength * Math.cos(angle - Math.PI / 6);
|
|
7141
7259
|
const y1 = arrowTipY - arrowLength * Math.sin(angle - Math.PI / 6);
|
|
7142
|
-
const
|
|
7143
|
-
const
|
|
7260
|
+
const x22 = arrowTipX - arrowLength * Math.cos(angle + Math.PI / 6);
|
|
7261
|
+
const y22 = arrowTipY - arrowLength * Math.sin(angle + Math.PI / 6);
|
|
7144
7262
|
ctx.fillStyle = arrowStyle.fill ?? "#000000";
|
|
7145
7263
|
ctx.beginPath();
|
|
7146
7264
|
ctx.moveTo(arrowTipX, arrowTipY);
|
|
7147
7265
|
ctx.lineTo(x1, y1);
|
|
7148
|
-
ctx.lineTo(
|
|
7266
|
+
ctx.lineTo(x22, y22);
|
|
7149
7267
|
ctx.closePath();
|
|
7150
7268
|
ctx.fill();
|
|
7151
7269
|
} catch (error) {
|
|
@@ -8554,7 +8672,7 @@ var V2Graph = class {
|
|
|
8554
8672
|
/**
|
|
8555
8673
|
* Draw legend on export canvas
|
|
8556
8674
|
*/
|
|
8557
|
-
drawLegendOnExportCanvas(ctx, legendElement,
|
|
8675
|
+
drawLegendOnExportCanvas(ctx, legendElement, x3, y3) {
|
|
8558
8676
|
const legendItems = legendElement.querySelectorAll(".pg-legend-item");
|
|
8559
8677
|
const padding = 16;
|
|
8560
8678
|
const itemHeight = 24;
|
|
@@ -8564,8 +8682,8 @@ var V2Graph = class {
|
|
|
8564
8682
|
ctx.fillStyle = "#ffffff";
|
|
8565
8683
|
ctx.strokeStyle = "#e2e8f0";
|
|
8566
8684
|
ctx.lineWidth = 1;
|
|
8567
|
-
ctx.fillRect(
|
|
8568
|
-
ctx.strokeRect(
|
|
8685
|
+
ctx.fillRect(x3, y3, legendWidth, legendHeight);
|
|
8686
|
+
ctx.strokeRect(x3, y3, legendWidth, legendHeight);
|
|
8569
8687
|
ctx.font = "12px Arial, sans-serif";
|
|
8570
8688
|
ctx.textAlign = "left";
|
|
8571
8689
|
ctx.textBaseline = "middle";
|
|
@@ -8573,8 +8691,8 @@ var V2Graph = class {
|
|
|
8573
8691
|
const swatch = item.querySelector(".pg-legend-swatch");
|
|
8574
8692
|
const label = item.querySelector(".pg-legend-label");
|
|
8575
8693
|
if (swatch && label) {
|
|
8576
|
-
const itemY =
|
|
8577
|
-
const swatchX =
|
|
8694
|
+
const itemY = y3 + padding + index2 * (itemHeight + itemSpacing) + itemHeight / 2;
|
|
8695
|
+
const swatchX = x3 + padding;
|
|
8578
8696
|
const textX = swatchX + 14 + 8;
|
|
8579
8697
|
const swatchColor = swatch.style.backgroundColor || "#94a3b8";
|
|
8580
8698
|
ctx.fillStyle = swatchColor;
|