@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.
@@ -1094,6 +1094,10 @@ function drawPhylogeny(
1094
1094
 
1095
1095
  return svg.node();
1096
1096
  } else if (layout === "radial") {
1097
+ // RADIAL LAYOUT
1098
+ if (width !== height) {
1099
+ throw new Error("width and height must be the same for radial layout");
1100
+ }
1097
1101
  const parsedTree = readTree(treeText);
1098
1102
  const rad = radialLayout(parsedTree, {
1099
1103
  angleStrategy: "fan",
@@ -1103,6 +1107,10 @@ function drawPhylogeny(
1103
1107
  // ===== MODE =====
1104
1108
  const TIP_MODE = radialMode; // "phylo" (shorten to original tips) or "outer" (project to one circle)
1105
1109
  const isOuter = TIP_MODE === "outer";
1110
+ if (TIP_MODE !== "phylo" && TIP_MODE !== "outer") {
1111
+ throw new Error("radialMode must be either 'phylo' or 'outer'");
1112
+ }
1113
+
1106
1114
 
1107
1115
  // visuals (0 = let spokes reach the dots)
1108
1116
  const DOT_R = 3;
@@ -1268,7 +1276,7 @@ function drawPhylogeny(
1268
1276
 
1269
1277
  // maps for fast lookup on hover (childId → spoke / arc)
1270
1278
  const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1271
- const arcByChild = new Map(rad.child_arcs.map((a) => [a.childId, a]));
1279
+ const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
1272
1280
 
1273
1281
  // ===== LABELS =====
1274
1282
  // Labels — make them follow the tip position used by the current mode
@@ -1374,29 +1382,17 @@ function drawPhylogeny(
1374
1382
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1375
1383
  const a = arcByChild.get(cur.thisId);
1376
1384
  if (a) {
1385
+ const pathD = (a.sweep == null)
1386
+ ? describeArc(centerX, centerY, radiusPx(a.radius), a.start, a.end)
1387
+ : describeArcSweep(centerX, centerY, radiusPx(a.radius), a.start, a.end, a.sweep);
1388
+
1377
1389
  arcLayer
1378
1390
  .append("path")
1379
- .attr("d", (d) =>
1380
- d.sweep == null
1381
- ? describeArc(
1382
- centerX,
1383
- centerY,
1384
- radiusPx(d.radius),
1385
- d.start,
1386
- d.end
1387
- )
1388
- : describeArcSweep(
1389
- centerX,
1390
- centerY,
1391
- radiusPx(d.radius),
1392
- d.start,
1393
- d.end,
1394
- d.sweep
1395
- )
1396
- )
1391
+ .attr("d", pathD)
1397
1392
  .attr("fill", "none")
1398
1393
  .attr("stroke", stroke)
1399
1394
  .attr("stroke-width", width);
1395
+
1400
1396
  }
1401
1397
 
1402
1398
  first = false;