polly-graph 0.2.2 → 0.2.3
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 +262 -198
- package/dist/index.js +262 -198
- 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
|
}
|
|
@@ -1943,38 +2016,29 @@ var PhysicsManager = class {
|
|
|
1943
2016
|
this.config = config;
|
|
1944
2017
|
this.simulationStartTime = performance.now();
|
|
1945
2018
|
const nodeCount = config.nodes.length;
|
|
1946
|
-
const linkCount = config.links.length;
|
|
1947
2019
|
const graphArea = config.width * config.height;
|
|
1948
|
-
const baseChargeStrength = -600;
|
|
1949
2020
|
const nodeDensity = nodeCount / (graphArea / 1e5);
|
|
1950
2021
|
const densityFactor = Math.min(nodeDensity, 2);
|
|
1951
|
-
const adaptiveChargeStrength = baseChargeStrength / (1 + densityFactor * 0.4);
|
|
1952
2022
|
const baseVelocityDecay = 0.4;
|
|
1953
2023
|
const adaptiveVelocityDecay = Math.min(baseVelocityDecay + densityFactor * 0.2, 0.8);
|
|
1954
2024
|
const baseAlphaDecay = 0.02;
|
|
1955
2025
|
const adaptiveAlphaDecay = Math.min(baseAlphaDecay + densityFactor * 0.01, 0.05);
|
|
1956
|
-
console.log("\u{1F52C} Adaptive Physics:", {
|
|
1957
|
-
nodeCount,
|
|
1958
|
-
linkCount,
|
|
1959
|
-
graphArea: Math.round(graphArea),
|
|
1960
|
-
nodeDensity: nodeDensity.toFixed(3),
|
|
1961
|
-
densityFactor: densityFactor.toFixed(2),
|
|
1962
|
-
chargeStrength: adaptiveChargeStrength.toFixed(0),
|
|
1963
|
-
velocityDecay: adaptiveVelocityDecay.toFixed(2),
|
|
1964
|
-
alphaDecay: adaptiveAlphaDecay.toFixed(3),
|
|
1965
|
-
maxDistance: Math.max(300, 600 - densityFactor * 100)
|
|
1966
|
-
});
|
|
1967
2026
|
this.simulation = simulation_default(config.nodes).force(
|
|
1968
2027
|
"link",
|
|
1969
|
-
link_default(config.links).id((d) => d.id).distance(
|
|
2028
|
+
link_default(config.links).id((d) => d.id).distance(150).strength(0.4)
|
|
1970
2029
|
// Much weaker link strength to allow repulsion to work
|
|
1971
2030
|
).force(
|
|
1972
2031
|
"charge",
|
|
1973
|
-
manyBody_default().strength(
|
|
1974
|
-
//
|
|
2032
|
+
manyBody_default().strength(-500)
|
|
2033
|
+
// Adaptive repulsion strength
|
|
2034
|
+
// .distanceMin(1) // Minimum distance for repulsion
|
|
2035
|
+
// .distanceMax(Math.max(300, 600 - densityFactor * 100)) // Reduce max distance for dense graphs
|
|
2036
|
+
).force(
|
|
2037
|
+
"collision",
|
|
2038
|
+
collide_default().radius((node) => this.getNodeRadius(node) + 2).strength(1)
|
|
1975
2039
|
).force(
|
|
1976
2040
|
"center",
|
|
1977
|
-
center_default(0, 0).strength(0.
|
|
2041
|
+
center_default(0, 0).strength(0.5)
|
|
1978
2042
|
// Center around origin like force-graph
|
|
1979
2043
|
).velocityDecay(adaptiveVelocityDecay).alphaDecay(adaptiveAlphaDecay).on("tick", config.onTick).on("end", () => this.handleSimulationEnd());
|
|
1980
2044
|
if (config.cooldownTime) {
|
|
@@ -2101,12 +2165,12 @@ var PhysicsManager = class {
|
|
|
2101
2165
|
* Update center force position for new canvas dimensions
|
|
2102
2166
|
* Following force-graph pattern for container resizing
|
|
2103
2167
|
*/
|
|
2104
|
-
updateCenterForce(
|
|
2168
|
+
updateCenterForce(x3, y3) {
|
|
2105
2169
|
if (!this.simulation) return;
|
|
2106
2170
|
try {
|
|
2107
|
-
this.simulation.force("center", center_default(
|
|
2171
|
+
this.simulation.force("center", center_default(x3, y3).strength(0.1));
|
|
2108
2172
|
} catch (error) {
|
|
2109
|
-
ErrorHandler.logError(error, { x:
|
|
2173
|
+
ErrorHandler.logError(error, { x: x3, y: y3 });
|
|
2110
2174
|
}
|
|
2111
2175
|
}
|
|
2112
2176
|
/**
|
|
@@ -2323,8 +2387,8 @@ function select_default(select) {
|
|
|
2323
2387
|
}
|
|
2324
2388
|
|
|
2325
2389
|
// node_modules/d3-selection/src/array.js
|
|
2326
|
-
function array(
|
|
2327
|
-
return
|
|
2390
|
+
function array(x3) {
|
|
2391
|
+
return x3 == null ? [] : Array.isArray(x3) ? x3 : Array.from(x3);
|
|
2328
2392
|
}
|
|
2329
2393
|
|
|
2330
2394
|
// node_modules/d3-selection/src/selectorAll.js
|
|
@@ -2443,9 +2507,9 @@ EnterNode.prototype = {
|
|
|
2443
2507
|
};
|
|
2444
2508
|
|
|
2445
2509
|
// node_modules/d3-selection/src/constant.js
|
|
2446
|
-
function constant_default2(
|
|
2510
|
+
function constant_default2(x3) {
|
|
2447
2511
|
return function() {
|
|
2448
|
-
return
|
|
2512
|
+
return x3;
|
|
2449
2513
|
};
|
|
2450
2514
|
}
|
|
2451
2515
|
|
|
@@ -3118,7 +3182,7 @@ function yesdrag(view, noclick) {
|
|
|
3118
3182
|
}
|
|
3119
3183
|
|
|
3120
3184
|
// node_modules/d3-drag/src/constant.js
|
|
3121
|
-
var constant_default3 = (
|
|
3185
|
+
var constant_default3 = (x3) => () => x3;
|
|
3122
3186
|
|
|
3123
3187
|
// node_modules/d3-drag/src/event.js
|
|
3124
3188
|
function DragEvent(type, {
|
|
@@ -3127,8 +3191,8 @@ function DragEvent(type, {
|
|
|
3127
3191
|
target,
|
|
3128
3192
|
identifier,
|
|
3129
3193
|
active,
|
|
3130
|
-
x:
|
|
3131
|
-
y:
|
|
3194
|
+
x: x3,
|
|
3195
|
+
y: y3,
|
|
3132
3196
|
dx,
|
|
3133
3197
|
dy,
|
|
3134
3198
|
dispatch: dispatch2
|
|
@@ -3140,8 +3204,8 @@ function DragEvent(type, {
|
|
|
3140
3204
|
target: { value: target, enumerable: true, configurable: true },
|
|
3141
3205
|
identifier: { value: identifier, enumerable: true, configurable: true },
|
|
3142
3206
|
active: { value: active, enumerable: true, configurable: true },
|
|
3143
|
-
x: { value:
|
|
3144
|
-
y: { value:
|
|
3207
|
+
x: { value: x3, enumerable: true, configurable: true },
|
|
3208
|
+
y: { value: y3, enumerable: true, configurable: true },
|
|
3145
3209
|
dx: { value: dx, enumerable: true, configurable: true },
|
|
3146
3210
|
dy: { value: dy, enumerable: true, configurable: true },
|
|
3147
3211
|
_: { value: dispatch2 }
|
|
@@ -3668,7 +3732,7 @@ function basisClosed_default(values) {
|
|
|
3668
3732
|
}
|
|
3669
3733
|
|
|
3670
3734
|
// node_modules/d3-interpolate/src/constant.js
|
|
3671
|
-
var constant_default4 = (
|
|
3735
|
+
var constant_default4 = (x3) => () => x3;
|
|
3672
3736
|
|
|
3673
3737
|
// node_modules/d3-interpolate/src/color.js
|
|
3674
3738
|
function linear(a2, d) {
|
|
@@ -3676,14 +3740,14 @@ function linear(a2, d) {
|
|
|
3676
3740
|
return a2 + t * d;
|
|
3677
3741
|
};
|
|
3678
3742
|
}
|
|
3679
|
-
function exponential(a2, b,
|
|
3680
|
-
return a2 = Math.pow(a2,
|
|
3681
|
-
return Math.pow(a2 + t * b,
|
|
3743
|
+
function exponential(a2, b, y3) {
|
|
3744
|
+
return a2 = Math.pow(a2, y3), b = Math.pow(b, y3) - a2, y3 = 1 / y3, function(t) {
|
|
3745
|
+
return Math.pow(a2 + t * b, y3);
|
|
3682
3746
|
};
|
|
3683
3747
|
}
|
|
3684
|
-
function gamma(
|
|
3685
|
-
return (
|
|
3686
|
-
return b - a2 ? exponential(a2, b,
|
|
3748
|
+
function gamma(y3) {
|
|
3749
|
+
return (y3 = +y3) === 1 ? nogamma : function(a2, b) {
|
|
3750
|
+
return b - a2 ? exponential(a2, b, y3) : constant_default4(isNaN(a2) ? b : a2);
|
|
3687
3751
|
};
|
|
3688
3752
|
}
|
|
3689
3753
|
function nogamma(a2, b) {
|
|
@@ -3692,8 +3756,8 @@ function nogamma(a2, b) {
|
|
|
3692
3756
|
}
|
|
3693
3757
|
|
|
3694
3758
|
// node_modules/d3-interpolate/src/rgb.js
|
|
3695
|
-
var rgb_default = (function rgbGamma(
|
|
3696
|
-
var color2 = gamma(
|
|
3759
|
+
var rgb_default = (function rgbGamma(y3) {
|
|
3760
|
+
var color2 = gamma(y3);
|
|
3697
3761
|
function rgb2(start2, end) {
|
|
3698
3762
|
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
3763
|
return function(t) {
|
|
@@ -3878,14 +3942,14 @@ var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
|
|
|
3878
3942
|
|
|
3879
3943
|
// node_modules/d3-interpolate/src/zoom.js
|
|
3880
3944
|
var epsilon2 = 1e-12;
|
|
3881
|
-
function cosh(
|
|
3882
|
-
return ((
|
|
3945
|
+
function cosh(x3) {
|
|
3946
|
+
return ((x3 = Math.exp(x3)) + 1 / x3) / 2;
|
|
3883
3947
|
}
|
|
3884
|
-
function sinh(
|
|
3885
|
-
return ((
|
|
3948
|
+
function sinh(x3) {
|
|
3949
|
+
return ((x3 = Math.exp(x3)) - 1 / x3) / 2;
|
|
3886
3950
|
}
|
|
3887
|
-
function tanh(
|
|
3888
|
-
return ((
|
|
3951
|
+
function tanh(x3) {
|
|
3952
|
+
return ((x3 = Math.exp(2 * x3)) - 1) / (x3 + 1);
|
|
3889
3953
|
}
|
|
3890
3954
|
var zoom_default = (function zoomRho(rho, rho2, rho4) {
|
|
3891
3955
|
function zoom(p0, p1) {
|
|
@@ -4613,7 +4677,7 @@ selection_default.prototype.interrupt = interrupt_default2;
|
|
|
4613
4677
|
selection_default.prototype.transition = transition_default2;
|
|
4614
4678
|
|
|
4615
4679
|
// node_modules/d3-zoom/src/constant.js
|
|
4616
|
-
var constant_default5 = (
|
|
4680
|
+
var constant_default5 = (x3) => () => x3;
|
|
4617
4681
|
|
|
4618
4682
|
// node_modules/d3-zoom/src/event.js
|
|
4619
4683
|
function ZoomEvent(type, {
|
|
@@ -4632,42 +4696,42 @@ function ZoomEvent(type, {
|
|
|
4632
4696
|
}
|
|
4633
4697
|
|
|
4634
4698
|
// node_modules/d3-zoom/src/transform.js
|
|
4635
|
-
function Transform(k,
|
|
4699
|
+
function Transform(k, x3, y3) {
|
|
4636
4700
|
this.k = k;
|
|
4637
|
-
this.x =
|
|
4638
|
-
this.y =
|
|
4701
|
+
this.x = x3;
|
|
4702
|
+
this.y = y3;
|
|
4639
4703
|
}
|
|
4640
4704
|
Transform.prototype = {
|
|
4641
4705
|
constructor: Transform,
|
|
4642
4706
|
scale: function(k) {
|
|
4643
4707
|
return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
|
|
4644
4708
|
},
|
|
4645
|
-
translate: function(
|
|
4646
|
-
return
|
|
4709
|
+
translate: function(x3, y3) {
|
|
4710
|
+
return x3 === 0 & y3 === 0 ? this : new Transform(this.k, this.x + this.k * x3, this.y + this.k * y3);
|
|
4647
4711
|
},
|
|
4648
4712
|
apply: function(point) {
|
|
4649
4713
|
return [point[0] * this.k + this.x, point[1] * this.k + this.y];
|
|
4650
4714
|
},
|
|
4651
|
-
applyX: function(
|
|
4652
|
-
return
|
|
4715
|
+
applyX: function(x3) {
|
|
4716
|
+
return x3 * this.k + this.x;
|
|
4653
4717
|
},
|
|
4654
|
-
applyY: function(
|
|
4655
|
-
return
|
|
4718
|
+
applyY: function(y3) {
|
|
4719
|
+
return y3 * this.k + this.y;
|
|
4656
4720
|
},
|
|
4657
4721
|
invert: function(location) {
|
|
4658
4722
|
return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
|
|
4659
4723
|
},
|
|
4660
|
-
invertX: function(
|
|
4661
|
-
return (
|
|
4724
|
+
invertX: function(x3) {
|
|
4725
|
+
return (x3 - this.x) / this.k;
|
|
4662
4726
|
},
|
|
4663
|
-
invertY: function(
|
|
4664
|
-
return (
|
|
4727
|
+
invertY: function(y3) {
|
|
4728
|
+
return (y3 - this.y) / this.k;
|
|
4665
4729
|
},
|
|
4666
|
-
rescaleX: function(
|
|
4667
|
-
return
|
|
4730
|
+
rescaleX: function(x3) {
|
|
4731
|
+
return x3.copy().domain(x3.range().map(this.invertX, this).map(x3.invert, x3));
|
|
4668
4732
|
},
|
|
4669
|
-
rescaleY: function(
|
|
4670
|
-
return
|
|
4733
|
+
rescaleY: function(y3) {
|
|
4734
|
+
return y3.copy().domain(y3.range().map(this.invertY, this).map(y3.invert, y3));
|
|
4671
4735
|
},
|
|
4672
4736
|
toString: function() {
|
|
4673
4737
|
return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
|
|
@@ -4749,20 +4813,20 @@ function zoom_default2() {
|
|
|
4749
4813
|
return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent);
|
|
4750
4814
|
}, p, event);
|
|
4751
4815
|
};
|
|
4752
|
-
zoom.translateBy = function(selection2,
|
|
4816
|
+
zoom.translateBy = function(selection2, x3, y3, event) {
|
|
4753
4817
|
zoom.transform(selection2, function() {
|
|
4754
4818
|
return constrain(this.__zoom.translate(
|
|
4755
|
-
typeof
|
|
4756
|
-
typeof
|
|
4819
|
+
typeof x3 === "function" ? x3.apply(this, arguments) : x3,
|
|
4820
|
+
typeof y3 === "function" ? y3.apply(this, arguments) : y3
|
|
4757
4821
|
), extent.apply(this, arguments), translateExtent);
|
|
4758
4822
|
}, null, event);
|
|
4759
4823
|
};
|
|
4760
|
-
zoom.translateTo = function(selection2,
|
|
4824
|
+
zoom.translateTo = function(selection2, x3, y3, p, event) {
|
|
4761
4825
|
zoom.transform(selection2, function() {
|
|
4762
4826
|
var e = extent.apply(this, arguments), t = this.__zoom, p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p;
|
|
4763
4827
|
return constrain(identity2.translate(p0[0], p0[1]).scale(t.k).translate(
|
|
4764
|
-
typeof
|
|
4765
|
-
typeof
|
|
4828
|
+
typeof x3 === "function" ? -x3.apply(this, arguments) : -x3,
|
|
4829
|
+
typeof y3 === "function" ? -y3.apply(this, arguments) : -y3
|
|
4766
4830
|
), e, translateExtent);
|
|
4767
4831
|
}, p, event);
|
|
4768
4832
|
};
|
|
@@ -4771,8 +4835,8 @@ function zoom_default2() {
|
|
|
4771
4835
|
return k === transform2.k ? transform2 : new Transform(k, transform2.x, transform2.y);
|
|
4772
4836
|
}
|
|
4773
4837
|
function translate(transform2, p0, p1) {
|
|
4774
|
-
var
|
|
4775
|
-
return
|
|
4838
|
+
var x3 = p0[0] - p1[0] * transform2.k, y3 = p0[1] - p1[1] * transform2.k;
|
|
4839
|
+
return x3 === transform2.x && y3 === transform2.y ? transform2 : new Transform(transform2.k, x3, y3);
|
|
4776
4840
|
}
|
|
4777
4841
|
function centroid(extent2) {
|
|
4778
4842
|
return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
|
|
@@ -5806,9 +5870,9 @@ var SelectionManager = class {
|
|
|
5806
5870
|
if (!this.canvasState) return;
|
|
5807
5871
|
try {
|
|
5808
5872
|
const rect = this.container.getBoundingClientRect();
|
|
5809
|
-
const
|
|
5810
|
-
const
|
|
5811
|
-
const obj = this.getObjUnderPointer(
|
|
5873
|
+
const x3 = event.clientX - rect.left;
|
|
5874
|
+
const y3 = event.clientY - rect.top;
|
|
5875
|
+
const obj = this.getObjUnderPointer(x3, y3);
|
|
5812
5876
|
if (obj) {
|
|
5813
5877
|
if (obj.d.entityType === "Node") {
|
|
5814
5878
|
this.selectNode(obj.d);
|
|
@@ -5828,19 +5892,19 @@ var SelectionManager = class {
|
|
|
5828
5892
|
/**
|
|
5829
5893
|
* Get object under pointer coordinates (using shadow canvas)
|
|
5830
5894
|
*/
|
|
5831
|
-
getObjUnderPointer(
|
|
5895
|
+
getObjUnderPointer(x3, y3) {
|
|
5832
5896
|
if (!this.canvasState) return null;
|
|
5833
5897
|
try {
|
|
5834
5898
|
const { shadowCtx, colorTracker } = this.canvasState;
|
|
5835
5899
|
const pxScale = window.devicePixelRatio;
|
|
5836
|
-
const px =
|
|
5900
|
+
const px = x3 > 0 && y3 > 0 ? shadowCtx.getImageData(x3 * pxScale, y3 * pxScale, 1, 1) : null;
|
|
5837
5901
|
if (px && px.data.length >= 3) {
|
|
5838
5902
|
const rgb2 = [px.data[0] ?? 0, px.data[1] ?? 0, px.data[2] ?? 0];
|
|
5839
5903
|
return colorTracker.lookup(rgb2);
|
|
5840
5904
|
}
|
|
5841
5905
|
return null;
|
|
5842
5906
|
} catch (error) {
|
|
5843
|
-
ErrorHandler.logError(error, { x:
|
|
5907
|
+
ErrorHandler.logError(error, { x: x3, y: y3 });
|
|
5844
5908
|
return null;
|
|
5845
5909
|
}
|
|
5846
5910
|
}
|
|
@@ -6058,8 +6122,8 @@ var NodesRenderer = class {
|
|
|
6058
6122
|
static renderWithOptimizedStates(ctx, nodes, styleResolver, hoveredNodeId, selectedNodeId) {
|
|
6059
6123
|
try {
|
|
6060
6124
|
for (const node of nodes) {
|
|
6061
|
-
const
|
|
6062
|
-
const
|
|
6125
|
+
const x3 = node.x;
|
|
6126
|
+
const y3 = node.y;
|
|
6063
6127
|
const isHovered = hoveredNodeId === node.id;
|
|
6064
6128
|
const isSelected = selectedNodeId === node.id;
|
|
6065
6129
|
const style = styleResolver.resolveNodeStyle({
|
|
@@ -6068,7 +6132,7 @@ var NodesRenderer = class {
|
|
|
6068
6132
|
isSelected
|
|
6069
6133
|
});
|
|
6070
6134
|
ctx.beginPath();
|
|
6071
|
-
ctx.arc(
|
|
6135
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6072
6136
|
ctx.fillStyle = style.fill;
|
|
6073
6137
|
ctx.globalAlpha = style.opacity;
|
|
6074
6138
|
ctx.fill();
|
|
@@ -6090,12 +6154,12 @@ var NodesRenderer = class {
|
|
|
6090
6154
|
static render(ctx, nodes, nodeStyle, hoverNodeStyle, isNodeHovered) {
|
|
6091
6155
|
try {
|
|
6092
6156
|
for (const node of nodes) {
|
|
6093
|
-
const
|
|
6094
|
-
const
|
|
6157
|
+
const x3 = node.x;
|
|
6158
|
+
const y3 = node.y;
|
|
6095
6159
|
const isHovered = isNodeHovered(node.id);
|
|
6096
6160
|
const style = isHovered ? hoverNodeStyle : nodeStyle;
|
|
6097
6161
|
ctx.beginPath();
|
|
6098
|
-
ctx.arc(
|
|
6162
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6099
6163
|
ctx.fillStyle = style.fill;
|
|
6100
6164
|
ctx.globalAlpha = style.opacity;
|
|
6101
6165
|
ctx.fill();
|
|
@@ -6117,8 +6181,8 @@ var NodesRenderer = class {
|
|
|
6117
6181
|
static renderWithStyleResolver(ctx, nodes, styleResolver, isNodeHovered, isNodeSelected, performanceMetrics) {
|
|
6118
6182
|
try {
|
|
6119
6183
|
for (const node of nodes) {
|
|
6120
|
-
const
|
|
6121
|
-
const
|
|
6184
|
+
const x3 = node.x;
|
|
6185
|
+
const y3 = node.y;
|
|
6122
6186
|
const hoverStart = performance.now();
|
|
6123
6187
|
const isHovered = isNodeHovered(node.id);
|
|
6124
6188
|
const isSelected = isNodeSelected ? isNodeSelected(node.id) : false;
|
|
@@ -6136,7 +6200,7 @@ var NodesRenderer = class {
|
|
|
6136
6200
|
}
|
|
6137
6201
|
const canvasStart = performance.now();
|
|
6138
6202
|
ctx.beginPath();
|
|
6139
|
-
ctx.arc(
|
|
6203
|
+
ctx.arc(x3, y3, style.radius, 0, 2 * Math.PI);
|
|
6140
6204
|
ctx.fillStyle = style.fill;
|
|
6141
6205
|
ctx.globalAlpha = style.opacity;
|
|
6142
6206
|
ctx.fill();
|
|
@@ -6162,14 +6226,14 @@ var NodesRenderer = class {
|
|
|
6162
6226
|
try {
|
|
6163
6227
|
for (const node of nodes) {
|
|
6164
6228
|
if (!node.__indexColorRGB) continue;
|
|
6165
|
-
const
|
|
6166
|
-
const
|
|
6229
|
+
const x3 = node.x;
|
|
6230
|
+
const y3 = node.y;
|
|
6167
6231
|
const [r, g, b] = node.__indexColorRGB;
|
|
6168
6232
|
const rgbColor = `rgb(${r},${g},${b})`;
|
|
6169
6233
|
const hitRadius = nodeRadius + 0.5 + 0.1;
|
|
6170
6234
|
shadowCtx.fillStyle = rgbColor;
|
|
6171
6235
|
shadowCtx.beginPath();
|
|
6172
|
-
shadowCtx.arc(
|
|
6236
|
+
shadowCtx.arc(x3, y3, hitRadius, 0, 2 * Math.PI);
|
|
6173
6237
|
shadowCtx.fill();
|
|
6174
6238
|
}
|
|
6175
6239
|
} catch (error) {
|
|
@@ -6204,13 +6268,13 @@ var NodeLabelsRenderer = class {
|
|
|
6204
6268
|
ctx.textBaseline = resolvedStyle.textBaseline;
|
|
6205
6269
|
ctx.fillStyle = resolvedStyle.fillStyle;
|
|
6206
6270
|
for (const node of nodes) {
|
|
6207
|
-
const
|
|
6208
|
-
const
|
|
6271
|
+
const x3 = node.x;
|
|
6272
|
+
const y3 = node.y;
|
|
6209
6273
|
const fullLabel = node.label || node.id;
|
|
6210
6274
|
const maxWidth = nodeRadius * 2 - 6;
|
|
6211
6275
|
const truncatedLabel = this.truncateLabel(ctx, fullLabel, maxWidth);
|
|
6212
|
-
const labelY =
|
|
6213
|
-
ctx.fillText(truncatedLabel,
|
|
6276
|
+
const labelY = y3 + resolvedStyle.offsetY;
|
|
6277
|
+
ctx.fillText(truncatedLabel, x3, labelY);
|
|
6214
6278
|
}
|
|
6215
6279
|
} catch (error) {
|
|
6216
6280
|
ErrorHandler.logError(error);
|
|
@@ -6393,15 +6457,15 @@ var LinkLabelsRenderer = class {
|
|
|
6393
6457
|
/**
|
|
6394
6458
|
* Render a single label at given coordinates
|
|
6395
6459
|
*/
|
|
6396
|
-
static renderSingleLabel(ctx, text,
|
|
6460
|
+
static renderSingleLabel(ctx, text, x3, y3, style) {
|
|
6397
6461
|
ctx.font = style.font ?? "10px Arial";
|
|
6398
6462
|
const metrics = ctx.measureText(text);
|
|
6399
6463
|
const textWidth = metrics.width;
|
|
6400
6464
|
const textHeight = (metrics.actualBoundingBoxAscent || 10) + (metrics.actualBoundingBoxDescent || 4);
|
|
6401
6465
|
const rectWidth = textWidth + (style.paddingX ?? 8) * 2;
|
|
6402
6466
|
const rectHeight = textHeight + (style.paddingY ?? 4) * 2;
|
|
6403
|
-
const rectX =
|
|
6404
|
-
const rectY =
|
|
6467
|
+
const rectX = x3 - rectWidth / 2;
|
|
6468
|
+
const rectY = y3 - rectHeight / 2;
|
|
6405
6469
|
if (style.backgroundColor && style.backgroundColor !== "transparent") {
|
|
6406
6470
|
ctx.fillStyle = style.backgroundColor;
|
|
6407
6471
|
this.roundRect(ctx, rectX, rectY, rectWidth, rectHeight, style.borderRadius ?? 4);
|
|
@@ -6416,26 +6480,26 @@ var LinkLabelsRenderer = class {
|
|
|
6416
6480
|
ctx.fillStyle = style.textColor ?? "#000000";
|
|
6417
6481
|
ctx.textAlign = "center";
|
|
6418
6482
|
ctx.textBaseline = "middle";
|
|
6419
|
-
ctx.fillText(text,
|
|
6483
|
+
ctx.fillText(text, x3, y3);
|
|
6420
6484
|
}
|
|
6421
6485
|
/**
|
|
6422
6486
|
* Helper to draw rounded rectangle
|
|
6423
6487
|
*/
|
|
6424
|
-
static roundRect(ctx,
|
|
6488
|
+
static roundRect(ctx, x3, y3, width, height, radius) {
|
|
6425
6489
|
if (radius === 0) {
|
|
6426
|
-
ctx.rect(
|
|
6490
|
+
ctx.rect(x3, y3, width, height);
|
|
6427
6491
|
return;
|
|
6428
6492
|
}
|
|
6429
6493
|
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(
|
|
6494
|
+
ctx.moveTo(x3 + radius, y3);
|
|
6495
|
+
ctx.lineTo(x3 + width - radius, y3);
|
|
6496
|
+
ctx.quadraticCurveTo(x3 + width, y3, x3 + width, y3 + radius);
|
|
6497
|
+
ctx.lineTo(x3 + width, y3 + height - radius);
|
|
6498
|
+
ctx.quadraticCurveTo(x3 + width, y3 + height, x3 + width - radius, y3 + height);
|
|
6499
|
+
ctx.lineTo(x3 + radius, y3 + height);
|
|
6500
|
+
ctx.quadraticCurveTo(x3, y3 + height, x3, y3 + height - radius);
|
|
6501
|
+
ctx.lineTo(x3, y3 + radius);
|
|
6502
|
+
ctx.quadraticCurveTo(x3, y3, x3 + radius, y3);
|
|
6439
6503
|
ctx.closePath();
|
|
6440
6504
|
}
|
|
6441
6505
|
/**
|
|
@@ -7076,13 +7140,13 @@ var Renderer = class {
|
|
|
7076
7140
|
const arrowTipY = targetPoint.y + arrowLength * Math.sin(angle);
|
|
7077
7141
|
const x1 = arrowTipX - arrowLength * Math.cos(angle - Math.PI / 6);
|
|
7078
7142
|
const y1 = arrowTipY - arrowLength * Math.sin(angle - Math.PI / 6);
|
|
7079
|
-
const
|
|
7080
|
-
const
|
|
7143
|
+
const x22 = arrowTipX - arrowLength * Math.cos(angle + Math.PI / 6);
|
|
7144
|
+
const y22 = arrowTipY - arrowLength * Math.sin(angle + Math.PI / 6);
|
|
7081
7145
|
ctx.fillStyle = arrowStyle.fill ?? "#000000";
|
|
7082
7146
|
ctx.beginPath();
|
|
7083
7147
|
ctx.moveTo(arrowTipX, arrowTipY);
|
|
7084
7148
|
ctx.lineTo(x1, y1);
|
|
7085
|
-
ctx.lineTo(
|
|
7149
|
+
ctx.lineTo(x22, y22);
|
|
7086
7150
|
ctx.closePath();
|
|
7087
7151
|
ctx.fill();
|
|
7088
7152
|
} catch (error) {
|
|
@@ -8491,7 +8555,7 @@ var V2Graph = class {
|
|
|
8491
8555
|
/**
|
|
8492
8556
|
* Draw legend on export canvas
|
|
8493
8557
|
*/
|
|
8494
|
-
drawLegendOnExportCanvas(ctx, legendElement,
|
|
8558
|
+
drawLegendOnExportCanvas(ctx, legendElement, x3, y3) {
|
|
8495
8559
|
const legendItems = legendElement.querySelectorAll(".pg-legend-item");
|
|
8496
8560
|
const padding = 16;
|
|
8497
8561
|
const itemHeight = 24;
|
|
@@ -8501,8 +8565,8 @@ var V2Graph = class {
|
|
|
8501
8565
|
ctx.fillStyle = "#ffffff";
|
|
8502
8566
|
ctx.strokeStyle = "#e2e8f0";
|
|
8503
8567
|
ctx.lineWidth = 1;
|
|
8504
|
-
ctx.fillRect(
|
|
8505
|
-
ctx.strokeRect(
|
|
8568
|
+
ctx.fillRect(x3, y3, legendWidth, legendHeight);
|
|
8569
|
+
ctx.strokeRect(x3, y3, legendWidth, legendHeight);
|
|
8506
8570
|
ctx.font = "12px Arial, sans-serif";
|
|
8507
8571
|
ctx.textAlign = "left";
|
|
8508
8572
|
ctx.textBaseline = "middle";
|
|
@@ -8510,8 +8574,8 @@ var V2Graph = class {
|
|
|
8510
8574
|
const swatch = item.querySelector(".pg-legend-swatch");
|
|
8511
8575
|
const label = item.querySelector(".pg-legend-label");
|
|
8512
8576
|
if (swatch && label) {
|
|
8513
|
-
const itemY =
|
|
8514
|
-
const swatchX =
|
|
8577
|
+
const itemY = y3 + padding + index2 * (itemHeight + itemSpacing) + itemHeight / 2;
|
|
8578
|
+
const swatchX = x3 + padding;
|
|
8515
8579
|
const textX = swatchX + 14 + 8;
|
|
8516
8580
|
const swatchColor = swatch.style.backgroundColor || "#94a3b8";
|
|
8517
8581
|
ctx.fillStyle = swatchColor;
|