@euphrasiologist/lwphylo 1.2.12 → 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/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;
@@ -1456,7 +1464,7 @@ function drawPhylogeny(
1456
1464
 
1457
1465
  // maps for fast lookup on hover (childId → spoke / arc)
1458
1466
  const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1459
- 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]));
1460
1468
 
1461
1469
  // ===== LABELS =====
1462
1470
  // Labels — make them follow the tip position used by the current mode
@@ -1562,29 +1570,17 @@ function drawPhylogeny(
1562
1570
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1563
1571
  const a = arcByChild.get(cur.thisId);
1564
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
+
1565
1577
  arcLayer
1566
1578
  .append("path")
1567
- .attr("d", (d) =>
1568
- d.sweep == null
1569
- ? describeArc(
1570
- centerX,
1571
- centerY,
1572
- radiusPx(d.radius),
1573
- d.start,
1574
- d.end
1575
- )
1576
- : describeArcSweep(
1577
- centerX,
1578
- centerY,
1579
- radiusPx(d.radius),
1580
- d.start,
1581
- d.end,
1582
- d.sweep
1583
- )
1584
- )
1579
+ .attr("d", pathD)
1585
1580
  .attr("fill", "none")
1586
1581
  .attr("stroke", stroke)
1587
1582
  .attr("stroke-width", width);
1583
+
1588
1584
  }
1589
1585
 
1590
1586
  first = false;