@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.cjs
CHANGED
|
@@ -1282,6 +1282,10 @@ function drawPhylogeny(
|
|
|
1282
1282
|
|
|
1283
1283
|
return svg.node();
|
|
1284
1284
|
} else if (layout === "radial") {
|
|
1285
|
+
// RADIAL LAYOUT
|
|
1286
|
+
if (width !== height) {
|
|
1287
|
+
throw new Error("width and height must be the same for radial layout");
|
|
1288
|
+
}
|
|
1285
1289
|
const parsedTree = readTree(treeText);
|
|
1286
1290
|
const rad = radialLayout(parsedTree, {
|
|
1287
1291
|
angleStrategy: "fan",
|
|
@@ -1291,6 +1295,10 @@ function drawPhylogeny(
|
|
|
1291
1295
|
// ===== MODE =====
|
|
1292
1296
|
const TIP_MODE = radialMode; // "phylo" (shorten to original tips) or "outer" (project to one circle)
|
|
1293
1297
|
const isOuter = TIP_MODE === "outer";
|
|
1298
|
+
if (TIP_MODE !== "phylo" && TIP_MODE !== "outer") {
|
|
1299
|
+
throw new Error("radialMode must be either 'phylo' or 'outer'");
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1294
1302
|
|
|
1295
1303
|
// visuals (0 = let spokes reach the dots)
|
|
1296
1304
|
const DOT_R = 3;
|
|
@@ -1366,14 +1374,24 @@ function drawPhylogeny(
|
|
|
1366
1374
|
.data(rad.arcs)
|
|
1367
1375
|
.join("path")
|
|
1368
1376
|
.attr("d", (d) =>
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1377
|
+
d.sweep == null
|
|
1378
|
+
? describeArc(
|
|
1379
|
+
centerX,
|
|
1380
|
+
centerY,
|
|
1381
|
+
radiusPx(d.radius),
|
|
1382
|
+
d.start,
|
|
1383
|
+
d.end
|
|
1384
|
+
)
|
|
1385
|
+
: describeArcSweep(
|
|
1386
|
+
centerX,
|
|
1387
|
+
centerY,
|
|
1388
|
+
radiusPx(d.radius),
|
|
1389
|
+
d.start,
|
|
1390
|
+
d.end,
|
|
1391
|
+
d.sweep
|
|
1392
|
+
)
|
|
1376
1393
|
)
|
|
1394
|
+
|
|
1377
1395
|
.attr("fill", "none")
|
|
1378
1396
|
.attr("stroke", "#777")
|
|
1379
1397
|
.attr("stroke-width", strokeWidth);
|
|
@@ -1446,7 +1464,7 @@ function drawPhylogeny(
|
|
|
1446
1464
|
|
|
1447
1465
|
// maps for fast lookup on hover (childId → spoke / arc)
|
|
1448
1466
|
const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
|
|
1449
|
-
const arcByChild = new Map(rad.child_arcs.map((a) => [a.childId, a]));
|
|
1467
|
+
const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
|
|
1450
1468
|
|
|
1451
1469
|
// ===== LABELS =====
|
|
1452
1470
|
// Labels — make them follow the tip position used by the current mode
|
|
@@ -1552,29 +1570,17 @@ function drawPhylogeny(
|
|
|
1552
1570
|
// ----- half-arc at parent radius (parent.angle → child.angle) -----
|
|
1553
1571
|
const a = arcByChild.get(cur.thisId);
|
|
1554
1572
|
if (a) {
|
|
1573
|
+
const pathD = (a.sweep == null)
|
|
1574
|
+
? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
|
|
1575
|
+
: describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
|
|
1576
|
+
|
|
1555
1577
|
arcLayer
|
|
1556
1578
|
.append("path")
|
|
1557
|
-
.attr("d",
|
|
1558
|
-
d.sweep == null
|
|
1559
|
-
? describeArc(
|
|
1560
|
-
centerX,
|
|
1561
|
-
centerY,
|
|
1562
|
-
radiusPx(d.radius),
|
|
1563
|
-
d.start,
|
|
1564
|
-
d.end
|
|
1565
|
-
)
|
|
1566
|
-
: describeArcSweep(
|
|
1567
|
-
centerX,
|
|
1568
|
-
centerY,
|
|
1569
|
-
radiusPx(d.radius),
|
|
1570
|
-
d.start,
|
|
1571
|
-
d.end,
|
|
1572
|
-
d.sweep
|
|
1573
|
-
)
|
|
1574
|
-
)
|
|
1579
|
+
.attr("d", pathD)
|
|
1575
1580
|
.attr("fill", "none")
|
|
1576
1581
|
.attr("stroke", stroke)
|
|
1577
1582
|
.attr("stroke-width", width);
|
|
1583
|
+
|
|
1578
1584
|
}
|
|
1579
1585
|
|
|
1580
1586
|
first = false;
|