@euphrasiologist/lwphylo 1.2.10 → 1.2.12
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.
- package/dist/drawPhylogeny.cjs +51 -17
- package/dist/drawPhylogeny.cjs.map +1 -1
- package/dist/drawPhylogeny.esm.js +51 -17
- package/dist/drawPhylogeny.esm.js.map +1 -1
- package/dist/drawPhylogeny.umd.js +1 -1
- package/dist/drawPhylogeny.umd.js.map +1 -1
- package/dist/index.cjs +36 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/drawPhylogeny.cjs
CHANGED
|
@@ -61,6 +61,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
|
|
|
61
61
|
return `M ${p0.x} ${p0.y} A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${p1.x} ${p1.y}`;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// src/radial/describeArcSweep.js
|
|
65
|
+
const TAU$1 = Math.PI * 2;
|
|
66
|
+
const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
|
|
67
|
+
|
|
68
|
+
function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
|
|
69
|
+
const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
|
|
70
|
+
if (!(r > 0) || delta < 1e-9) return "";
|
|
71
|
+
const largeArcFlag = delta > Math.PI ? 1 : 0;
|
|
72
|
+
|
|
73
|
+
const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
|
|
74
|
+
const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
|
|
75
|
+
|
|
76
|
+
return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
64
79
|
/**
|
|
65
80
|
* Recursive function for pre-order traversal of tree (returns array)
|
|
66
81
|
*/
|
|
@@ -1130,6 +1145,7 @@ function drawPhylogeny(
|
|
|
1130
1145
|
.scaleLinear()
|
|
1131
1146
|
.domain([-scaleRadial, scaleRadial])
|
|
1132
1147
|
.range([h, 0]);
|
|
1148
|
+
|
|
1133
1149
|
const radiusPx = (r) => r * (w / (2 * scaleRadial));
|
|
1134
1150
|
|
|
1135
1151
|
// ===== INDEXES / HELPERS =====
|
|
@@ -1183,14 +1199,24 @@ function drawPhylogeny(
|
|
|
1183
1199
|
.data(rad.arcs)
|
|
1184
1200
|
.join("path")
|
|
1185
1201
|
.attr("d", (d) =>
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1202
|
+
d.sweep == null
|
|
1203
|
+
? describeArc(
|
|
1204
|
+
centerX,
|
|
1205
|
+
centerY,
|
|
1206
|
+
radiusPx(d.radius),
|
|
1207
|
+
d.start,
|
|
1208
|
+
d.end
|
|
1209
|
+
)
|
|
1210
|
+
: describeArcSweep(
|
|
1211
|
+
centerX,
|
|
1212
|
+
centerY,
|
|
1213
|
+
radiusPx(d.radius),
|
|
1214
|
+
d.start,
|
|
1215
|
+
d.end,
|
|
1216
|
+
d.sweep
|
|
1217
|
+
)
|
|
1193
1218
|
)
|
|
1219
|
+
|
|
1194
1220
|
.attr("fill", "none")
|
|
1195
1221
|
.attr("stroke", "#777")
|
|
1196
1222
|
.attr("stroke-width", strokeWidth);
|
|
@@ -1314,7 +1340,7 @@ function drawPhylogeny(
|
|
|
1314
1340
|
|
|
1315
1341
|
// label hover
|
|
1316
1342
|
labels
|
|
1317
|
-
.on("mouseenter", function(
|
|
1343
|
+
.on("mouseenter", function(_event, d) {
|
|
1318
1344
|
drawRadialPath(d, hoverLines, hoverArcs, hoverStroke, hoverWidth);
|
|
1319
1345
|
d3__namespace.select(this).select("text").attr("font-weight", 600);
|
|
1320
1346
|
})
|
|
@@ -1371,15 +1397,23 @@ function drawPhylogeny(
|
|
|
1371
1397
|
if (a) {
|
|
1372
1398
|
arcLayer
|
|
1373
1399
|
.append("path")
|
|
1374
|
-
.attr(
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1400
|
+
.attr("d", (d) =>
|
|
1401
|
+
d.sweep == null
|
|
1402
|
+
? describeArc(
|
|
1403
|
+
centerX,
|
|
1404
|
+
centerY,
|
|
1405
|
+
radiusPx(d.radius),
|
|
1406
|
+
d.start,
|
|
1407
|
+
d.end
|
|
1408
|
+
)
|
|
1409
|
+
: describeArcSweep(
|
|
1410
|
+
centerX,
|
|
1411
|
+
centerY,
|
|
1412
|
+
radiusPx(d.radius),
|
|
1413
|
+
d.start,
|
|
1414
|
+
d.end,
|
|
1415
|
+
d.sweep
|
|
1416
|
+
)
|
|
1383
1417
|
)
|
|
1384
1418
|
.attr("fill", "none")
|
|
1385
1419
|
.attr("stroke", stroke)
|