@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.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;
@@ -1435,7 +1443,7 @@ function drawPhylogeny(
1435
1443
 
1436
1444
  // maps for fast lookup on hover (childId → spoke / arc)
1437
1445
  const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1438
- 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]));
1439
1447
 
1440
1448
  // ===== LABELS =====
1441
1449
  // Labels — make them follow the tip position used by the current mode
@@ -1541,29 +1549,17 @@ function drawPhylogeny(
1541
1549
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1542
1550
  const a = arcByChild.get(cur.thisId);
1543
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
+
1544
1556
  arcLayer
1545
1557
  .append("path")
1546
- .attr("d", (d) =>
1547
- d.sweep == null
1548
- ? describeArc(
1549
- centerX,
1550
- centerY,
1551
- radiusPx(d.radius),
1552
- d.start,
1553
- d.end
1554
- )
1555
- : describeArcSweep(
1556
- centerX,
1557
- centerY,
1558
- radiusPx(d.radius),
1559
- d.start,
1560
- d.end,
1561
- d.sweep
1562
- )
1563
- )
1558
+ .attr("d", pathD)
1564
1559
  .attr("fill", "none")
1565
1560
  .attr("stroke", stroke)
1566
1561
  .attr("stroke-width", width);
1562
+
1567
1563
  }
1568
1564
 
1569
1565
  first = false;