@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.
@@ -1236,29 +1236,6 @@ function drawPhylogeny(
1236
1236
  return { X0, Y0, X1s: X0 + dx * t, Y1s: Y0 + dy * t, len };
1237
1237
  }
1238
1238
 
1239
- // put this next to your other radial helpers (top of file or in your lib)
1240
- function arcPathCCW(cx, cy, R, a0, a1) {
1241
- const TAU = Math.PI * 2;
1242
- const norm = (t) => ((t % TAU) + TAU) % TAU;
1243
-
1244
- a0 = norm(a0);
1245
- a1 = norm(a1);
1246
-
1247
- const delta = (a1 - a0 + TAU) % TAU; // CCW span a0 -> a1 in [0, 2π)
1248
- if (delta < 1e-9) return ""; // degenerate; draw nothing
1249
-
1250
- // With your polarToCartesian using y = cy - r*sin(t),
1251
- // sweepFlag=0 gives a visually CCW arc segment.
1252
- const largeArcFlag = delta > Math.PI ? 1 : 0;
1253
- const sweepFlag = 0;
1254
-
1255
- const p0 = polarToCartesian(cx, cy, R, a0);
1256
- const p1 = polarToCartesian(cx, cy, R, a1);
1257
-
1258
- return `M ${p0.x} ${p0.y} A ${R} ${R} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
1259
- }
1260
-
1261
-
1262
1239
  // ===== SVG ROOT =====
1263
1240
  const svg = d3__namespace
1264
1241
  .create("svg")
@@ -1371,8 +1348,10 @@ function drawPhylogeny(
1371
1348
  }
1372
1349
 
1373
1350
  // maps for fast lookup on hover (childId → spoke / arc)
1374
- const spokeByChild = new Map(rad.radii.map((s) => [childIdOf(s), s]));
1375
- const arcByChild = new Map((rad.child_arcs ?? []).map((a) => [a.childId, a]));
1351
+ const key = (x) => (typeof x === "string" ? +x : x);
1352
+ const spokeByChild = new Map(rad.radii.map(s => [key(s.childId ?? s.thisId ?? s.id1), s]));
1353
+ const arcByChild = new Map(rad.child_arcs.map(a => [key(a.childId), a]));
1354
+
1376
1355
 
1377
1356
  // ===== LABELS =====
1378
1357
  // Labels — make them follow the tip position used by the current mode
@@ -1478,11 +1457,17 @@ function drawPhylogeny(
1478
1457
  // ----- half-arc at parent radius (parent.angle → child.angle) -----
1479
1458
  const a = arcByChild.get(cur.thisId);
1480
1459
  if (a) {
1481
- const pathD = arcPathCCW(centerX, centerY, radiusPx(a.radius), a.start, a.end);
1460
+ function pathFromArcRecord(rec) {
1461
+ const R = radiusPx(rec.radius);
1462
+ return rec.sweep == null
1463
+ ? describeArc(centerX, centerY, R, rec.start, rec.end)
1464
+ : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
1465
+ }
1466
+
1482
1467
 
1483
1468
  arcLayer
1484
1469
  .append("path")
1485
- .attr("d", pathD)
1470
+ .attr("d", pathFromArcRecord(a))
1486
1471
  .attr("fill", "none")
1487
1472
  .attr("stroke", stroke)
1488
1473
  .attr("stroke-width", width);