@euphrasiologist/lwphylo 1.2.16 → 1.2.17

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.
@@ -1215,29 +1215,6 @@ function drawPhylogeny(
1215
1215
  return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
1216
1216
  }
1217
1217
 
1218
- // put this next to your other radial helpers (top of file or in your lib)
1219
- function arcPathCCW(cx, cy, R, a0, a1) {
1220
- const TAU = Math.PI * 2;
1221
- const norm = (t) => ((t % TAU) + TAU) % TAU;
1222
-
1223
- a0 = norm(a0);
1224
- a1 = norm(a1);
1225
-
1226
- const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
1227
- if (delta < 1e-9) return ""; // degenerate; draw nothing
1228
-
1229
- // With your polarToCartesian using y = cy - r*sin(t),
1230
- // sweepFlag=0 gives a visually CCW arc segment.
1231
- const largeArcFlag = delta > Math.PI ? 1 : 0;
1232
- const sweepFlag = 0;
1233
-
1234
- const p0 = polarToCartesian(cx, cy, R, a0);
1235
- const p1 = polarToCartesian(cx, cy, R, a1);
1236
-
1237
- return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
1238
- }
1239
-
1240
-
1241
1218
  // ===== SVG ROOT =====
1242
1219
  const svg = d3
1243
1220
  .create("svg")
@@ -1350,8 +1327,10 @@ function drawPhylogeny(
1350
1327
  }
1351
1328
 
1352
1329
  // maps for fast lookup on hover (childId → spoke / arc)
1353
- const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1354
- const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
1330
+ const key = (x) => (typeof x === "string" ? +x : x);
1331
+ const spokeByChild = new Map(rad.radii.map(s => [key(s.childId ?? s.thisId ?? s.id1), s]));
1332
+ const arcByChild = new Map(rad.child_arcs.map(a => [key(a.childId), a]));
1333
+
1355
1334
 
1356
1335
  // ===== LABELS =====
1357
1336
  // Labels — make them follow the tip position used by the current mode
@@ -1457,11 +1436,17 @@ function drawPhylogeny(
1457
1436
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1458
1437
  const a = arcByChild.get(cur.thisId);
1459
1438
  if (a) {
1460
- const pathD = arcPathCCW(centerX, centerY, radiusPx(a.radius), a.start, a.end);
1439
+ function pathFromArcRecord(rec) {
1440
+ const R = radiusPx(rec.radius);
1441
+ return rec.sweep == null
1442
+ ? describeArc(centerX, centerY, R, rec.start, rec.end)
1443
+ : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
1444
+ }
1445
+
1461
1446
 
1462
1447
  arcLayer
1463
1448
  .append("path")
1464
- .attr("d", pathD)
1449
+ .attr("d", pathFromArcRecord(a))
1465
1450
  .attr("fill", "none")
1466
1451
  .attr("stroke", stroke)
1467
1452
  .attr("stroke-width", width);