@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.
@@ -1115,6 +1115,10 @@ function drawPhylogeny(
1115
1115
 
1116
1116
  return svg.node();
1117
1117
  } else if (layout === "radial") {
1118
+ // RADIAL LAYOUT
1119
+ if (width !== height) {
1120
+ throw new Error("width and height must be the same for radial layout");
1121
+ }
1118
1122
  const parsedTree = readTree(treeText);
1119
1123
  const rad = radialLayout(parsedTree, {
1120
1124
  angleStrategy: "fan",
@@ -1124,6 +1128,10 @@ function drawPhylogeny(
1124
1128
  // ===== MODE =====
1125
1129
  const TIP_MODE = radialMode; // "phylo" (shorten to original tips) or "outer" (project to one circle)
1126
1130
  const isOuter = TIP_MODE === "outer";
1131
+ if (TIP_MODE !== "phylo" && TIP_MODE !== "outer") {
1132
+ throw new Error("radialMode must be either 'phylo' or 'outer'");
1133
+ }
1134
+
1127
1135
 
1128
1136
  // visuals (0 = let spokes reach the dots)
1129
1137
  const DOT_R = 3;
@@ -1289,7 +1297,7 @@ function drawPhylogeny(
1289
1297
 
1290
1298
  // maps for fast lookup on hover (childId → spoke / arc)
1291
1299
  const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1292
- const arcByChild = new Map(rad.child_arcs.map((a) => [a.childId, a]));
1300
+ const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
1293
1301
 
1294
1302
  // ===== LABELS =====
1295
1303
  // Labels — make them follow the tip position used by the current mode
@@ -1395,29 +1403,17 @@ function drawPhylogeny(
1395
1403
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1396
1404
  const a = arcByChild.get(cur.thisId);
1397
1405
  if (a) {
1406
+ const pathD = (a.sweep == null)
1407
+ ? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
1408
+ : describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
1409
+
1398
1410
  arcLayer
1399
1411
  .append("path")
1400
- .attr("d", (d) =>
1401
- d.sweep == null
1402
- ? describeArc(
1403
- centerX,
1404
- centerY,
1405
- radiusPx(d.radius),
1406
- d.start,
1407
- d.end
1408
- )
1409
- : describeArcSweep(
1410
- centerX,
1411
- centerY,
1412
- radiusPx(d.radius),
1413
- d.start,
1414
- d.end,
1415
- d.sweep
1416
- )
1417
- )
1412
+ .attr("d", pathD)
1418
1413
  .attr("fill", "none")
1419
1414
  .attr("stroke", stroke)
1420
1415
  .attr("stroke-width", width);
1416
+
1421
1417
  }
1422
1418
 
1423
1419
  first = false;