@euphrasiologist/lwphylo 1.2.19 → 1.2.21

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.
@@ -473,6 +473,9 @@ function getChildArcsFan(pd) {
473
473
  const TAU = Math.PI * 2;
474
474
  const norm = (t) => ((t % TAU) + TAU) % TAU;
475
475
 
476
+ const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
477
+ const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
478
+
476
479
  // Circular midpoint that travels CCW from a -> b by half the CCW span
477
480
  function midCCW(a, b) {
478
481
  const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
@@ -518,20 +521,25 @@ function getChildArcsFan(pd) {
518
521
 
519
522
  for (let i = 0; i < N; i++) {
520
523
  const prev = A[(i - 1 + N) % N];
521
- const cur = A[i];
524
+ const cur = A[i];
522
525
  const next = A[(i + 1) % N];
523
526
 
524
527
  // “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
525
528
  const start = midCCW(prev.a, cur.a);
526
- const end = midCCW(cur.a, next.a);
529
+ const end = midCCW(cur.a, next.a);
530
+
531
+ // Choose the **shorter** sweep (0 = CCW, 1 = CW in our math-angle convention)
532
+ const ccw = ccwDelta(start, end);
533
+ const cw = cwDelta(start, end);
534
+ const sweep = ccw <= cw ? 0 : 1;
527
535
 
528
536
  child_arcs.push({
529
537
  parentId: pid,
530
- childId: cur.id,
538
+ childId: cur.id,
531
539
  radius,
532
540
  start,
533
541
  end,
534
- sweep: 0 // CCW (consistent with describeArcSweep and your y-flip)
542
+ sweep
535
543
  });
536
544
  }
537
545
  }
@@ -539,8 +547,6 @@ function getChildArcsFan(pd) {
539
547
  return child_arcs;
540
548
  }
541
549
 
542
- // src/radial/radialLayout.js
543
-
544
550
  /**
545
551
  * radialLayout(node, opts?)
546
552
  * opts:
@@ -586,7 +592,7 @@ function radialLayout(node, opts = {}) {
586
592
 
587
593
  // per-child arcs for half-arc highlighting if you already use them
588
594
  let child_arcs = [];
589
- if (opts.arcsStyle === "fan") {
595
+ if (arcsStyle === "fan") {
590
596
  child_arcs = getChildArcsFan(pd);
591
597
  } else {
592
598
  child_arcs = getChildArcs(pd);
@@ -1447,7 +1453,10 @@ function drawPhylogeny(
1447
1453
  lineLayer.selectAll("*").remove();
1448
1454
  arcLayer.selectAll("*").remove();
1449
1455
 
1450
- let cur = typeof target === "number" ? byId.get(target) : target;
1456
+ let cur = (typeof target === "number" || typeof target === "string")
1457
+ ? byId.get(target)
1458
+ : target;
1459
+
1451
1460
  if (!cur) return;
1452
1461
 
1453
1462
  let first = true;