@euphrasiologist/lwphylo 1.2.11 → 1.2.13
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/drawPhylogeny.cjs +32 -26
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +32 -26
- package/dist/drawPhylogeny.esm.js.map +1 -1
- package/dist/drawPhylogeny.umd.js +1 -1
- package/dist/drawPhylogeny.umd.js.map +1 -1
- package/dist/index.cjs +32 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1261,6 +1261,10 @@ function drawPhylogeny(
|
|
|
1261
1261
|
|
|
1262
1262
|
return svg.node();
|
|
1263
1263
|
} else if (layout === "radial") {
|
|
1264
|
+
// RADIAL LAYOUT
|
|
1265
|
+
if (width !== height) {
|
|
1266
|
+
throw new Error("width and height must be the same for radial layout");
|
|
1267
|
+
}
|
|
1264
1268
|
const parsedTree = readTree(treeText);
|
|
1265
1269
|
const rad = radialLayout(parsedTree, {
|
|
1266
1270
|
angleStrategy: "fan",
|
|
@@ -1270,6 +1274,10 @@ function drawPhylogeny(
|
|
|
1270
1274
|
// ===== MODE =====
|
|
1271
1275
|
const TIP_MODE = radialMode; // "phylo" (shorten to original tips) or "outer" (project to one circle)
|
|
1272
1276
|
const isOuter = TIP_MODE === "outer";
|
|
1277
|
+
if (TIP_MODE !== "phylo" && TIP_MODE !== "outer") {
|
|
1278
|
+
throw new Error("radialMode must be either 'phylo' or 'outer'");
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1273
1281
|
|
|
1274
1282
|
// visuals (0 = let spokes reach the dots)
|
|
1275
1283
|
const DOT_R = 3;
|
|
@@ -1345,14 +1353,24 @@ function drawPhylogeny(
|
|
|
1345
1353
|
.data(rad.arcs)
|
|
1346
1354
|
.join("path")
|
|
1347
1355
|
.attr("d", (d) =>
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1356
|
+
d.sweep == null
|
|
1357
|
+
? describeArc(
|
|
1358
|
+
centerX,
|
|
1359
|
+
centerY,
|
|
1360
|
+
radiusPx(d.radius),
|
|
1361
|
+
d.start,
|
|
1362
|
+
d.end
|
|
1363
|
+
)
|
|
1364
|
+
: describeArcSweep(
|
|
1365
|
+
centerX,
|
|
1366
|
+
centerY,
|
|
1367
|
+
radiusPx(d.radius),
|
|
1368
|
+
d.start,
|
|
1369
|
+
d.end,
|
|
1370
|
+
d.sweep
|
|
1371
|
+
)
|
|
1355
1372
|
)
|
|
1373
|
+
|
|
1356
1374
|
.attr("fill", "none")
|
|
1357
1375
|
.attr("stroke", "#777")
|
|
1358
1376
|
.attr("stroke-width", strokeWidth);
|
|
@@ -1425,7 +1443,7 @@ function drawPhylogeny(
|
|
|
1425
1443
|
|
|
1426
1444
|
// maps for fast lookup on hover (childId → spoke / arc)
|
|
1427
1445
|
const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
|
|
1428
|
-
const arcByChild = new Map(rad.child_arcs.map((a) => [a.childId, a]));
|
|
1446
|
+
const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
|
|
1429
1447
|
|
|
1430
1448
|
// ===== LABELS =====
|
|
1431
1449
|
// Labels — make them follow the tip position used by the current mode
|
|
@@ -1531,29 +1549,17 @@ function drawPhylogeny(
|
|
|
1531
1549
|
// ----- half-arc at parent radius (parent.angle → child.angle) -----
|
|
1532
1550
|
const a = arcByChild.get(cur.thisId);
|
|
1533
1551
|
if (a) {
|
|
1552
|
+
const pathD = (a.sweep == null)
|
|
1553
|
+
? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
|
|
1554
|
+
: describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
|
|
1555
|
+
|
|
1534
1556
|
arcLayer
|
|
1535
1557
|
.append("path")
|
|
1536
|
-
.attr("d",
|
|
1537
|
-
d.sweep == null
|
|
1538
|
-
? describeArc(
|
|
1539
|
-
centerX,
|
|
1540
|
-
centerY,
|
|
1541
|
-
radiusPx(d.radius),
|
|
1542
|
-
d.start,
|
|
1543
|
-
d.end
|
|
1544
|
-
)
|
|
1545
|
-
: describeArcSweep(
|
|
1546
|
-
centerX,
|
|
1547
|
-
centerY,
|
|
1548
|
-
radiusPx(d.radius),
|
|
1549
|
-
d.start,
|
|
1550
|
-
d.end,
|
|
1551
|
-
d.sweep
|
|
1552
|
-
)
|
|
1553
|
-
)
|
|
1558
|
+
.attr("d", pathD)
|
|
1554
1559
|
.attr("fill", "none")
|
|
1555
1560
|
.attr("stroke", stroke)
|
|
1556
1561
|
.attr("stroke-width", width);
|
|
1562
|
+
|
|
1557
1563
|
}
|
|
1558
1564
|
|
|
1559
1565
|
first = false;
|