@euphrasiologist/lwphylo 1.2.10 → 1.2.11

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.
@@ -40,6 +40,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
40
40
  return `M ${p0.x} ${p0.y} A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
41
41
  }
42
42
 
43
+ // src/radial/describeArcSweep.js
44
+ const TAU$1 = Math.PI * 2;
45
+ const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
46
+
47
+ function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
48
+ const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
49
+ if (!(r > 0) || delta < 1e-9) return "";
50
+ const largeArcFlag = delta > Math.PI ? 1 : 0;
51
+
52
+ const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
53
+ const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
54
+
55
+ return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
56
+ }
57
+
43
58
  /**
44
59
  * Recursive function for pre-order traversal of tree (returns array)
45
60
  */
@@ -1109,6 +1124,7 @@ function drawPhylogeny(
1109
1124
  .scaleLinear()
1110
1125
  .domain([-scaleRadial, scaleRadial])
1111
1126
  .range([h, 0]);
1127
+
1112
1128
  const radiusPx = (r) => r * (w / (2 * scaleRadial));
1113
1129
 
1114
1130
  // ===== INDEXES / HELPERS =====
@@ -1293,7 +1309,7 @@ function drawPhylogeny(
1293
1309
 
1294
1310
  // label hover
1295
1311
  labels
1296
- .on("mouseenter", function(event, d) {
1312
+ .on("mouseenter", function(_event, d) {
1297
1313
  drawRadialPath(d, hoverLines, hoverArcs, hoverStroke, hoverWidth);
1298
1314
  d3.select(this).select("text").attr("font-weight", 600);
1299
1315
  })
@@ -1350,15 +1366,23 @@ function drawPhylogeny(
1350
1366
  if (a) {
1351
1367
  arcLayer
1352
1368
  .append("path")
1353
- .attr(
1354
- "d",
1355
- describeArc(
1356
- centerX,
1357
- centerY,
1358
- Math.max(0, radiusPx(a.radius)),
1359
- a.start,
1360
- a.end
1361
- )
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
+ )
1362
1386
  )
1363
1387
  .attr("fill", "none")
1364
1388
  .attr("stroke", stroke)