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.js
CHANGED
|
@@ -374,14 +374,14 @@ var CanvasUtils = {
|
|
|
374
374
|
/**
|
|
375
375
|
* Safe image data extraction
|
|
376
376
|
*/
|
|
377
|
-
getPixelData(ctx,
|
|
377
|
+
getPixelData(ctx, x3, y3, pixelRatio = window.devicePixelRatio || 1) {
|
|
378
378
|
try {
|
|
379
|
-
if (
|
|
379
|
+
if (x3 <= 0 || y3 <= 0) {
|
|
380
380
|
return null;
|
|
381
381
|
}
|
|
382
382
|
const imageData = ctx.getImageData(
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
x3 * pixelRatio,
|
|
384
|
+
y3 * pixelRatio,
|
|
385
385
|
1,
|
|
386
386
|
1
|
|
387
387
|
);
|
|
@@ -391,8 +391,8 @@ var CanvasUtils = {
|
|
|
391
391
|
return null;
|
|
392
392
|
}
|
|
393
393
|
ErrorHandler.logError(error, {
|
|
394
|
-
x:
|
|
395
|
-
y:
|
|
394
|
+
x: x3,
|
|
395
|
+
y: y3,
|
|
396
396
|
pixelRatio
|
|
397
397
|
});
|
|
398
398
|
return null;
|
|
@@ -1121,16 +1121,16 @@ var CanvasManager = class {
|
|
|
1121
1121
|
};
|
|
1122
1122
|
|
|
1123
1123
|
// node_modules/d3-force/src/center.js
|
|
1124
|
-
function center_default(
|
|
1124
|
+
function center_default(x3, y3) {
|
|
1125
1125
|
var nodes, strength = 1;
|
|
1126
|
-
if (
|
|
1127
|
-
if (
|
|
1126
|
+
if (x3 == null) x3 = 0;
|
|
1127
|
+
if (y3 == null) y3 = 0;
|
|
1128
1128
|
function force() {
|
|
1129
1129
|
var i, n = nodes.length, node, sx = 0, sy = 0;
|
|
1130
1130
|
for (i = 0; i < n; ++i) {
|
|
1131
1131
|
node = nodes[i], sx += node.x, sy += node.y;
|
|
1132
1132
|
}
|
|
1133
|
-
for (sx = (sx / n -
|
|
1133
|
+
for (sx = (sx / n - x3) * strength, sy = (sy / n - y3) * strength, i = 0; i < n; ++i) {
|
|
1134
1134
|
node = nodes[i], node.x -= sx, node.y -= sy;
|
|
1135
1135
|
}
|
|
1136
1136
|
}
|
|
@@ -1138,10 +1138,10 @@ function center_default(x2, y2) {
|
|
|
1138
1138
|
nodes = _;
|
|
1139
1139
|
};
|
|
1140
1140
|
force.x = function(_) {
|
|
1141
|
-
return arguments.length ? (
|
|
1141
|
+
return arguments.length ? (x3 = +_, force) : x3;
|
|
1142
1142
|
};
|
|
1143
1143
|
force.y = function(_) {
|
|
1144
|
-
return arguments.length ? (
|
|
1144
|
+
return arguments.length ? (y3 = +_, force) : y3;
|
|
1145
1145
|
};
|
|
1146
1146
|
force.strength = function(_) {
|
|
1147
1147
|
return arguments.length ? (strength = +_, force) : strength;
|
|
@@ -1151,42 +1151,42 @@ function center_default(x2, y2) {
|
|
|
1151
1151
|
|
|
1152
1152
|
// node_modules/d3-quadtree/src/add.js
|
|
1153
1153
|
function add_default(d) {
|
|
1154
|
-
const
|
|
1155
|
-
return add(this.cover(
|
|
1154
|
+
const x3 = +this._x.call(null, d), y3 = +this._y.call(null, d);
|
|
1155
|
+
return add(this.cover(x3, y3), x3, y3, d);
|
|
1156
1156
|
}
|
|
1157
|
-
function add(tree,
|
|
1158
|
-
if (isNaN(
|
|
1157
|
+
function add(tree, x3, y3, d) {
|
|
1158
|
+
if (isNaN(x3) || isNaN(y3)) return tree;
|
|
1159
1159
|
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;
|
|
1160
1160
|
if (!node) return tree._root = leaf, tree;
|
|
1161
1161
|
while (node.length) {
|
|
1162
|
-
if (right =
|
|
1162
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
1163
1163
|
else x1 = xm;
|
|
1164
|
-
if (bottom =
|
|
1164
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
1165
1165
|
else y1 = ym;
|
|
1166
1166
|
if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
|
|
1167
1167
|
}
|
|
1168
1168
|
xp = +tree._x.call(null, node.data);
|
|
1169
1169
|
yp = +tree._y.call(null, node.data);
|
|
1170
|
-
if (
|
|
1170
|
+
if (x3 === xp && y3 === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
|
|
1171
1171
|
do {
|
|
1172
1172
|
parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
|
|
1173
|
-
if (right =
|
|
1173
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
1174
1174
|
else x1 = xm;
|
|
1175
|
-
if (bottom =
|
|
1175
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
1176
1176
|
else y1 = ym;
|
|
1177
1177
|
} while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm));
|
|
1178
1178
|
return parent[j] = node, parent[i] = leaf, tree;
|
|
1179
1179
|
}
|
|
1180
1180
|
function addAll(data) {
|
|
1181
|
-
var d, i, n = data.length,
|
|
1181
|
+
var d, i, n = data.length, x3, y3, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
1182
1182
|
for (i = 0; i < n; ++i) {
|
|
1183
|
-
if (isNaN(
|
|
1184
|
-
xz[i] =
|
|
1185
|
-
yz[i] =
|
|
1186
|
-
if (
|
|
1187
|
-
if (
|
|
1188
|
-
if (
|
|
1189
|
-
if (
|
|
1183
|
+
if (isNaN(x3 = +this._x.call(null, d = data[i])) || isNaN(y3 = +this._y.call(null, d))) continue;
|
|
1184
|
+
xz[i] = x3;
|
|
1185
|
+
yz[i] = y3;
|
|
1186
|
+
if (x3 < x0) x0 = x3;
|
|
1187
|
+
if (x3 > x1) x1 = x3;
|
|
1188
|
+
if (y3 < y0) y0 = y3;
|
|
1189
|
+
if (y3 > y1) y1 = y3;
|
|
1190
1190
|
}
|
|
1191
1191
|
if (x0 > x1 || y0 > y1) return this;
|
|
1192
1192
|
this.cover(x0, y0).cover(x1, y1);
|
|
@@ -1197,16 +1197,16 @@ function addAll(data) {
|
|
|
1197
1197
|
}
|
|
1198
1198
|
|
|
1199
1199
|
// node_modules/d3-quadtree/src/cover.js
|
|
1200
|
-
function cover_default(
|
|
1201
|
-
if (isNaN(
|
|
1200
|
+
function cover_default(x3, y3) {
|
|
1201
|
+
if (isNaN(x3 = +x3) || isNaN(y3 = +y3)) return this;
|
|
1202
1202
|
var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1;
|
|
1203
1203
|
if (isNaN(x0)) {
|
|
1204
|
-
x1 = (x0 = Math.floor(
|
|
1205
|
-
y1 = (y0 = Math.floor(
|
|
1204
|
+
x1 = (x0 = Math.floor(x3)) + 1;
|
|
1205
|
+
y1 = (y0 = Math.floor(y3)) + 1;
|
|
1206
1206
|
} else {
|
|
1207
1207
|
var z = x1 - x0 || 1, node = this._root, parent, i;
|
|
1208
|
-
while (x0 >
|
|
1209
|
-
i = (
|
|
1208
|
+
while (x0 > x3 || x3 >= x1 || y0 > y3 || y3 >= y1) {
|
|
1209
|
+
i = (y3 < y0) << 1 | x3 < x0;
|
|
1210
1210
|
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
|
|
1211
1211
|
switch (i) {
|
|
1212
1212
|
case 0:
|
|
@@ -1258,17 +1258,17 @@ function quad_default(node, x0, y0, x1, y1) {
|
|
|
1258
1258
|
}
|
|
1259
1259
|
|
|
1260
1260
|
// node_modules/d3-quadtree/src/find.js
|
|
1261
|
-
function find_default(
|
|
1262
|
-
var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22,
|
|
1263
|
-
if (node) quads.push(new quad_default(node, x0, y0,
|
|
1261
|
+
function find_default(x3, y3, radius) {
|
|
1262
|
+
var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22, x32 = this._x1, y32 = this._y1, quads = [], node = this._root, q, i;
|
|
1263
|
+
if (node) quads.push(new quad_default(node, x0, y0, x32, y32));
|
|
1264
1264
|
if (radius == null) radius = Infinity;
|
|
1265
1265
|
else {
|
|
1266
|
-
x0 =
|
|
1267
|
-
|
|
1266
|
+
x0 = x3 - radius, y0 = y3 - radius;
|
|
1267
|
+
x32 = x3 + radius, y32 = y3 + radius;
|
|
1268
1268
|
radius *= radius;
|
|
1269
1269
|
}
|
|
1270
1270
|
while (q = quads.pop()) {
|
|
1271
|
-
if (!(node = q.node) || (x1 = q.x0) >
|
|
1271
|
+
if (!(node = q.node) || (x1 = q.x0) > x32 || (y1 = q.y0) > y32 || (x22 = q.x1) < x0 || (y22 = q.y1) < y0) continue;
|
|
1272
1272
|
if (node.length) {
|
|
1273
1273
|
var xm = (x1 + x22) / 2, ym = (y1 + y22) / 2;
|
|
1274
1274
|
quads.push(
|
|
@@ -1277,17 +1277,17 @@ function find_default(x2, y2, radius) {
|
|
|
1277
1277
|
new quad_default(node[1], xm, y1, x22, ym),
|
|
1278
1278
|
new quad_default(node[0], x1, y1, xm, ym)
|
|
1279
1279
|
);
|
|
1280
|
-
if (i = (
|
|
1280
|
+
if (i = (y3 >= ym) << 1 | x3 >= xm) {
|
|
1281
1281
|
q = quads[quads.length - 1];
|
|
1282
1282
|
quads[quads.length - 1] = quads[quads.length - 1 - i];
|
|
1283
1283
|
quads[quads.length - 1 - i] = q;
|
|
1284
1284
|
}
|
|
1285
1285
|
} else {
|
|
1286
|
-
var dx =
|
|
1286
|
+
var dx = x3 - +this._x.call(null, node.data), dy = y3 - +this._y.call(null, node.data), d2 = dx * dx + dy * dy;
|
|
1287
1287
|
if (d2 < radius) {
|
|
1288
1288
|
var d = Math.sqrt(radius = d2);
|
|
1289
|
-
x0 =
|
|
1290
|
-
|
|
1289
|
+
x0 = x3 - d, y0 = y3 - d;
|
|
1290
|
+
x32 = x3 + d, y32 = y3 + d;
|
|
1291
1291
|
data = node.data;
|
|
1292
1292
|
}
|
|
1293
1293
|
}
|
|
@@ -1297,13 +1297,13 @@ function find_default(x2, y2, radius) {
|
|
|
1297
1297
|
|
|
1298
1298
|
// node_modules/d3-quadtree/src/remove.js
|
|
1299
1299
|
function remove_default(d) {
|
|
1300
|
-
if (isNaN(
|
|
1301
|
-
var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1,
|
|
1300
|
+
if (isNaN(x3 = +this._x.call(null, d)) || isNaN(y3 = +this._y.call(null, d))) return this;
|
|
1301
|
+
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;
|
|
1302
1302
|
if (!node) return this;
|
|
1303
1303
|
if (node.length) while (true) {
|
|
1304
|
-
if (right =
|
|
1304
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
1305
1305
|
else x1 = xm;
|
|
1306
|
-
if (bottom =
|
|
1306
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
1307
1307
|
else y1 = ym;
|
|
1308
1308
|
if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
|
|
1309
1309
|
if (!node.length) break;
|
|
@@ -1395,13 +1395,13 @@ function y_default(_) {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
1397
|
// node_modules/d3-quadtree/src/quadtree.js
|
|
1398
|
-
function quadtree(nodes,
|
|
1399
|
-
var tree = new Quadtree(
|
|
1398
|
+
function quadtree(nodes, x3, y3) {
|
|
1399
|
+
var tree = new Quadtree(x3 == null ? defaultX : x3, y3 == null ? defaultY : y3, NaN, NaN, NaN, NaN);
|
|
1400
1400
|
return nodes == null ? tree : tree.addAll(nodes);
|
|
1401
1401
|
}
|
|
1402
|
-
function Quadtree(
|
|
1403
|
-
this._x =
|
|
1404
|
-
this._y =
|
|
1402
|
+
function Quadtree(x3, y3, x0, y0, x1, y1) {
|
|
1403
|
+
this._x = x3;
|
|
1404
|
+
this._y = y3;
|
|
1405
1405
|
this._x0 = x0;
|
|
1406
1406
|
this._y0 = y0;
|
|
1407
1407
|
this._x1 = x1;
|
|
@@ -1445,9 +1445,9 @@ treeProto.x = x_default;
|
|
|
1445
1445
|
treeProto.y = y_default;
|
|
1446
1446
|
|
|
1447
1447
|
// node_modules/d3-force/src/constant.js
|
|
1448
|
-
function constant_default(
|
|
1448
|
+
function constant_default(x3) {
|
|
1449
1449
|
return function() {
|
|
1450
|
-
return
|
|
1450
|
+
return x3;
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
1453
|
|
|
@@ -1456,6 +1456,79 @@ function jiggle_default(random) {
|
|
|
1456
1456
|
return (random() - 0.5) * 1e-6;
|
|
1457
1457
|
}
|
|
1458
1458
|
|
|
1459
|
+
// node_modules/d3-force/src/collide.js
|
|
1460
|
+
function x(d) {
|
|
1461
|
+
return d.x + d.vx;
|
|
1462
|
+
}
|
|
1463
|
+
function y(d) {
|
|
1464
|
+
return d.y + d.vy;
|
|
1465
|
+
}
|
|
1466
|
+
function collide_default(radius) {
|
|
1467
|
+
var nodes, radii, random, strength = 1, iterations = 1;
|
|
1468
|
+
if (typeof radius !== "function") radius = constant_default(radius == null ? 1 : +radius);
|
|
1469
|
+
function force() {
|
|
1470
|
+
var i, n = nodes.length, tree, node, xi, yi, ri, ri2;
|
|
1471
|
+
for (var k = 0; k < iterations; ++k) {
|
|
1472
|
+
tree = quadtree(nodes, x, y).visitAfter(prepare);
|
|
1473
|
+
for (i = 0; i < n; ++i) {
|
|
1474
|
+
node = nodes[i];
|
|
1475
|
+
ri = radii[node.index], ri2 = ri * ri;
|
|
1476
|
+
xi = node.x + node.vx;
|
|
1477
|
+
yi = node.y + node.vy;
|
|
1478
|
+
tree.visit(apply);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
function apply(quad, x0, y0, x1, y1) {
|
|
1482
|
+
var data = quad.data, rj = quad.r, r = ri + rj;
|
|
1483
|
+
if (data) {
|
|
1484
|
+
if (data.index > node.index) {
|
|
1485
|
+
var x3 = xi - data.x - data.vx, y3 = yi - data.y - data.vy, l = x3 * x3 + y3 * y3;
|
|
1486
|
+
if (l < r * r) {
|
|
1487
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
1488
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
1489
|
+
l = (r - (l = Math.sqrt(l))) / l * strength;
|
|
1490
|
+
node.vx += (x3 *= l) * (r = (rj *= rj) / (ri2 + rj));
|
|
1491
|
+
node.vy += (y3 *= l) * r;
|
|
1492
|
+
data.vx -= x3 * (r = 1 - r);
|
|
1493
|
+
data.vy -= y3 * r;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
function prepare(quad) {
|
|
1502
|
+
if (quad.data) return quad.r = radii[quad.data.index];
|
|
1503
|
+
for (var i = quad.r = 0; i < 4; ++i) {
|
|
1504
|
+
if (quad[i] && quad[i].r > quad.r) {
|
|
1505
|
+
quad.r = quad[i].r;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
function initialize() {
|
|
1510
|
+
if (!nodes) return;
|
|
1511
|
+
var i, n = nodes.length, node;
|
|
1512
|
+
radii = new Array(n);
|
|
1513
|
+
for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
|
|
1514
|
+
}
|
|
1515
|
+
force.initialize = function(_nodes, _random) {
|
|
1516
|
+
nodes = _nodes;
|
|
1517
|
+
random = _random;
|
|
1518
|
+
initialize();
|
|
1519
|
+
};
|
|
1520
|
+
force.iterations = function(_) {
|
|
1521
|
+
return arguments.length ? (iterations = +_, force) : iterations;
|
|
1522
|
+
};
|
|
1523
|
+
force.strength = function(_) {
|
|
1524
|
+
return arguments.length ? (strength = +_, force) : strength;
|
|
1525
|
+
};
|
|
1526
|
+
force.radius = function(_) {
|
|
1527
|
+
return arguments.length ? (radius = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : radius;
|
|
1528
|
+
};
|
|
1529
|
+
return force;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1459
1532
|
// node_modules/d3-force/src/link.js
|
|
1460
1533
|
function index(d) {
|
|
1461
1534
|
return d.index;
|
|
@@ -1473,17 +1546,17 @@ function link_default(links) {
|
|
|
1473
1546
|
}
|
|
1474
1547
|
function force(alpha) {
|
|
1475
1548
|
for (var k = 0, n = links.length; k < iterations; ++k) {
|
|
1476
|
-
for (var i = 0, link, source, target,
|
|
1549
|
+
for (var i = 0, link, source, target, x3, y3, l, b; i < n; ++i) {
|
|
1477
1550
|
link = links[i], source = link.source, target = link.target;
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
l = Math.sqrt(
|
|
1551
|
+
x3 = target.x + target.vx - source.x - source.vx || jiggle_default(random);
|
|
1552
|
+
y3 = target.y + target.vy - source.y - source.vy || jiggle_default(random);
|
|
1553
|
+
l = Math.sqrt(x3 * x3 + y3 * y3);
|
|
1481
1554
|
l = (l - distances[i]) / l * alpha * strengths[i];
|
|
1482
|
-
|
|
1483
|
-
target.vx -=
|
|
1484
|
-
target.vy -=
|
|
1485
|
-
source.vx +=
|
|
1486
|
-
source.vy +=
|
|
1555
|
+
x3 *= l, y3 *= l;
|
|
1556
|
+
target.vx -= x3 * (b = bias[i]);
|
|
1557
|
+
target.vy -= y3 * b;
|
|
1558
|
+
source.vx += x3 * (b = 1 - b);
|
|
1559
|
+
source.vy += y3 * b;
|
|
1487
1560
|
}
|
|
1488
1561
|
}
|
|
1489
1562
|
}
|
|
@@ -1731,10 +1804,10 @@ function lcg_default() {
|
|
|
1731
1804
|
}
|
|
1732
1805
|
|
|
1733
1806
|
// node_modules/d3-force/src/simulation.js
|
|
1734
|
-
function
|
|
1807
|
+
function x2(d) {
|
|
1735
1808
|
return d.x;
|
|
1736
1809
|
}
|
|
1737
|
-
function
|
|
1810
|
+
function y2(d) {
|
|
1738
1811
|
return d.y;
|
|
1739
1812
|
}
|
|
1740
1813
|
var initialRadius = 10;
|
|
@@ -1820,14 +1893,14 @@ function simulation_default(nodes) {
|
|
|
1820
1893
|
force: function(name, _) {
|
|
1821
1894
|
return arguments.length > 1 ? (_ == null ? forces.delete(name) : forces.set(name, initializeForce(_)), simulation) : forces.get(name);
|
|
1822
1895
|
},
|
|
1823
|
-
find: function(
|
|
1896
|
+
find: function(x3, y3, radius) {
|
|
1824
1897
|
var i = 0, n = nodes.length, dx, dy, d2, node, closest;
|
|
1825
1898
|
if (radius == null) radius = Infinity;
|
|
1826
1899
|
else radius *= radius;
|
|
1827
1900
|
for (i = 0; i < n; ++i) {
|
|
1828
1901
|
node = nodes[i];
|
|
1829
|
-
dx =
|
|
1830
|
-
dy =
|
|
1902
|
+
dx = x3 - node.x;
|
|
1903
|
+
dy = y3 - node.y;
|
|
1831
1904
|
d2 = dx * dx + dy * dy;
|
|
1832
1905
|
if (d2 < radius) closest = node, radius = d2;
|
|
1833
1906
|
}
|
|
@@ -1843,7 +1916,7 @@ function simulation_default(nodes) {
|
|
|
1843
1916
|
function manyBody_default() {
|
|
1844
1917
|
var nodes, node, random, alpha, strength = constant_default(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81;
|
|
1845
1918
|
function force(_) {
|
|
1846
|
-
var i, n = nodes.length, tree = quadtree(nodes,
|
|
1919
|
+
var i, n = nodes.length, tree = quadtree(nodes, x2, y2).visitAfter(accumulate);
|
|
1847
1920
|
for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
|
|
1848
1921
|
}
|
|
1849
1922
|
function initialize() {
|
|
@@ -1853,15 +1926,15 @@ function manyBody_default() {
|
|
|
1853
1926
|
for (i = 0; i < n; ++i) node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes);
|
|
1854
1927
|
}
|
|
1855
1928
|
function accumulate(quad) {
|
|
1856
|
-
var strength2 = 0, q, c2, weight = 0,
|
|
1929
|
+
var strength2 = 0, q, c2, weight = 0, x3, y3, i;
|
|
1857
1930
|
if (quad.length) {
|
|
1858
|
-
for (
|
|
1931
|
+
for (x3 = y3 = i = 0; i < 4; ++i) {
|
|
1859
1932
|
if ((q = quad[i]) && (c2 = Math.abs(q.value))) {
|
|
1860
|
-
strength2 += q.value, weight += c2,
|
|
1933
|
+
strength2 += q.value, weight += c2, x3 += c2 * q.x, y3 += c2 * q.y;
|
|
1861
1934
|
}
|
|
1862
1935
|
}
|
|
1863
|
-
quad.x =
|
|
1864
|
-
quad.y =
|
|
1936
|
+
quad.x = x3 / weight;
|
|
1937
|
+
quad.y = y3 / weight;
|
|
1865
1938
|
} else {
|
|
1866
1939
|
q = quad;
|
|
1867
1940
|
q.x = q.data.x;
|
|
@@ -1872,29 +1945,29 @@ function manyBody_default() {
|
|
|
1872
1945
|
}
|
|
1873
1946
|
quad.value = strength2;
|
|
1874
1947
|
}
|
|
1875
|
-
function apply(quad, x1, _,
|
|
1948
|
+
function apply(quad, x1, _, x22) {
|
|
1876
1949
|
if (!quad.value) return true;
|
|
1877
|
-
var x3 = quad.x - node.x,
|
|
1950
|
+
var x3 = quad.x - node.x, y3 = quad.y - node.y, w = x22 - x1, l = x3 * x3 + y3 * y3;
|
|
1878
1951
|
if (w * w / theta2 < l) {
|
|
1879
1952
|
if (l < distanceMax2) {
|
|
1880
1953
|
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
1881
|
-
if (
|
|
1954
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
1882
1955
|
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
1883
1956
|
node.vx += x3 * quad.value * alpha / l;
|
|
1884
|
-
node.vy +=
|
|
1957
|
+
node.vy += y3 * quad.value * alpha / l;
|
|
1885
1958
|
}
|
|
1886
1959
|
return true;
|
|
1887
1960
|
} else if (quad.length || l >= distanceMax2) return;
|
|
1888
1961
|
if (quad.data !== node || quad.next) {
|
|
1889
1962
|
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
1890
|
-
if (
|
|
1963
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
1891
1964
|
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
1892
1965
|
}
|
|
1893
1966
|
do
|
|
1894
1967
|
if (quad.data !== node) {
|
|
1895
1968
|
w = strengths[quad.data.index] * alpha / l;
|
|
1896
1969
|
node.vx += x3 * w;
|
|
1897
|
-
node.vy +=
|
|
1970
|
+
node.vy += y3 * w;
|
|
1898
1971
|
}
|
|
1899
1972
|
while (quad = quad.next);
|
|
1900
1973
|
}
|
|
@@ -1924,9 +1997,10 @@ var PhysicsManager = class {
|
|
|
1924
1997
|
config;
|
|
1925
1998
|
simulationStartTime;
|
|
1926
1999
|
simulationEndTime;
|
|
1927
|
-
cooldownTimer;
|
|
1928
2000
|
hasInitialAutoFitCompleted = false;
|
|
1929
2001
|
timerManager;
|
|
2002
|
+
isVisibilityListenerAttached = false;
|
|
2003
|
+
nodeMap = /* @__PURE__ */ new Map();
|
|
1930
2004
|
constructor(timerManager) {
|
|
1931
2005
|
this.timerManager = timerManager;
|
|
1932
2006
|
}
|
|
@@ -1940,43 +2014,49 @@ var PhysicsManager = class {
|
|
|
1940
2014
|
if (typeof config.onTick !== "function") {
|
|
1941
2015
|
throw new ValidationError("onTick callback is required and must be a function");
|
|
1942
2016
|
}
|
|
2017
|
+
if (!this.isVisibilityListenerAttached) {
|
|
2018
|
+
document.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
2019
|
+
this.isVisibilityListenerAttached = true;
|
|
2020
|
+
}
|
|
1943
2021
|
this.config = config;
|
|
1944
2022
|
this.simulationStartTime = performance.now();
|
|
1945
2023
|
const nodeCount = config.nodes.length;
|
|
1946
|
-
const
|
|
1947
|
-
const graphArea = config.width * config.height;
|
|
1948
|
-
const baseChargeStrength = -600;
|
|
2024
|
+
const graphArea = Math.max(config.width * config.height, 1);
|
|
1949
2025
|
const nodeDensity = nodeCount / (graphArea / 1e5);
|
|
1950
2026
|
const densityFactor = Math.min(nodeDensity, 2);
|
|
1951
|
-
const adaptiveChargeStrength = baseChargeStrength / (1 + densityFactor * 0.4);
|
|
1952
2027
|
const baseVelocityDecay = 0.4;
|
|
1953
2028
|
const adaptiveVelocityDecay = Math.min(baseVelocityDecay + densityFactor * 0.2, 0.8);
|
|
1954
2029
|
const baseAlphaDecay = 0.02;
|
|
1955
2030
|
const adaptiveAlphaDecay = Math.min(baseAlphaDecay + densityFactor * 0.01, 0.05);
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
});
|
|
2031
|
+
if (this.simulation) {
|
|
2032
|
+
this.simulation.stop();
|
|
2033
|
+
}
|
|
2034
|
+
this.buildNodeIndex();
|
|
2035
|
+
const linkDistance = nodeCount > 1e4 ? 220 : nodeCount > 5e3 ? 190 : nodeCount > 2e3 ? 170 : 150;
|
|
2036
|
+
const chargeStrength = nodeCount > 1e4 ? -350 : nodeCount > 5e3 ? -400 : nodeCount > 2e3 ? -450 : -500;
|
|
2037
|
+
const collisionRadius = nodeCount > 1e4 ? 1 : nodeCount > 5e3 ? 2 : 2;
|
|
2038
|
+
const collisionIterations = nodeCount > 1e4 ? 1 : nodeCount > 5e3 ? 1 : 2;
|
|
2039
|
+
const centerStrength = nodeCount > 5e3 ? 0.15 : 0.5;
|
|
2040
|
+
const linkStrength = nodeCount > 1e4 ? 0.15 : nodeCount > 5e3 ? 0.25 : 0.4;
|
|
1967
2041
|
this.simulation = simulation_default(config.nodes).force(
|
|
1968
2042
|
"link",
|
|
1969
|
-
link_default(config.links).id((d) => d.id).distance(
|
|
1970
|
-
// Much weaker link strength to allow repulsion to work
|
|
2043
|
+
link_default(config.links).id((d) => d.id).distance(linkDistance).strength(linkStrength).iterations(1)
|
|
1971
2044
|
).force(
|
|
1972
2045
|
"charge",
|
|
1973
|
-
manyBody_default().strength(
|
|
1974
|
-
|
|
2046
|
+
manyBody_default().strength(chargeStrength).theta(nodeCount > 5e3 ? 1.2 : 0.9).distanceMax(nodeCount > 5e3 ? 500 : 1e3)
|
|
2047
|
+
).force(
|
|
2048
|
+
"collision",
|
|
2049
|
+
collide_default().radius((node) => (node.style?.radius ?? 20) + collisionRadius).strength(1).iterations(collisionIterations)
|
|
1975
2050
|
).force(
|
|
1976
2051
|
"center",
|
|
1977
|
-
center_default(0, 0).strength(
|
|
1978
|
-
|
|
1979
|
-
|
|
2052
|
+
center_default(0, 0).strength(centerStrength)
|
|
2053
|
+
).velocityDecay(
|
|
2054
|
+
nodeCount > 5e3 ? 0.65 : adaptiveVelocityDecay
|
|
2055
|
+
).alphaDecay(
|
|
2056
|
+
nodeCount > 5e3 ? 0.05 : adaptiveAlphaDecay
|
|
2057
|
+
).alphaMin(
|
|
2058
|
+
nodeCount > 5e3 ? 0.05 : 1e-3
|
|
2059
|
+
).on("tick", config.onTick).on("end", () => this.handleSimulationEnd());
|
|
1980
2060
|
if (config.cooldownTime) {
|
|
1981
2061
|
this.setupCooldownTimer(config.cooldownTime);
|
|
1982
2062
|
}
|
|
@@ -2029,6 +2109,34 @@ var PhysicsManager = class {
|
|
|
2029
2109
|
ErrorHandler.logError(error, { cooldownTime });
|
|
2030
2110
|
}
|
|
2031
2111
|
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Build node index for O(1) lookups (Step 3 optimization)
|
|
2114
|
+
*/
|
|
2115
|
+
buildNodeIndex() {
|
|
2116
|
+
if (!this.config) return;
|
|
2117
|
+
try {
|
|
2118
|
+
this.nodeMap.clear();
|
|
2119
|
+
for (const node of this.config.nodes) {
|
|
2120
|
+
this.nodeMap.set(node.id, node);
|
|
2121
|
+
}
|
|
2122
|
+
for (const link of this.config.links) {
|
|
2123
|
+
if (typeof link.source === "string") {
|
|
2124
|
+
const sourceNode = this.nodeMap.get(link.source);
|
|
2125
|
+
if (sourceNode) {
|
|
2126
|
+
link.source = sourceNode;
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
if (typeof link.target === "string") {
|
|
2130
|
+
const targetNode = this.nodeMap.get(link.target);
|
|
2131
|
+
if (targetNode) {
|
|
2132
|
+
link.target = targetNode;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
} catch (error) {
|
|
2137
|
+
ErrorHandler.logError(error);
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2032
2140
|
/**
|
|
2033
2141
|
* Get simulation instance
|
|
2034
2142
|
*/
|
|
@@ -2041,11 +2149,15 @@ var PhysicsManager = class {
|
|
|
2041
2149
|
/**
|
|
2042
2150
|
* Reheat simulation for drag interactions
|
|
2043
2151
|
*/
|
|
2044
|
-
reheat(alphaTarget
|
|
2045
|
-
if (!this.simulation)
|
|
2152
|
+
reheat(alphaTarget) {
|
|
2153
|
+
if (!this.simulation || !this.config) {
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
const nodeCount = this.config.nodes.length;
|
|
2157
|
+
const effectiveAlpha = alphaTarget ?? (nodeCount > 1e4 ? 5e-3 : nodeCount > 5e3 ? 0.01 : nodeCount > 2e3 ? 0.02 : 0.1);
|
|
2046
2158
|
try {
|
|
2047
|
-
this.simulation.alphaTarget(
|
|
2048
|
-
if (this.config
|
|
2159
|
+
this.simulation.alphaTarget(effectiveAlpha).restart();
|
|
2160
|
+
if (this.config.cooldownTime) {
|
|
2049
2161
|
this.setupCooldownTimer(this.config.cooldownTime);
|
|
2050
2162
|
}
|
|
2051
2163
|
} catch (error) {
|
|
@@ -2101,12 +2213,12 @@ var PhysicsManager = class {
|
|
|
2101
2213
|
* Update center force position for new canvas dimensions
|
|
2102
2214
|
* Following force-graph pattern for container resizing
|
|
2103
2215
|
*/
|
|
2104
|
-
updateCenterForce(
|
|
2216
|
+
updateCenterForce(x3, y3) {
|
|
2105
2217
|
if (!this.simulation) return;
|
|
2106
2218
|
try {
|
|
2107
|
-
this.simulation.force("center", center_default(
|
|
2219
|
+
this.simulation.force("center", center_default(x3, y3).strength(0.1));
|
|
2108
2220
|
} catch (error) {
|
|
2109
|
-
ErrorHandler.logError(error, { x:
|
|
2221
|
+
ErrorHandler.logError(error, { x: x3, y: y3 });
|
|
2110
2222
|
}
|
|
2111
2223
|
}
|
|
2112
2224
|
/**
|
|
@@ -2115,14 +2227,14 @@ var PhysicsManager = class {
|
|
|
2115
2227
|
adjustLinkDistancesForVisualShortening() {
|
|
2116
2228
|
if (!this.simulation || !this.config) return;
|
|
2117
2229
|
try {
|
|
2230
|
+
const baseDistance = this.calculateBaseDistance();
|
|
2118
2231
|
const linkForce = this.simulation.force("link");
|
|
2119
2232
|
if (linkForce) {
|
|
2120
2233
|
linkForce.distance((link) => {
|
|
2121
|
-
const
|
|
2122
|
-
const
|
|
2123
|
-
const
|
|
2124
|
-
const
|
|
2125
|
-
const targetRadius = this.getNodeRadius(targetNode);
|
|
2234
|
+
const sourceNode = typeof link.source === "string" ? this.nodeMap.get(link.source) : link.source;
|
|
2235
|
+
const targetNode = typeof link.target === "string" ? this.nodeMap.get(link.target) : link.target;
|
|
2236
|
+
const sourceRadius = sourceNode?.style?.radius ?? 20;
|
|
2237
|
+
const targetRadius = targetNode?.style?.radius ?? 20;
|
|
2126
2238
|
const arrowLength = this.getLinkArrowLength(link);
|
|
2127
2239
|
const visualCompensation = sourceRadius + targetRadius + arrowLength;
|
|
2128
2240
|
const spacingBuffer = Math.max(20, (sourceRadius + targetRadius) * 0.5);
|
|
@@ -2140,23 +2252,10 @@ var PhysicsManager = class {
|
|
|
2140
2252
|
calculateBaseDistance() {
|
|
2141
2253
|
if (!this.config) return 120;
|
|
2142
2254
|
const nodeCount = this.config.nodes.length;
|
|
2143
|
-
const graphArea = this.config.width * this.config.height;
|
|
2255
|
+
const graphArea = Math.max(this.config.width * this.config.height, 1);
|
|
2144
2256
|
const nodeAreaRatio = nodeCount / (graphArea / 1e4);
|
|
2145
2257
|
return Math.max(80, Math.min(200, 120 + nodeAreaRatio * 20));
|
|
2146
2258
|
}
|
|
2147
|
-
/**
|
|
2148
|
-
* Find node by ID
|
|
2149
|
-
*/
|
|
2150
|
-
findNodeById(id2) {
|
|
2151
|
-
return this.config?.nodes.find((node) => node.id === id2);
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* Get node radius from style or default
|
|
2155
|
-
*/
|
|
2156
|
-
getNodeRadius(node) {
|
|
2157
|
-
if (!node) return 20;
|
|
2158
|
-
return node.style?.radius ?? 20;
|
|
2159
|
-
}
|
|
2160
2259
|
/**
|
|
2161
2260
|
* Get arrow length from link style or default
|
|
2162
2261
|
*/
|
|
@@ -2173,7 +2272,7 @@ var PhysicsManager = class {
|
|
|
2173
2272
|
if (!this.config) return;
|
|
2174
2273
|
try {
|
|
2175
2274
|
for (const node of this.config.nodes) {
|
|
2176
|
-
if (
|
|
2275
|
+
if (node.x == null || node.y == null) {
|
|
2177
2276
|
node.x = Math.random() * this.config.width;
|
|
2178
2277
|
node.y = Math.random() * this.config.height;
|
|
2179
2278
|
}
|
|
@@ -2221,30 +2320,49 @@ var PhysicsManager = class {
|
|
|
2221
2320
|
* Pause the simulation
|
|
2222
2321
|
*/
|
|
2223
2322
|
pause() {
|
|
2224
|
-
if (this.simulation) {
|
|
2225
|
-
|
|
2323
|
+
if (!this.simulation) {
|
|
2324
|
+
return;
|
|
2226
2325
|
}
|
|
2326
|
+
this.timerManager.clearTimer("simulationCooldown");
|
|
2327
|
+
this.simulation.stop();
|
|
2227
2328
|
}
|
|
2228
2329
|
/**
|
|
2229
2330
|
* Resume the simulation
|
|
2230
2331
|
*/
|
|
2231
2332
|
resume() {
|
|
2232
|
-
if (this.simulation) {
|
|
2233
|
-
|
|
2333
|
+
if (!this.simulation) {
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
const nodeCount = this.config?.nodes.length ?? 0;
|
|
2337
|
+
const alpha = nodeCount > 1e4 ? 0.01 : nodeCount > 5e3 ? 0.02 : nodeCount > 2e3 ? 0.05 : 0.3;
|
|
2338
|
+
this.simulation.alpha(alpha).alphaTarget(0).restart();
|
|
2339
|
+
if (this.config?.cooldownTime) {
|
|
2340
|
+
this.setupCooldownTimer(this.config.cooldownTime);
|
|
2234
2341
|
}
|
|
2235
2342
|
}
|
|
2343
|
+
handleVisibilityChange = () => {
|
|
2344
|
+
if (document.visibilityState !== "visible") {
|
|
2345
|
+
this.pause();
|
|
2346
|
+
} else {
|
|
2347
|
+
this.resume();
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2236
2350
|
/**
|
|
2237
2351
|
* Destroy physics simulation
|
|
2238
2352
|
*/
|
|
2239
2353
|
destroy() {
|
|
2240
2354
|
try {
|
|
2355
|
+
if (this.isVisibilityListenerAttached) {
|
|
2356
|
+
document.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
2357
|
+
this.isVisibilityListenerAttached = false;
|
|
2358
|
+
}
|
|
2241
2359
|
this.timerManager.clearTimer("simulationCooldown");
|
|
2242
|
-
this.cooldownTimer = void 0;
|
|
2243
2360
|
if (this.simulation) {
|
|
2244
2361
|
this.simulation.stop();
|
|
2245
2362
|
this.simulation = void 0;
|
|
2246
2363
|
}
|
|
2247
2364
|
this.config = void 0;
|
|
2365
|
+
this.nodeMap.clear();
|
|
2248
2366
|
this.simulationStartTime = void 0;
|
|
2249
2367
|
this.simulationEndTime = void 0;
|
|
2250
2368
|
this.hasInitialAutoFitCompleted = false;
|
|
@@ -2323,8 +2441,8 @@ function select_default(select) {
|
|
|
2323
2441
|
}
|
|
2324
2442
|
|
|
2325
2443
|
// node_modules/d3-selection/src/array.js
|
|
2326
|
-
function array(
|
|
2327
|
-
return
|
|
2444
|
+
function array(x3) {
|
|
2445
|
+
return x3 == null ? [] : Array.isArray(x3) ? x3 : Array.from(x3);
|
|
2328
2446
|
}
|
|
2329
2447
|
|
|
2330
2448
|
// node_modules/d3-selection/src/selectorAll.js
|
|
@@ -2443,9 +2561,9 @@ EnterNode.prototype = {
|
|
|
2443
2561
|
};
|
|
2444
2562
|
|
|
2445
2563
|
// node_modules/d3-selection/src/constant.js
|
|
2446
|
-
function constant_default2(
|
|
2564
|
+
function constant_default2(x3) {
|
|
2447
2565
|
return function() {
|
|
2448
|
-
return
|
|
2566
|
+
return x3;
|
|
2449
2567
|
};
|
|
2450
2568
|
}
|
|
2451
2569
|
|
|
@@ -3118,7 +3236,7 @@ function yesdrag(view, noclick) {
|
|
|
3118
3236
|
}
|
|
3119
3237
|
|
|
3120
3238
|
// node_modules/d3-drag/src/constant.js
|
|
3121
|
-
var constant_default3 = (
|
|
3239
|
+
var constant_default3 = (x3) => () => x3;
|
|
3122
3240
|
|
|
3123
3241
|
// node_modules/d3-drag/src/event.js
|
|
3124
3242
|
function DragEvent(type, {
|
|
@@ -3127,8 +3245,8 @@ function DragEvent(type, {
|
|
|
3127
3245
|
target,
|
|
3128
3246
|
identifier,
|
|
3129
3247
|
active,
|
|
3130
|
-
x:
|
|
3131
|
-
y:
|
|
3248
|
+
x: x3,
|
|
3249
|
+
y: y3,
|
|
3132
3250
|
dx,
|
|
3133
3251
|
dy,
|
|
3134
3252
|
dispatch: dispatch2
|
|
@@ -3140,8 +3258,8 @@ function DragEvent(type, {
|
|
|
3140
3258
|
target: { value: target, enumerable: true, configurable: true },
|
|
3141
3259
|
identifier: { value: identifier, enumerable: true, configurable: true },
|
|
3142
3260
|
active: { value: active, enumerable: true, configurable: true },
|
|
3143
|
-
x: { value:
|
|
3144
|
-
y: { value:
|
|
3261
|
+
x: { value: x3, enumerable: true, configurable: true },
|
|
3262
|
+
y: { value: y3, enumerable: true, configurable: true },
|
|
3145
3263
|
dx: { value: dx, enumerable: true, configurable: true },
|
|
3146
3264
|
dy: { value: dy, enumerable: true, configurable: true },
|
|
3147
3265
|
_: { value: dispatch2 }
|
|
@@ -3668,7 +3786,7 @@ function basisClosed_default(values) {
|
|
|
3668
3786
|
}
|
|
3669
3787
|
|
|
3670
3788
|
// node_modules/d3-interpolate/src/constant.js
|
|
3671
|
-
var constant_default4 = (
|
|
3789
|
+
var constant_default4 = (x3) => () => x3;
|
|
3672
3790
|
|
|
3673
3791
|
// node_modules/d3-interpolate/src/color.js
|
|
3674
3792
|
function linear(a2, d) {
|
|
@@ -3676,14 +3794,14 @@ function linear(a2, d) {
|
|
|
3676
3794
|
return a2 + t * d;
|
|
3677
3795
|
};
|
|
3678
3796
|
}
|
|
3679
|
-
function exponential(a2, b,
|
|
3680
|
-
return a2 = Math.pow(a2,
|
|
3681
|
-
return Math.pow(a2 + t * b,
|
|
3797
|
+
function exponential(a2, b, y3) {
|
|
3798
|
+
return a2 = Math.pow(a2, y3), b = Math.pow(b, y3) - a2, y3 = 1 / y3, function(t) {
|
|
3799
|
+
return Math.pow(a2 + t * b, y3);
|
|
3682
3800
|
};
|
|
3683
3801
|
}
|
|
3684
|
-
function gamma(
|
|
3685
|
-
return (
|
|
3686
|
-
return b - a2 ? exponential(a2, b,
|
|
3802
|
+
function gamma(y3) {
|
|
3803
|
+
return (y3 = +y3) === 1 ? nogamma : function(a2, b) {
|
|
3804
|
+
return b - a2 ? exponential(a2, b, y3) : constant_default4(isNaN(a2) ? b : a2);
|
|
3687
3805
|
};
|
|
3688
3806
|
}
|
|
3689
3807
|
function nogamma(a2, b) {
|
|
@@ -3692,8 +3810,8 @@ function nogamma(a2, b) {
|
|
|
3692
3810
|
}
|
|
3693
3811
|
|
|
3694
3812
|
// node_modules/d3-interpolate/src/rgb.js
|
|
3695
|
-
var rgb_default = (function rgbGamma(
|
|
3696
|
-
var color2 = gamma(
|
|
3813
|
+
var rgb_default = (function rgbGamma(y3) {
|
|
3814
|
+
var color2 = gamma(y3);
|
|
3697
3815
|
function rgb2(start2, end) {
|
|
3698
3816
|
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);
|
|
3699
3817
|
return function(t) {
|
|
@@ -3878,14 +3996,14 @@ var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
|
|
|
3878
3996
|
|
|
3879
3997
|
// node_modules/d3-interpolate/src/zoom.js
|
|
3880
3998
|
var epsilon2 = 1e-12;
|
|
3881
|
-
function cosh(
|
|
3882
|
-
return ((
|
|
3999
|
+
function cosh(x3) {
|
|
4000
|
+
return ((x3 = Math.exp(x3)) + 1 / x3) / 2;
|
|
3883
4001
|
}
|
|
3884
|
-
function sinh(
|
|
3885
|
-
return ((
|
|
4002
|
+
function sinh(x3) {
|
|
4003
|
+
return ((x3 = Math.exp(x3)) - 1 / x3) / 2;
|
|
3886
4004
|
}
|
|
3887
|
-
function tanh(
|
|
3888
|
-
return ((
|
|
4005
|
+
function tanh(x3) {
|
|
4006
|
+
return ((x3 = Math.exp(2 * x3)) - 1) / (x3 + 1);
|
|
3889
4007
|
}
|
|
3890
4008
|
var zoom_default = (function zoomRho(rho, rho2, rho4) {
|
|
3891
4009
|
function zoom(p0, p1) {
|
|
@@ -4613,7 +4731,7 @@ selection_default.prototype.interrupt = interrupt_default2;
|
|
|
4613
4731
|
selection_default.prototype.transition = transition_default2;
|
|
4614
4732
|
|
|
4615
4733
|
// node_modules/d3-zoom/src/constant.js
|
|
4616
|
-
var constant_default5 = (
|
|
4734
|
+
var constant_default5 = (x3) => () => x3;
|
|
4617
4735
|
|
|
4618
4736
|
// node_modules/d3-zoom/src/event.js
|
|
4619
4737
|
function ZoomEvent(type, {
|
|
@@ -4632,42 +4750,42 @@ function ZoomEvent(type, {
|
|
|
4632
4750
|
}
|
|
4633
4751
|
|
|
4634
4752
|
// node_modules/d3-zoom/src/transform.js
|
|
4635
|
-
function Transform(k,
|
|
4753
|
+
function Transform(k, x3, y3) {
|
|
4636
4754
|
this.k = k;
|
|
4637
|
-
this.x =
|
|
4638
|
-
this.y =
|
|
4755
|
+
this.x = x3;
|
|
4756
|
+
this.y = y3;
|
|
4639
4757
|
}
|
|
4640
4758
|
Transform.prototype = {
|
|
4641
4759
|
constructor: Transform,
|
|
4642
4760
|
scale: function(k) {
|
|
4643
4761
|
return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
|
|
4644
4762
|
},
|
|
4645
|
-
translate: function(
|
|
4646
|
-
return
|
|
4763
|
+
translate: function(x3, y3) {
|
|
4764
|
+
return x3 === 0 & y3 === 0 ? this : new Transform(this.k, this.x + this.k * x3, this.y + this.k * y3);
|
|
4647
4765
|
},
|
|
4648
4766
|
apply: function(point) {
|
|
4649
4767
|
return [point[0] * this.k + this.x, point[1] * this.k + this.y];
|
|
4650
4768
|
},
|
|
4651
|
-
applyX: function(
|
|
4652
|
-
return
|
|
4769
|
+
applyX: function(x3) {
|
|
4770
|
+
return x3 * this.k + this.x;
|
|
4653
4771
|
},
|
|
4654
|
-
applyY: function(
|
|
4655
|
-
return
|
|
4772
|
+
applyY: function(y3) {
|
|
4773
|
+
return y3 * this.k + this.y;
|
|
4656
4774
|
},
|
|
4657
4775
|
invert: function(location) {
|
|
4658
4776
|
return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
|
|
4659
4777
|
},
|
|
4660
|
-
invertX: function(
|
|
4661
|
-
return (
|
|
4778
|
+
invertX: function(x3) {
|
|
4779
|
+
return (x3 - this.x) / this.k;
|
|
4662
4780
|
},
|
|
4663
|
-
invertY: function(
|
|
4664
|
-
return (
|
|
4781
|
+
invertY: function(y3) {
|
|
4782
|
+
return (y3 - this.y) / this.k;
|
|
4665
4783
|
},
|
|
4666
|
-
rescaleX: function(
|
|
4667
|
-
return
|
|
4784
|
+
rescaleX: function(x3) {
|
|
4785
|
+
return x3.copy().domain(x3.range().map(this.invertX, this).map(x3.invert, x3));
|
|
4668
4786
|
},
|
|
4669
|
-
rescaleY: function(
|
|
4670
|
-
return
|
|
4787
|
+
rescaleY: function(y3) {
|
|
4788
|
+
return y3.copy().domain(y3.range().map(this.invertY, this).map(y3.invert, y3));
|
|
4671
4789
|
},
|
|
4672
4790
|
toString: function() {
|
|
4673
4791
|
return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
|
|
@@ -4749,20 +4867,20 @@ function zoom_default2() {
|
|
|
4749
4867
|
return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent);
|
|
4750
4868
|
}, p, event);
|
|
4751
4869
|
};
|
|
4752
|
-
zoom.translateBy = function(selection2,
|
|
4870
|
+
zoom.translateBy = function(selection2, x3, y3, event) {
|
|
4753
4871
|
zoom.transform(selection2, function() {
|
|
4754
4872
|
return constrain(this.__zoom.translate(
|
|
4755
|
-
typeof
|
|
4756
|
-
typeof
|
|
4873
|
+
typeof x3 === "function" ? x3.apply(this, arguments) : x3,
|
|
4874
|
+
typeof y3 === "function" ? y3.apply(this, arguments) : y3
|
|
4757
4875
|
), extent.apply(this, arguments), translateExtent);
|
|
4758
4876
|
}, null, event);
|
|
4759
4877
|
};
|
|
4760
|
-
zoom.translateTo = function(selection2,
|
|
4878
|
+
zoom.translateTo = function(selection2, x3, y3, p, event) {
|
|
4761
4879
|
zoom.transform(selection2, function() {
|
|
4762
4880
|
var e = extent.apply(this, arguments), t = this.__zoom, p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p;
|
|
4763
4881
|
return constrain(identity2.translate(p0[0], p0[1]).scale(t.k).translate(
|
|
4764
|
-
typeof
|
|
4765
|
-
typeof
|
|
4882
|
+
typeof x3 === "function" ? -x3.apply(this, arguments) : -x3,
|
|
4883
|
+
typeof y3 === "function" ? -y3.apply(this, arguments) : -y3
|
|
4766
4884
|
), e, translateExtent);
|
|
4767
4885
|
}, p, event);
|
|
4768
4886
|
};
|
|
@@ -4771,8 +4889,8 @@ function zoom_default2() {
|
|
|
4771
4889
|
return k === transform2.k ? transform2 : new Transform(k, transform2.x, transform2.y);
|
|
4772
4890
|
}
|
|
4773
4891
|
function translate(transform2, p0, p1) {
|
|
4774
|
-
var
|
|
4775
|
-
return
|
|
4892
|
+
var x3 = p0[0] - p1[0] * transform2.k, y3 = p0[1] - p1[1] * transform2.k;
|
|
4893
|
+
return x3 === transform2.x && y3 === transform2.y ? transform2 : new Transform(transform2.k, x3, y3);
|
|
4776
4894
|
}
|
|
4777
4895
|
function centroid(extent2) {
|
|
4778
4896
|
return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
|
|
@@ -5077,7 +5195,7 @@ var DragManager = class {
|
|
|
5077
5195
|
fy: obj.fy
|
|
5078
5196
|
};
|
|
5079
5197
|
if (!event.active) {
|
|
5080
|
-
this.config.physicsManager.reheat(
|
|
5198
|
+
this.config.physicsManager.reheat();
|
|
5081
5199
|
obj.fx = obj.x;
|
|
5082
5200
|
obj.fy = obj.y;
|
|
5083
5201
|
}
|
|
@@ -5806,9 +5924,9 @@ var SelectionManager = class {
|
|
|
5806
5924
|
if (!this.canvasState) return;
|
|
5807
5925
|
try {
|
|
5808
5926
|
const rect = this.container.getBoundingClientRect();
|
|
5809
|
-
const
|
|
5810
|
-
const
|
|
5811
|
-
const obj = this.getObjUnderPointer(
|
|
5927
|
+
const x3 = event.clientX - rect.left;
|
|
5928
|
+
const y3 = event.clientY - rect.top;
|
|
5929
|
+
const obj = this.getObjUnderPointer(x3, y3);
|
|
5812
5930
|
if (obj) {
|
|
5813
5931
|
if (obj.d.entityType === "Node") {
|
|
5814
5932
|
this.selectNode(obj.d);
|
|
@@ -5828,19 +5946,19 @@ var SelectionManager = class {
|
|
|
5828
5946
|
/**
|
|
5829
5947
|
* Get object under pointer coordinates (using shadow canvas)
|
|
5830
5948
|
*/
|
|
5831
|
-
getObjUnderPointer(
|
|
5949
|
+
getObjUnderPointer(x3, y3) {
|
|
5832
5950
|
if (!this.canvasState) return null;
|
|
5833
5951
|
try {
|
|
5834
5952
|
const { shadowCtx, colorTracker } = this.canvasState;
|
|
5835
5953
|
const pxScale = window.devicePixelRatio;
|
|
5836
|
-
const px =
|
|
5954
|
+
const px = x3 > 0 && y3 > 0 ? shadowCtx.getImageData(x3 * pxScale, y3 * pxScale, 1, 1) : null;
|
|
5837
5955
|
if (px && px.data.length >= 3) {
|
|
5838
5956
|
const rgb2 = [px.data[0] ?? 0, px.data[1] ?? 0, px.data[2] ?? 0];
|
|
5839
5957
|
return colorTracker.lookup(rgb2);
|
|
5840
5958
|
}
|
|
5841
5959
|
return null;
|
|
5842
5960
|
} catch (error) {
|
|
5843
|
-
ErrorHandler.logError(error, { x:
|
|
5961
|
+
ErrorHandler.logError(error, { x: x3, y: y3 });
|
|
5844
5962
|
return null;
|
|
5845
5963
|
}
|
|
5846
5964
|
}
|
|
@@ -6058,8 +6176,8 @@ var NodesRenderer = class {
|
|
|
6058
6176
|
static renderWithOptimizedStates(ctx, nodes, styleResolver, hoveredNodeId, selectedNodeId) {
|
|
6059
6177
|
try {
|
|
6060
6178
|
for (const node of nodes) {
|
|
6061
|
-
const
|
|
6062
|
-
const
|
|
6179
|
+
const x3 = node.x;
|
|
6180
|
+
const y3 = node.y;
|
|
6063
6181
|
const isHovered = hoveredNodeId === node.id;
|
|
6064
6182
|
const isSelected = selectedNodeId === node.id;
|
|
6065
6183
|
const style = styleResolver.resolveNodeStyle({
|
|
@@ -6068,7 +6186,7 @@ var NodesRenderer = class {
|
|
|
6068
6186
|
isSelected
|
|
6069
6187
|
});
|
|
6070
6188
|
ctx.beginPath();
|
|
6071
|
-
ctx.arc(
|
|
6189
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6072
6190
|
ctx.fillStyle = style.fill;
|
|
6073
6191
|
ctx.globalAlpha = style.opacity;
|
|
6074
6192
|
ctx.fill();
|
|
@@ -6090,12 +6208,12 @@ var NodesRenderer = class {
|
|
|
6090
6208
|
static render(ctx, nodes, nodeStyle, hoverNodeStyle, isNodeHovered) {
|
|
6091
6209
|
try {
|
|
6092
6210
|
for (const node of nodes) {
|
|
6093
|
-
const
|
|
6094
|
-
const
|
|
6211
|
+
const x3 = node.x;
|
|
6212
|
+
const y3 = node.y;
|
|
6095
6213
|
const isHovered = isNodeHovered(node.id);
|
|
6096
6214
|
const style = isHovered ? hoverNodeStyle : nodeStyle;
|
|
6097
6215
|
ctx.beginPath();
|
|
6098
|
-
ctx.arc(
|
|
6216
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6099
6217
|
ctx.fillStyle = style.fill;
|
|
6100
6218
|
ctx.globalAlpha = style.opacity;
|
|
6101
6219
|
ctx.fill();
|
|
@@ -6117,8 +6235,8 @@ var NodesRenderer = class {
|
|
|
6117
6235
|
static renderWithStyleResolver(ctx, nodes, styleResolver, isNodeHovered, isNodeSelected, performanceMetrics) {
|
|
6118
6236
|
try {
|
|
6119
6237
|
for (const node of nodes) {
|
|
6120
|
-
const
|
|
6121
|
-
const
|
|
6238
|
+
const x3 = node.x;
|
|
6239
|
+
const y3 = node.y;
|
|
6122
6240
|
const hoverStart = performance.now();
|
|
6123
6241
|
const isHovered = isNodeHovered(node.id);
|
|
6124
6242
|
const isSelected = isNodeSelected ? isNodeSelected(node.id) : false;
|
|
@@ -6136,7 +6254,7 @@ var NodesRenderer = class {
|
|
|
6136
6254
|
}
|
|
6137
6255
|
const canvasStart = performance.now();
|
|
6138
6256
|
ctx.beginPath();
|
|
6139
|
-
ctx.arc(
|
|
6257
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6140
6258
|
ctx.fillStyle = style.fill;
|
|
6141
6259
|
ctx.globalAlpha = style.opacity;
|
|
6142
6260
|
ctx.fill();
|
|
@@ -6162,14 +6280,14 @@ var NodesRenderer = class {
|
|
|
6162
6280
|
try {
|
|
6163
6281
|
for (const node of nodes) {
|
|
6164
6282
|
if (!node.__indexColorRGB) continue;
|
|
6165
|
-
const
|
|
6166
|
-
const
|
|
6283
|
+
const x3 = node.x;
|
|
6284
|
+
const y3 = node.y;
|
|
6167
6285
|
const [r, g, b] = node.__indexColorRGB;
|
|
6168
6286
|
const rgbColor = `rgb(${r},${g},${b})`;
|
|
6169
6287
|
const hitRadius = nodeRadius + 0.5 + 0.1;
|
|
6170
6288
|
shadowCtx.fillStyle = rgbColor;
|
|
6171
6289
|
shadowCtx.beginPath();
|
|
6172
|
-
shadowCtx.arc(
|
|
6290
|
+
shadowCtx.arc(x3, y3, hitRadius, 0, 2 * Math.PI);
|
|
6173
6291
|
shadowCtx.fill();
|
|
6174
6292
|
}
|
|
6175
6293
|
} catch (error) {
|
|
@@ -6204,13 +6322,13 @@ var NodeLabelsRenderer = class {
|
|
|
6204
6322
|
ctx.textBaseline = resolvedStyle.textBaseline;
|
|
6205
6323
|
ctx.fillStyle = resolvedStyle.fillStyle;
|
|
6206
6324
|
for (const node of nodes) {
|
|
6207
|
-
const
|
|
6208
|
-
const
|
|
6325
|
+
const x3 = node.x;
|
|
6326
|
+
const y3 = node.y;
|
|
6209
6327
|
const fullLabel = node.label || node.id;
|
|
6210
6328
|
const maxWidth = nodeRadius * 2 - 6;
|
|
6211
6329
|
const truncatedLabel = this.truncateLabel(ctx, fullLabel, maxWidth);
|
|
6212
|
-
const labelY =
|
|
6213
|
-
ctx.fillText(truncatedLabel,
|
|
6330
|
+
const labelY = y3 + resolvedStyle.offsetY;
|
|
6331
|
+
ctx.fillText(truncatedLabel, x3, labelY);
|
|
6214
6332
|
}
|
|
6215
6333
|
} catch (error) {
|
|
6216
6334
|
ErrorHandler.logError(error);
|
|
@@ -6393,15 +6511,15 @@ var LinkLabelsRenderer = class {
|
|
|
6393
6511
|
/**
|
|
6394
6512
|
* Render a single label at given coordinates
|
|
6395
6513
|
*/
|
|
6396
|
-
static renderSingleLabel(ctx, text,
|
|
6514
|
+
static renderSingleLabel(ctx, text, x3, y3, style) {
|
|
6397
6515
|
ctx.font = style.font ?? "10px Arial";
|
|
6398
6516
|
const metrics = ctx.measureText(text);
|
|
6399
6517
|
const textWidth = metrics.width;
|
|
6400
6518
|
const textHeight = (metrics.actualBoundingBoxAscent || 10) + (metrics.actualBoundingBoxDescent || 4);
|
|
6401
6519
|
const rectWidth = textWidth + (style.paddingX ?? 8) * 2;
|
|
6402
6520
|
const rectHeight = textHeight + (style.paddingY ?? 4) * 2;
|
|
6403
|
-
const rectX =
|
|
6404
|
-
const rectY =
|
|
6521
|
+
const rectX = x3 - rectWidth / 2;
|
|
6522
|
+
const rectY = y3 - rectHeight / 2;
|
|
6405
6523
|
if (style.backgroundColor && style.backgroundColor !== "transparent") {
|
|
6406
6524
|
ctx.fillStyle = style.backgroundColor;
|
|
6407
6525
|
this.roundRect(ctx, rectX, rectY, rectWidth, rectHeight, style.borderRadius ?? 4);
|
|
@@ -6416,26 +6534,26 @@ var LinkLabelsRenderer = class {
|
|
|
6416
6534
|
ctx.fillStyle = style.textColor ?? "#000000";
|
|
6417
6535
|
ctx.textAlign = "center";
|
|
6418
6536
|
ctx.textBaseline = "middle";
|
|
6419
|
-
ctx.fillText(text,
|
|
6537
|
+
ctx.fillText(text, x3, y3);
|
|
6420
6538
|
}
|
|
6421
6539
|
/**
|
|
6422
6540
|
* Helper to draw rounded rectangle
|
|
6423
6541
|
*/
|
|
6424
|
-
static roundRect(ctx,
|
|
6542
|
+
static roundRect(ctx, x3, y3, width, height, radius) {
|
|
6425
6543
|
if (radius === 0) {
|
|
6426
|
-
ctx.rect(
|
|
6544
|
+
ctx.rect(x3, y3, width, height);
|
|
6427
6545
|
return;
|
|
6428
6546
|
}
|
|
6429
6547
|
ctx.beginPath();
|
|
6430
|
-
ctx.moveTo(
|
|
6431
|
-
ctx.lineTo(
|
|
6432
|
-
ctx.quadraticCurveTo(
|
|
6433
|
-
ctx.lineTo(
|
|
6434
|
-
ctx.quadraticCurveTo(
|
|
6435
|
-
ctx.lineTo(
|
|
6436
|
-
ctx.quadraticCurveTo(
|
|
6437
|
-
ctx.lineTo(
|
|
6438
|
-
ctx.quadraticCurveTo(
|
|
6548
|
+
ctx.moveTo(x3 + radius, y3);
|
|
6549
|
+
ctx.lineTo(x3 + width - radius, y3);
|
|
6550
|
+
ctx.quadraticCurveTo(x3 + width, y3, x3 + width, y3 + radius);
|
|
6551
|
+
ctx.lineTo(x3 + width, y3 + height - radius);
|
|
6552
|
+
ctx.quadraticCurveTo(x3 + width, y3 + height, x3 + width - radius, y3 + height);
|
|
6553
|
+
ctx.lineTo(x3 + radius, y3 + height);
|
|
6554
|
+
ctx.quadraticCurveTo(x3, y3 + height, x3, y3 + height - radius);
|
|
6555
|
+
ctx.lineTo(x3, y3 + radius);
|
|
6556
|
+
ctx.quadraticCurveTo(x3, y3, x3 + radius, y3);
|
|
6439
6557
|
ctx.closePath();
|
|
6440
6558
|
}
|
|
6441
6559
|
/**
|
|
@@ -7076,13 +7194,13 @@ var Renderer = class {
|
|
|
7076
7194
|
const arrowTipY = targetPoint.y + arrowLength * Math.sin(angle);
|
|
7077
7195
|
const x1 = arrowTipX - arrowLength * Math.cos(angle - Math.PI / 6);
|
|
7078
7196
|
const y1 = arrowTipY - arrowLength * Math.sin(angle - Math.PI / 6);
|
|
7079
|
-
const
|
|
7080
|
-
const
|
|
7197
|
+
const x22 = arrowTipX - arrowLength * Math.cos(angle + Math.PI / 6);
|
|
7198
|
+
const y22 = arrowTipY - arrowLength * Math.sin(angle + Math.PI / 6);
|
|
7081
7199
|
ctx.fillStyle = arrowStyle.fill ?? "#000000";
|
|
7082
7200
|
ctx.beginPath();
|
|
7083
7201
|
ctx.moveTo(arrowTipX, arrowTipY);
|
|
7084
7202
|
ctx.lineTo(x1, y1);
|
|
7085
|
-
ctx.lineTo(
|
|
7203
|
+
ctx.lineTo(x22, y22);
|
|
7086
7204
|
ctx.closePath();
|
|
7087
7205
|
ctx.fill();
|
|
7088
7206
|
} catch (error) {
|
|
@@ -8491,7 +8609,7 @@ var V2Graph = class {
|
|
|
8491
8609
|
/**
|
|
8492
8610
|
* Draw legend on export canvas
|
|
8493
8611
|
*/
|
|
8494
|
-
drawLegendOnExportCanvas(ctx, legendElement,
|
|
8612
|
+
drawLegendOnExportCanvas(ctx, legendElement, x3, y3) {
|
|
8495
8613
|
const legendItems = legendElement.querySelectorAll(".pg-legend-item");
|
|
8496
8614
|
const padding = 16;
|
|
8497
8615
|
const itemHeight = 24;
|
|
@@ -8501,8 +8619,8 @@ var V2Graph = class {
|
|
|
8501
8619
|
ctx.fillStyle = "#ffffff";
|
|
8502
8620
|
ctx.strokeStyle = "#e2e8f0";
|
|
8503
8621
|
ctx.lineWidth = 1;
|
|
8504
|
-
ctx.fillRect(
|
|
8505
|
-
ctx.strokeRect(
|
|
8622
|
+
ctx.fillRect(x3, y3, legendWidth, legendHeight);
|
|
8623
|
+
ctx.strokeRect(x3, y3, legendWidth, legendHeight);
|
|
8506
8624
|
ctx.font = "12px Arial, sans-serif";
|
|
8507
8625
|
ctx.textAlign = "left";
|
|
8508
8626
|
ctx.textBaseline = "middle";
|
|
@@ -8510,8 +8628,8 @@ var V2Graph = class {
|
|
|
8510
8628
|
const swatch = item.querySelector(".pg-legend-swatch");
|
|
8511
8629
|
const label = item.querySelector(".pg-legend-label");
|
|
8512
8630
|
if (swatch && label) {
|
|
8513
|
-
const itemY =
|
|
8514
|
-
const swatchX =
|
|
8631
|
+
const itemY = y3 + padding + index2 * (itemHeight + itemSpacing) + itemHeight / 2;
|
|
8632
|
+
const swatchX = x3 + padding;
|
|
8515
8633
|
const textX = swatchX + 14 + 8;
|
|
8516
8634
|
const swatchColor = swatch.style.backgroundColor || "#94a3b8";
|
|
8517
8635
|
ctx.fillStyle = swatchColor;
|