@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.
@@ -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;
@@ -1178,14 +1186,24 @@ function drawPhylogeny(
1178
1186
  .data(rad.arcs)
1179
1187
  .join("path")
1180
1188
  .attr("d", (d) =>
1181
- describeArc(
1182
- centerX,
1183
- centerY,
1184
- Math.max(0, radiusPx(d.radius)),
1185
- d.start,
1186
- d.end
1187
- )
1189
+ d.sweep == null
1190
+ ? describeArc(
1191
+ centerX,
1192
+ centerY,
1193
+ radiusPx(d.radius),
1194
+ d.start,
1195
+ d.end
1196
+ )
1197
+ : describeArcSweep(
1198
+ centerX,
1199
+ centerY,
1200
+ radiusPx(d.radius),
1201
+ d.start,
1202
+ d.end,
1203
+ d.sweep
1204
+ )
1188
1205
  )
1206
+
1189
1207
  .attr("fill", "none")
1190
1208
  .attr("stroke", "#777")
1191
1209
  .attr("stroke-width", strokeWidth);
@@ -1258,7 +1276,7 @@ function drawPhylogeny(
1258
1276
 
1259
1277
  // maps for fast lookup on hover (childId → spoke / arc)
1260
1278
  const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1261
- 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]));
1262
1280
 
1263
1281
  // ===== LABELS =====
1264
1282
  // Labels — make them follow the tip position used by the current mode
@@ -1364,29 +1382,17 @@ function drawPhylogeny(
1364
1382
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1365
1383
  const a = arcByChild.get(cur.thisId);
1366
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
+
1367
1389
  arcLayer
1368
1390
  .append("path")
1369
- .attr("d", (d) =>
1370
- d.sweep == null
1371
- ? describeArc(
1372
- centerX,
1373
- centerY,
1374
- radiusPx(d.radius),
1375
- d.start,
1376
- d.end
1377
- )
1378
- : describeArcSweep(
1379
- centerX,
1380
- centerY,
1381
- radiusPx(d.radius),
1382
- d.start,
1383
- d.end,
1384
- d.sweep
1385
- )
1386
- )
1391
+ .attr("d", pathD)
1387
1392
  .attr("fill", "none")
1388
1393
  .attr("stroke", stroke)
1389
1394
  .attr("stroke-width", width);
1395
+
1390
1396
  }
1391
1397
 
1392
1398
  first = false;