allotaxonometer-ui 0.1.6 → 0.1.8
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/README.md +1 -7
- package/dist/index.js +40 -320
- package/dist/ssr/index.js +24 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,12 +8,6 @@ Headless UI components for allotaxonometer visualizations built with Svelte 5.
|
|
|
8
8
|
npm install allotaxonometer-ui
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Make sure you have these installed:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install svelte d3 allotaxonometer @ungap/structured-clone
|
|
15
|
-
```
|
|
16
|
-
|
|
17
11
|
## Usage
|
|
18
12
|
|
|
19
13
|
```svelte
|
|
@@ -48,4 +42,4 @@ git clone https://github.com/yourusername/allotaxonometer-ui.git
|
|
|
48
42
|
cd allotaxonometer-ui
|
|
49
43
|
npm install
|
|
50
44
|
npm run build
|
|
51
|
-
```
|
|
45
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -56,12 +56,8 @@ function style(props) {
|
|
|
56
56
|
const alloFonts = {
|
|
57
57
|
family: `"EB Garamond", "Garamond", "Century Schoolbook L", "URW Bookman L", "Bookman Old Style", "Times", serif`,
|
|
58
58
|
sizes: {
|
|
59
|
-
xs: "10px",
|
|
60
|
-
sm: "12px",
|
|
61
59
|
md: "14px",
|
|
62
|
-
lg: "16px"
|
|
63
|
-
xl: "18px"
|
|
64
|
-
}
|
|
60
|
+
lg: "16px"}
|
|
65
61
|
|
|
66
62
|
};
|
|
67
63
|
|
|
@@ -83,8 +79,8 @@ function AxisX($$anchor, $$props) {
|
|
|
83
79
|
|
|
84
80
|
let helperText = () => style({
|
|
85
81
|
fontFamily: alloFonts.family,
|
|
86
|
-
fontSize: alloFonts.sizes.
|
|
87
|
-
fill: alloColors.css.
|
|
82
|
+
fontSize: alloFonts.sizes.md,
|
|
83
|
+
fill: alloColors.css.darkgrey,
|
|
88
84
|
textAnchor: "middle"
|
|
89
85
|
});
|
|
90
86
|
|
|
@@ -108,7 +104,7 @@ function AxisX($$anchor, $$props) {
|
|
|
108
104
|
$.template_effect(
|
|
109
105
|
($0, $1, $2) => {
|
|
110
106
|
$.set_attribute(g_1, 'transform', `translate(${$0 ?? ''}, 0)`);
|
|
111
|
-
$.set_attribute(line, 'stroke', alloColors.css.
|
|
107
|
+
$.set_attribute(line, 'stroke', alloColors.css.darkergrey);
|
|
112
108
|
$.set_attribute(g_2, 'transform', `translate(${$1 ?? ''}, 0) scale(-1,1) rotate(45)`);
|
|
113
109
|
$.set_attribute(text, 'font-family', alloFonts.family);
|
|
114
110
|
$.set_attribute(text, 'font-size', alloFonts.sizes.md);
|
|
@@ -202,8 +198,8 @@ function AxisY($$anchor, $$props) {
|
|
|
202
198
|
|
|
203
199
|
let helperText = () => style({
|
|
204
200
|
fontFamily: alloFonts.family,
|
|
205
|
-
fontSize: alloFonts.sizes.
|
|
206
|
-
fill: alloColors.css.
|
|
201
|
+
fontSize: alloFonts.sizes.md,
|
|
202
|
+
fill: alloColors.css.darkgrey,
|
|
207
203
|
textAnchor: "middle"
|
|
208
204
|
});
|
|
209
205
|
|
|
@@ -227,7 +223,7 @@ function AxisY($$anchor, $$props) {
|
|
|
227
223
|
$.template_effect(
|
|
228
224
|
($0, $1, $2) => {
|
|
229
225
|
$.set_attribute(g_1, 'transform', `translate(0, ${$0 ?? ''})`);
|
|
230
|
-
$.set_attribute(line, 'stroke', alloColors.css.
|
|
226
|
+
$.set_attribute(line, 'stroke', alloColors.css.darkergrey);
|
|
231
227
|
$.set_attribute(g_2, 'transform', `translate(0, ${$1 ?? ''}) rotate(45)`);
|
|
232
228
|
$.set_attribute(text, 'font-family', alloFonts.family);
|
|
233
229
|
$.set_attribute(text, 'font-size', alloFonts.sizes.md);
|
|
@@ -689,7 +685,7 @@ function Diamond($$anchor, $$props) {
|
|
|
689
685
|
$.set_attribute(text, 'dx', $.get(d).x1 - $.get(d).y1 <= 0 ? 5 : -5);
|
|
690
686
|
$.set_attribute(text, 'text-anchor', $.get(d).x1 - $.get(d).y1 <= 0 ? "start" : "end");
|
|
691
687
|
$.set_attribute(text, 'transform', `scale(1,-1) rotate(-90) rotate(-45, ${$2 ?? ''}, ${$3 ?? ''}) translate(${$4 ?? ''}, 0)`);
|
|
692
|
-
$.set_style(text, `font-family: ${alloFonts
|
|
688
|
+
$.set_style(text, `font-family: ${alloFonts.family}; font-size: 12px; fill: ${alloColors.css.darkergrey ?? ''};`);
|
|
693
689
|
$.set_text(text_1, $5);
|
|
694
690
|
},
|
|
695
691
|
[
|
|
@@ -736,8 +732,8 @@ function Diamond($$anchor, $$props) {
|
|
|
736
732
|
$.reset(div_1);
|
|
737
733
|
|
|
738
734
|
$.template_effect(() => $.set_style(div_1, `
|
|
739
|
-
position: fixed;
|
|
740
|
-
left: ${$.get(tooltipX) ?? ''}px;
|
|
735
|
+
position: fixed;
|
|
736
|
+
left: ${$.get(tooltipX) ?? ''}px;
|
|
741
737
|
top: ${$.get(tooltipY) ?? ''}px;
|
|
742
738
|
background: white;
|
|
743
739
|
border: 1px solid rgb(200, 200, 200);
|
|
@@ -887,7 +883,7 @@ function Wordshift($$anchor, $$props) {
|
|
|
887
883
|
$.set_attribute(line_1, 'y2', $.get(innerHeight) - xAxisYOffset + barYOffset);
|
|
888
884
|
$.set_style(line_1, $.get(tick) === 0 ? `stroke: ${alloColors.css.verydarkgrey}; stroke-width: 1; stroke-opacity: 0.8;` : `stroke: currentColor; stroke-opacity: 0.1;`);
|
|
889
885
|
$.set_attribute(text, 'x', $4);
|
|
890
|
-
$.set_style(text, `font-family: ${alloFonts
|
|
886
|
+
$.set_style(text, `font-family: ${alloFonts.family}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''};`);
|
|
891
887
|
$.set_text(text_1, $5);
|
|
892
888
|
},
|
|
893
889
|
[
|
|
@@ -956,7 +952,7 @@ function Wordshift($$anchor, $$props) {
|
|
|
956
952
|
$.template_effect(() => {
|
|
957
953
|
$.set_attribute(text_6, 'x', $.get(xValue) > 0 ? -6 : 6);
|
|
958
954
|
$.set_attribute(text_6, 'text-anchor', $.get(xValue) > 0 ? "end" : "start");
|
|
959
|
-
$.set_style(text_6, `font-family: ${alloFonts
|
|
955
|
+
$.set_style(text_6, `font-family: ${alloFonts.family}; font-size: 14px; fill: ${alloColors.css.darkergrey ?? ''}; opacity: 0.5;`);
|
|
960
956
|
$.set_text(text_7, $.get(labelData).numbers_y);
|
|
961
957
|
});
|
|
962
958
|
|
|
@@ -975,7 +971,7 @@ function Wordshift($$anchor, $$props) {
|
|
|
975
971
|
$.set_attribute(g_3, 'transform', `translate(0, ${$0 ?? ''})`);
|
|
976
972
|
$.set_attribute(text_4, 'x', $.get(xValue) > 0 ? 6 : -6);
|
|
977
973
|
$.set_attribute(text_4, 'text-anchor', $.get(xValue) > 0 ? "start" : "end");
|
|
978
|
-
$.set_style(text_4, `font-family: ${alloFonts
|
|
974
|
+
$.set_style(text_4, `font-family: ${alloFonts.family}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''};`);
|
|
979
975
|
$.set_text(text_5, $.get(labelData).name_y);
|
|
980
976
|
},
|
|
981
977
|
[
|
|
@@ -997,7 +993,7 @@ function Wordshift($$anchor, $$props) {
|
|
|
997
993
|
$.set_attribute(svg, 'viewBox', `0 0 ${width() ?? ''} ${$.get(finalHeight) ?? ''}`);
|
|
998
994
|
$.set_attribute(g, 'transform', `translate(${marginLeft() ?? ''}, ${marginTop() - shiftSvgBy})`);
|
|
999
995
|
$.set_attribute(text_2, 'x', $0);
|
|
1000
|
-
$.set_style(text_2, `font-family: ${alloFonts
|
|
996
|
+
$.set_style(text_2, `font-family: ${alloFonts.family}; font-size: 16px; fill: ${alloColors.css.verydarkgrey ?? ''};`);
|
|
1001
997
|
$.set_text(text_3, xLabel());
|
|
1002
998
|
$.set_attribute(g_2, 'transform', `translate(${$1 ?? ''}, 0)`);
|
|
1003
999
|
},
|
|
@@ -1080,7 +1076,7 @@ function DivergingBarChart($$anchor, $$props) {
|
|
|
1080
1076
|
$.set_attribute(text, 'x', $4);
|
|
1081
1077
|
$.set_attribute(text, 'y', $5);
|
|
1082
1078
|
$.set_attribute(text, 'text-anchor', $.get(X)[$.get(i)] < 0 ? "end" : "start");
|
|
1083
|
-
$.set_style(text, `font-family: ${alloFonts
|
|
1079
|
+
$.set_style(text, `font-family: ${alloFonts.family}; font-size: 12px; fill: ${alloColors.css.darkergrey ?? ''}; opacity: 0.5;`);
|
|
1084
1080
|
$.set_text(text_1, $6);
|
|
1085
1081
|
},
|
|
1086
1082
|
[
|
|
@@ -1109,7 +1105,7 @@ function DivergingBarChart($$anchor, $$props) {
|
|
|
1109
1105
|
($0, $1) => {
|
|
1110
1106
|
$.set_attribute(text_2, 'y', $0);
|
|
1111
1107
|
$.set_attribute(text_2, 'opacity', $1);
|
|
1112
|
-
$.set_style(text_2, `font-family: ${alloFonts
|
|
1108
|
+
$.set_style(text_2, `font-family: ${alloFonts.family}; font-size: 14px; fill: ${alloColors.css.darkergrey ?? ''};`);
|
|
1113
1109
|
$.set_text(text_3, $.get(label));
|
|
1114
1110
|
},
|
|
1115
1111
|
[
|
|
@@ -1197,7 +1193,7 @@ function Legend($$anchor, $$props) {
|
|
|
1197
1193
|
$.template_effect(
|
|
1198
1194
|
($0) => {
|
|
1199
1195
|
$.set_attribute(g_1, 'transform', `translate(${$0 ?? ''}, 0)`);
|
|
1200
|
-
$.set_style(text, `font-family: ${alloFonts
|
|
1196
|
+
$.set_style(text, `font-family: ${alloFonts.family}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''}; text-anchor: start;`);
|
|
1201
1197
|
$.set_text(text_1, $.get(tick));
|
|
1202
1198
|
},
|
|
1203
1199
|
[() => $.get(x2)($.get(tick))]
|
|
@@ -1217,7 +1213,7 @@ function Legend($$anchor, $$props) {
|
|
|
1217
1213
|
$.set_attribute(svg, 'viewBox', `0 0 ${width() ?? ''} ${height() ?? ''}`);
|
|
1218
1214
|
$.set_attribute(text_2, 'x', marginLeft() - 25);
|
|
1219
1215
|
$.set_attribute(text_2, 'y', marginTop() + marginBottom());
|
|
1220
|
-
$.set_style(text_2, `font-family: ${alloFonts
|
|
1216
|
+
$.set_style(text_2, `font-family: ${alloFonts.family}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''}; text-anchor: start;`);
|
|
1221
1217
|
});
|
|
1222
1218
|
|
|
1223
1219
|
$.append($$anchor, svg);
|
|
@@ -1387,12 +1383,12 @@ function Dashboard($$anchor, $$props) {
|
|
|
1387
1383
|
$.reset(div);
|
|
1388
1384
|
|
|
1389
1385
|
$.template_effect(() => {
|
|
1390
|
-
$.set_style(div_5, `font-family: ${alloFonts
|
|
1386
|
+
$.set_style(div_5, `font-family: ${alloFonts.family}; font-size: 16px; color: ${alloColors.css.superdarkgrey ?? ''};`);
|
|
1391
1387
|
$.set_text(text, title()[0]);
|
|
1392
|
-
$.set_style(div_6, `position: absolute; top: 100%; left: -8em; margin-top: 3em; font-family: ${alloFonts
|
|
1388
|
+
$.set_style(div_6, `position: absolute; top: 100%; left: -8em; margin-top: 3em; font-family: ${alloFonts.family}; font-size: 14px; color: ${alloColors.css.darkgrey ?? ''}; width: 150px; line-height: 1;`);
|
|
1393
1389
|
$.set_text(text_1, instrumentText());
|
|
1394
1390
|
$.set_text(text_2, `α = ${alpha() ?? ''}`);
|
|
1395
|
-
$.set_style(div_9, `font-family: ${alloFonts
|
|
1391
|
+
$.set_style(div_9, `font-family: ${alloFonts.family}; font-size: 16px; color: ${alloColors.css.superdarkgrey ?? ''};`);
|
|
1396
1392
|
$.set_text(text_3, title()[1]);
|
|
1397
1393
|
});
|
|
1398
1394
|
|
|
@@ -1509,7 +1505,7 @@ function buildMixedElems(elem1, elem2) {
|
|
|
1509
1505
|
mixedelem[1]['types'] = union; // store union in mixedelem array for elem2
|
|
1510
1506
|
return mixedelem // return mixedelem array
|
|
1511
1507
|
}
|
|
1512
|
-
|
|
1508
|
+
|
|
1513
1509
|
// Combine elements and return a combined array containing counts, ranks, probs, and totalunique
|
|
1514
1510
|
function combElems(elem1, elem2) {
|
|
1515
1511
|
const mixedelem = buildMixedElems(elem1, elem2); // build mixed elements array
|
|
@@ -1520,7 +1516,7 @@ function combElems(elem1, elem2) {
|
|
|
1520
1516
|
const counts = new Array(mixedelem[j]['types'].length); // initialize counts array
|
|
1521
1517
|
const probs = new Array(mixedelem[j]['types'].length); // initialize probs array
|
|
1522
1518
|
|
|
1523
|
-
|
|
1519
|
+
|
|
1524
1520
|
// for each index in mixed elem[j], which is the union of both systems
|
|
1525
1521
|
for (let i=0; i < mixedelem[j]['types'].length; i++) { // find the index of type mixedelem[j]['types'][i] in system 1 or 2
|
|
1526
1522
|
// find the index of type mixedelem[j]['types'][i] in system 1 or 2
|
|
@@ -1529,9 +1525,9 @@ function combElems(elem1, elem2) {
|
|
|
1529
1525
|
counts[i] = idx_type_enumlist_in_elem === -1 ? 0 : enum_list[j][idx_type_enumlist_in_elem]["counts"];
|
|
1530
1526
|
probs[i] = idx_type_enumlist_in_elem === -1 ? 0 : enum_list[j][idx_type_enumlist_in_elem]["probs"];
|
|
1531
1527
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
// store counts, ranks, probs, and totalunique in mixedelem array for elem1 or elem2
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
// store counts, ranks, probs, and totalunique in mixedelem array for elem1 or elem2
|
|
1535
1531
|
mixedelem[j]['counts'] = counts;
|
|
1536
1532
|
mixedelem[j]['ranks'] = tiedrank(mixedelem[j]['counts']);
|
|
1537
1533
|
mixedelem[j]['probs'] = probs;
|
|
@@ -1546,32 +1542,32 @@ function combElems(elem1, elem2) {
|
|
|
1546
1542
|
function balanceDat(elem1, elem2) {
|
|
1547
1543
|
const types_1 = elem1.map(d => d.types);
|
|
1548
1544
|
const types_2 = elem2.map(d => d.types);
|
|
1549
|
-
|
|
1545
|
+
|
|
1550
1546
|
const union_types = getUnions(types_1, types_2);
|
|
1551
1547
|
const tot_types = types_1.length+types_2.length;
|
|
1552
|
-
|
|
1553
|
-
return [
|
|
1548
|
+
|
|
1549
|
+
return [
|
|
1554
1550
|
{ y_coord: "total count", frequency: +(types_2.length / tot_types).toFixed(3) },
|
|
1555
1551
|
{ y_coord: "total count", frequency: -(types_1.length / tot_types).toFixed(3) },
|
|
1556
|
-
{ y_coord: "all
|
|
1557
|
-
{ y_coord: "all
|
|
1558
|
-
{ y_coord: "exclusive
|
|
1559
|
-
{ y_coord: "exclusive
|
|
1552
|
+
{ y_coord: "all types", frequency: +(types_2.length / union_types.size).toFixed(3) },
|
|
1553
|
+
{ y_coord: "all types", frequency: -(types_1.length / union_types.size).toFixed(3) },
|
|
1554
|
+
{ y_coord: "exclusive types", frequency: +(setdiff(types_2, types_1).size / types_2.length).toFixed(3) },
|
|
1555
|
+
{ y_coord: "exclusive types", frequency: -(setdiff(types_1, types_2).size / types_1.length).toFixed(3) }
|
|
1560
1556
|
]
|
|
1561
1557
|
}
|
|
1562
|
-
|
|
1558
|
+
|
|
1563
1559
|
// helper to wrangle the data for the wordshift plot
|
|
1564
|
-
function wordShift_dat(me, dat) {
|
|
1560
|
+
function wordShift_dat(me, dat) {
|
|
1565
1561
|
const out = [];
|
|
1566
1562
|
for (let i=0; i < me[0]['types'].length; i++) {
|
|
1567
1563
|
const rank_diff = me[0]['ranks'][i]-me[1]['ranks'][i];
|
|
1568
1564
|
out.push({
|
|
1569
1565
|
'type': `${me[0]['types'][i]} (${me[0]['ranks'][i]} ⇋ ${me[1]['ranks'][i]})` ,
|
|
1570
1566
|
'rank_diff': rank_diff,
|
|
1571
|
-
'metric': rank_diff < 0 ? -dat.deltas[i] : dat.deltas[i],
|
|
1567
|
+
'metric': rank_diff < 0 ? -dat.deltas[i] : dat.deltas[i],
|
|
1572
1568
|
});
|
|
1573
1569
|
}
|
|
1574
|
-
|
|
1570
|
+
|
|
1575
1571
|
return out.slice().sort((a, b) => descending(Math.abs(a.metric), Math.abs(b.metric)))
|
|
1576
1572
|
}
|
|
1577
1573
|
|
|
@@ -1679,282 +1675,6 @@ function rank_turbulence_divergence(mixedelements, alpha) {
|
|
|
1679
1675
|
}
|
|
1680
1676
|
}
|
|
1681
1677
|
|
|
1682
|
-
const VOID = -1;
|
|
1683
|
-
const PRIMITIVE = 0;
|
|
1684
|
-
const ARRAY = 1;
|
|
1685
|
-
const OBJECT = 2;
|
|
1686
|
-
const DATE = 3;
|
|
1687
|
-
const REGEXP = 4;
|
|
1688
|
-
const MAP = 5;
|
|
1689
|
-
const SET = 6;
|
|
1690
|
-
const ERROR = 7;
|
|
1691
|
-
const BIGINT = 8;
|
|
1692
|
-
// export const SYMBOL = 9;
|
|
1693
|
-
|
|
1694
|
-
const env = typeof self === 'object' ? self : globalThis;
|
|
1695
|
-
|
|
1696
|
-
const deserializer = ($, _) => {
|
|
1697
|
-
const as = (out, index) => {
|
|
1698
|
-
$.set(index, out);
|
|
1699
|
-
return out;
|
|
1700
|
-
};
|
|
1701
|
-
|
|
1702
|
-
const unpair = index => {
|
|
1703
|
-
if ($.has(index))
|
|
1704
|
-
return $.get(index);
|
|
1705
|
-
|
|
1706
|
-
const [type, value] = _[index];
|
|
1707
|
-
switch (type) {
|
|
1708
|
-
case PRIMITIVE:
|
|
1709
|
-
case VOID:
|
|
1710
|
-
return as(value, index);
|
|
1711
|
-
case ARRAY: {
|
|
1712
|
-
const arr = as([], index);
|
|
1713
|
-
for (const index of value)
|
|
1714
|
-
arr.push(unpair(index));
|
|
1715
|
-
return arr;
|
|
1716
|
-
}
|
|
1717
|
-
case OBJECT: {
|
|
1718
|
-
const object = as({}, index);
|
|
1719
|
-
for (const [key, index] of value)
|
|
1720
|
-
object[unpair(key)] = unpair(index);
|
|
1721
|
-
return object;
|
|
1722
|
-
}
|
|
1723
|
-
case DATE:
|
|
1724
|
-
return as(new Date(value), index);
|
|
1725
|
-
case REGEXP: {
|
|
1726
|
-
const {source, flags} = value;
|
|
1727
|
-
return as(new RegExp(source, flags), index);
|
|
1728
|
-
}
|
|
1729
|
-
case MAP: {
|
|
1730
|
-
const map = as(new Map, index);
|
|
1731
|
-
for (const [key, index] of value)
|
|
1732
|
-
map.set(unpair(key), unpair(index));
|
|
1733
|
-
return map;
|
|
1734
|
-
}
|
|
1735
|
-
case SET: {
|
|
1736
|
-
const set = as(new Set, index);
|
|
1737
|
-
for (const index of value)
|
|
1738
|
-
set.add(unpair(index));
|
|
1739
|
-
return set;
|
|
1740
|
-
}
|
|
1741
|
-
case ERROR: {
|
|
1742
|
-
const {name, message} = value;
|
|
1743
|
-
return as(new env[name](message), index);
|
|
1744
|
-
}
|
|
1745
|
-
case BIGINT:
|
|
1746
|
-
return as(BigInt(value), index);
|
|
1747
|
-
case 'BigInt':
|
|
1748
|
-
return as(Object(BigInt(value)), index);
|
|
1749
|
-
case 'ArrayBuffer':
|
|
1750
|
-
return as(new Uint8Array(value).buffer, value);
|
|
1751
|
-
case 'DataView': {
|
|
1752
|
-
const { buffer } = new Uint8Array(value);
|
|
1753
|
-
return as(new DataView(buffer), value);
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
return as(new env[type](value), index);
|
|
1757
|
-
};
|
|
1758
|
-
|
|
1759
|
-
return unpair;
|
|
1760
|
-
};
|
|
1761
|
-
|
|
1762
|
-
/**
|
|
1763
|
-
* @typedef {Array<string,any>} Record a type representation
|
|
1764
|
-
*/
|
|
1765
|
-
|
|
1766
|
-
/**
|
|
1767
|
-
* Returns a deserialized value from a serialized array of Records.
|
|
1768
|
-
* @param {Record[]} serialized a previously serialized value.
|
|
1769
|
-
* @returns {any}
|
|
1770
|
-
*/
|
|
1771
|
-
const deserialize = serialized => deserializer(new Map, serialized)(0);
|
|
1772
|
-
|
|
1773
|
-
const EMPTY = '';
|
|
1774
|
-
|
|
1775
|
-
const {toString} = {};
|
|
1776
|
-
const {keys} = Object;
|
|
1777
|
-
|
|
1778
|
-
const typeOf = value => {
|
|
1779
|
-
const type = typeof value;
|
|
1780
|
-
if (type !== 'object' || !value)
|
|
1781
|
-
return [PRIMITIVE, type];
|
|
1782
|
-
|
|
1783
|
-
const asString = toString.call(value).slice(8, -1);
|
|
1784
|
-
switch (asString) {
|
|
1785
|
-
case 'Array':
|
|
1786
|
-
return [ARRAY, EMPTY];
|
|
1787
|
-
case 'Object':
|
|
1788
|
-
return [OBJECT, EMPTY];
|
|
1789
|
-
case 'Date':
|
|
1790
|
-
return [DATE, EMPTY];
|
|
1791
|
-
case 'RegExp':
|
|
1792
|
-
return [REGEXP, EMPTY];
|
|
1793
|
-
case 'Map':
|
|
1794
|
-
return [MAP, EMPTY];
|
|
1795
|
-
case 'Set':
|
|
1796
|
-
return [SET, EMPTY];
|
|
1797
|
-
case 'DataView':
|
|
1798
|
-
return [ARRAY, asString];
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
if (asString.includes('Array'))
|
|
1802
|
-
return [ARRAY, asString];
|
|
1803
|
-
|
|
1804
|
-
if (asString.includes('Error'))
|
|
1805
|
-
return [ERROR, asString];
|
|
1806
|
-
|
|
1807
|
-
return [OBJECT, asString];
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
const shouldSkip = ([TYPE, type]) => (
|
|
1811
|
-
TYPE === PRIMITIVE &&
|
|
1812
|
-
(type === 'function' || type === 'symbol')
|
|
1813
|
-
);
|
|
1814
|
-
|
|
1815
|
-
const serializer = (strict, json, $, _) => {
|
|
1816
|
-
|
|
1817
|
-
const as = (out, value) => {
|
|
1818
|
-
const index = _.push(out) - 1;
|
|
1819
|
-
$.set(value, index);
|
|
1820
|
-
return index;
|
|
1821
|
-
};
|
|
1822
|
-
|
|
1823
|
-
const pair = value => {
|
|
1824
|
-
if ($.has(value))
|
|
1825
|
-
return $.get(value);
|
|
1826
|
-
|
|
1827
|
-
let [TYPE, type] = typeOf(value);
|
|
1828
|
-
switch (TYPE) {
|
|
1829
|
-
case PRIMITIVE: {
|
|
1830
|
-
let entry = value;
|
|
1831
|
-
switch (type) {
|
|
1832
|
-
case 'bigint':
|
|
1833
|
-
TYPE = BIGINT;
|
|
1834
|
-
entry = value.toString();
|
|
1835
|
-
break;
|
|
1836
|
-
case 'function':
|
|
1837
|
-
case 'symbol':
|
|
1838
|
-
if (strict)
|
|
1839
|
-
throw new TypeError('unable to serialize ' + type);
|
|
1840
|
-
entry = null;
|
|
1841
|
-
break;
|
|
1842
|
-
case 'undefined':
|
|
1843
|
-
return as([VOID], value);
|
|
1844
|
-
}
|
|
1845
|
-
return as([TYPE, entry], value);
|
|
1846
|
-
}
|
|
1847
|
-
case ARRAY: {
|
|
1848
|
-
if (type) {
|
|
1849
|
-
let spread = value;
|
|
1850
|
-
if (type === 'DataView') {
|
|
1851
|
-
spread = new Uint8Array(value.buffer);
|
|
1852
|
-
}
|
|
1853
|
-
else if (type === 'ArrayBuffer') {
|
|
1854
|
-
spread = new Uint8Array(value);
|
|
1855
|
-
}
|
|
1856
|
-
return as([type, [...spread]], value);
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
const arr = [];
|
|
1860
|
-
const index = as([TYPE, arr], value);
|
|
1861
|
-
for (const entry of value)
|
|
1862
|
-
arr.push(pair(entry));
|
|
1863
|
-
return index;
|
|
1864
|
-
}
|
|
1865
|
-
case OBJECT: {
|
|
1866
|
-
if (type) {
|
|
1867
|
-
switch (type) {
|
|
1868
|
-
case 'BigInt':
|
|
1869
|
-
return as([type, value.toString()], value);
|
|
1870
|
-
case 'Boolean':
|
|
1871
|
-
case 'Number':
|
|
1872
|
-
case 'String':
|
|
1873
|
-
return as([type, value.valueOf()], value);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
if (json && ('toJSON' in value))
|
|
1878
|
-
return pair(value.toJSON());
|
|
1879
|
-
|
|
1880
|
-
const entries = [];
|
|
1881
|
-
const index = as([TYPE, entries], value);
|
|
1882
|
-
for (const key of keys(value)) {
|
|
1883
|
-
if (strict || !shouldSkip(typeOf(value[key])))
|
|
1884
|
-
entries.push([pair(key), pair(value[key])]);
|
|
1885
|
-
}
|
|
1886
|
-
return index;
|
|
1887
|
-
}
|
|
1888
|
-
case DATE:
|
|
1889
|
-
return as([TYPE, value.toISOString()], value);
|
|
1890
|
-
case REGEXP: {
|
|
1891
|
-
const {source, flags} = value;
|
|
1892
|
-
return as([TYPE, {source, flags}], value);
|
|
1893
|
-
}
|
|
1894
|
-
case MAP: {
|
|
1895
|
-
const entries = [];
|
|
1896
|
-
const index = as([TYPE, entries], value);
|
|
1897
|
-
for (const [key, entry] of value) {
|
|
1898
|
-
if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
|
|
1899
|
-
entries.push([pair(key), pair(entry)]);
|
|
1900
|
-
}
|
|
1901
|
-
return index;
|
|
1902
|
-
}
|
|
1903
|
-
case SET: {
|
|
1904
|
-
const entries = [];
|
|
1905
|
-
const index = as([TYPE, entries], value);
|
|
1906
|
-
for (const entry of value) {
|
|
1907
|
-
if (strict || !shouldSkip(typeOf(entry)))
|
|
1908
|
-
entries.push(pair(entry));
|
|
1909
|
-
}
|
|
1910
|
-
return index;
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
const {message} = value;
|
|
1915
|
-
return as([TYPE, {name: type, message}], value);
|
|
1916
|
-
};
|
|
1917
|
-
|
|
1918
|
-
return pair;
|
|
1919
|
-
};
|
|
1920
|
-
|
|
1921
|
-
/**
|
|
1922
|
-
* @typedef {Array<string,any>} Record a type representation
|
|
1923
|
-
*/
|
|
1924
|
-
|
|
1925
|
-
/**
|
|
1926
|
-
* Returns an array of serialized Records.
|
|
1927
|
-
* @param {any} value a serializable value.
|
|
1928
|
-
* @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that,
|
|
1929
|
-
* if `true`, will not throw errors on incompatible types, and behave more
|
|
1930
|
-
* like JSON stringify would behave. Symbol and Function will be discarded.
|
|
1931
|
-
* @returns {Record[]}
|
|
1932
|
-
*/
|
|
1933
|
-
const serialize = (value, {json, lossy} = {}) => {
|
|
1934
|
-
const _ = [];
|
|
1935
|
-
return serializer(!(json || lossy), !!json, new Map, _)(value), _;
|
|
1936
|
-
};
|
|
1937
|
-
|
|
1938
|
-
/**
|
|
1939
|
-
* @typedef {Array<string,any>} Record a type representation
|
|
1940
|
-
*/
|
|
1941
|
-
|
|
1942
|
-
/**
|
|
1943
|
-
* Returns an array of serialized Records.
|
|
1944
|
-
* @param {any} any a serializable value.
|
|
1945
|
-
* @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with
|
|
1946
|
-
* a transfer option (ignored when polyfilled) and/or non standard fields that
|
|
1947
|
-
* fallback to the polyfill if present.
|
|
1948
|
-
* @returns {Record[]}
|
|
1949
|
-
*/
|
|
1950
|
-
const structuredClone$1 = typeof structuredClone === "function" ?
|
|
1951
|
-
/* c8 ignore start */
|
|
1952
|
-
(any, options) => (
|
|
1953
|
-
options && ('json' in options || 'lossy' in options) ?
|
|
1954
|
-
deserialize(serialize(any, options)) : structuredClone(any)
|
|
1955
|
-
) :
|
|
1956
|
-
(any, options) => deserialize(serialize(any, options));
|
|
1957
|
-
|
|
1958
1678
|
function rank2coord(rank) { return Math.floor(Math.log10(rank) / (1/15)) }
|
|
1959
1679
|
|
|
1960
1680
|
// Augment information already in `me` class with coordinates.
|
|
@@ -2048,11 +1768,11 @@ function diamond_count(mixedelements, wordshift) {
|
|
|
2048
1768
|
mixedelements[1]['ranks'] = indices_deltas.map(i => mixedelements[1]['ranks'][i]);
|
|
2049
1769
|
mixedelements[1]['probs'] = indices_deltas.map(i => mixedelements[1]['probs'][i]);
|
|
2050
1770
|
|
|
2051
|
-
const deltas_loss =
|
|
2052
|
-
|
|
1771
|
+
const deltas_loss = [...deltas];
|
|
1772
|
+
[...deltas];
|
|
2053
1773
|
|
|
2054
1774
|
which(mixedelements[0]['ranks'].map((d,i) => mixedelements[0]['ranks'][i] > mixedelements[1]['ranks'][i])).map(e => deltas_loss[e] = -1);
|
|
2055
|
-
which(mixedelements[0]['ranks'].map((d,i) => mixedelements[1]['ranks'][i] < mixedelements[1]['ranks'][i])).map(e =>
|
|
1775
|
+
which(mixedelements[0]['ranks'].map((d,i) => mixedelements[1]['ranks'][i] < mixedelements[1]['ranks'][i])).map(e => -1);
|
|
2056
1776
|
|
|
2057
1777
|
|
|
2058
1778
|
const counts = diamond_counts(mixedelements);
|
package/dist/ssr/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as $ from "svelte/internal/server";
|
|
|
2
2
|
import * as d3 from "d3";
|
|
3
3
|
import { map, extent, InternSet, range, rollup, scaleLinear, scaleBand, rgb, interpolateInferno, scaleOrdinal } from "d3";
|
|
4
4
|
import { descending, sum, group, extent as extent$1 } from "d3-array";
|
|
5
|
-
import structuredClone from "@ungap/structured-clone";
|
|
6
5
|
function rgbArrayToCss(rgbArray) {
|
|
7
6
|
const [r, g, b] = rgbArray.map((v) => Math.round(v * 255));
|
|
8
7
|
return `rgb(${r}, ${g}, ${b})`;
|
|
@@ -39,11 +38,8 @@ const alloColors = {
|
|
|
39
38
|
const alloFonts = {
|
|
40
39
|
family: `"EB Garamond", "Garamond", "Century Schoolbook L", "URW Bookman L", "Bookman Old Style", "Times", serif`,
|
|
41
40
|
sizes: {
|
|
42
|
-
xs: "10px",
|
|
43
|
-
sm: "12px",
|
|
44
41
|
md: "14px",
|
|
45
|
-
lg: "16px"
|
|
46
|
-
xl: "18px"
|
|
42
|
+
lg: "16px"
|
|
47
43
|
}
|
|
48
44
|
};
|
|
49
45
|
function AxisX($$payload, $$props) {
|
|
@@ -59,15 +55,15 @@ function AxisX($$payload, $$props) {
|
|
|
59
55
|
});
|
|
60
56
|
let helperText = () => style({
|
|
61
57
|
fontFamily: alloFonts.family,
|
|
62
|
-
fontSize: alloFonts.sizes.
|
|
63
|
-
fill: alloColors.css.
|
|
58
|
+
fontSize: alloFonts.sizes.md,
|
|
59
|
+
fill: alloColors.css.darkgrey,
|
|
64
60
|
textAnchor: "middle"
|
|
65
61
|
});
|
|
66
62
|
const each_array = $.ensure_array_like(xTicks);
|
|
67
63
|
$$payload.out += `<g class="axis x"${$.attr("transform", `translate(0, ${$.stringify(innerHeight)})`)}><!--[-->`;
|
|
68
64
|
for (let index = 0, $$length = each_array.length; index < $$length; index++) {
|
|
69
65
|
let tick = each_array[index];
|
|
70
|
-
$$payload.out += `<g${$.attr("transform", `translate(${$.stringify(scale(tick))}, 0)`)}><line x1="0" x2="0" y1="0" y2="6"${$.attr("stroke", alloColors.css.
|
|
66
|
+
$$payload.out += `<g${$.attr("transform", `translate(${$.stringify(scale(tick))}, 0)`)}><line x1="0" x2="0" y1="0" y2="6"${$.attr("stroke", alloColors.css.darkergrey)} stroke-width="0.5"></line></g><g${$.attr("transform", `translate(${$.stringify(scale(tick))}, 0) scale(-1,1) rotate(45)`)}><text dx="5" dy="13" text-anchor="start"${$.attr("font-family", alloFonts.family)}${$.attr("font-size", alloFonts.sizes.md)}${$.attr("fill", alloColors.css.darkergrey)}>${$.escape(logFormat10(tick))}</text></g>`;
|
|
71
67
|
}
|
|
72
68
|
$$payload.out += `<!--]--><g class="xlab"><text${$.attr("x", innerHeight / 2)} dy="45"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(axisStyles())}>Rank r</text><text${$.attr("x", innerHeight / 2)} dy="63"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(axisStyles())}>for</text><text${$.attr("x", innerHeight / 2)} dy="80"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(axisStyles())}>${$.escape(title[1])}</text><text${$.attr("x", innerHeight - 40)} dy="60"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(helperText())}>more →</text><text${$.attr("x", innerHeight - 40)} dy="75"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(helperText())}>frequent</text><text${$.attr("x", 40)} dy="60"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(helperText())}>← less</text><text${$.attr("x", 40)} dy="75"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(innerHeight)}, 0)`)}${$.attr_style(helperText())}>frequent</text></g></g>`;
|
|
73
69
|
$.pop();
|
|
@@ -85,15 +81,15 @@ function AxisY($$payload, $$props) {
|
|
|
85
81
|
});
|
|
86
82
|
let helperText = () => style({
|
|
87
83
|
fontFamily: alloFonts.family,
|
|
88
|
-
fontSize: alloFonts.sizes.
|
|
89
|
-
fill: alloColors.css.
|
|
84
|
+
fontSize: alloFonts.sizes.md,
|
|
85
|
+
fill: alloColors.css.darkgrey,
|
|
90
86
|
textAnchor: "middle"
|
|
91
87
|
});
|
|
92
88
|
const each_array = $.ensure_array_like(yTicks);
|
|
93
89
|
$$payload.out += `<g class="axis y"${$.attr("transform", `translate(${$.stringify(innerHeight)}, 0) scale(-1, 1)`)}><!--[-->`;
|
|
94
90
|
for (let index = 0, $$length = each_array.length; index < $$length; index++) {
|
|
95
91
|
let tick = each_array[index];
|
|
96
|
-
$$payload.out += `<g${$.attr("transform", `translate(0, ${$.stringify(scale(tick))})`)}><line x1="0" x2="-6" y1="0" y2="0"${$.attr("stroke", alloColors.css.
|
|
92
|
+
$$payload.out += `<g${$.attr("transform", `translate(0, ${$.stringify(scale(tick))})`)}><line x1="0" x2="-6" y1="0" y2="0"${$.attr("stroke", alloColors.css.darkergrey)} stroke-width="0.5"></line></g><g${$.attr("transform", `translate(0, ${$.stringify(scale(tick))}) rotate(45)`)}><text dx="-5" dy="13" text-anchor="end"${$.attr("font-family", alloFonts.family)}${$.attr("font-size", alloFonts.sizes.md)}${$.attr("fill", alloColors.css.darkergrey)}>${$.escape(logFormat10(tick))}</text></g>`;
|
|
97
93
|
}
|
|
98
94
|
$$payload.out += `<!--]--><g class="ylab" transform="rotate(90)"><text${$.attr("x", innerHeight / 2)} dy="45"${$.attr_style(axisStyles())}>Rank r</text><text${$.attr("x", innerHeight / 2)} dy="63"${$.attr_style(axisStyles())}>for</text><text${$.attr("x", innerHeight / 2)} dy="80"${$.attr_style(axisStyles())}>${$.escape(title[0])}</text><text${$.attr("x", innerHeight - 40)} dy="60"${$.attr_style(helperText())}>less →</text><text${$.attr("x", innerHeight - 40)} dy="75"${$.attr_style(helperText())}>frequent</text><text${$.attr("x", 40)} dy="60"${$.attr_style(helperText())}>← more</text><text${$.attr("x", 40)} dy="75"${$.attr_style(helperText())}>frequent</text></g></g>`;
|
|
99
95
|
$.pop();
|
|
@@ -286,7 +282,7 @@ function Diamond($$payload, $$props) {
|
|
|
286
282
|
$$payload.out += `<!--]--><!--[-->`;
|
|
287
283
|
for (let $$index_2 = 0, $$length = each_array_2.length; $$index_2 < $$length; $$index_2++) {
|
|
288
284
|
let d = each_array_2[$$index_2];
|
|
289
|
-
$$payload.out += `<text${$.attr("x", xy(d.x1))}${$.attr("y", Number.isInteger(d.coord_on_diag) ? xy(d.y1) : xy(d.y1) - 1)}${$.attr("dx", d.x1 - d.y1 <= 0 ? 5 : -5)} dy="5"${$.attr("text-anchor", d.x1 - d.y1 <= 0 ? "start" : "end")}${$.attr("transform", `scale(1,-1) rotate(-90) rotate(-45, ${$.stringify(xy(d.x1))}, ${$.stringify(xy(d.y1))}) translate(${$.stringify(d.which_sys === "right" ? xy(Math.sqrt(d.cos_dist)) * 1.5 : -xy(Math.sqrt(d.cos_dist)) * 1.5)}, 0)`)}${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 12px; fill: ${$.stringify(alloColors.css.darkergrey)};`)}>${$.escape(d.types.split(",")[0])}</text>`;
|
|
285
|
+
$$payload.out += `<text${$.attr("x", xy(d.x1))}${$.attr("y", Number.isInteger(d.coord_on_diag) ? xy(d.y1) : xy(d.y1) - 1)}${$.attr("dx", d.x1 - d.y1 <= 0 ? 5 : -5)} dy="5"${$.attr("text-anchor", d.x1 - d.y1 <= 0 ? "start" : "end")}${$.attr("transform", `scale(1,-1) rotate(-90) rotate(-45, ${$.stringify(xy(d.x1))}, ${$.stringify(xy(d.y1))}) translate(${$.stringify(d.which_sys === "right" ? xy(Math.sqrt(d.cos_dist)) * 1.5 : -xy(Math.sqrt(d.cos_dist)) * 1.5)}, 0)`)}${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 12px; fill: ${$.stringify(alloColors.css.darkergrey)};`)}>${$.escape(d.types.split(",")[0])}</text>`;
|
|
290
286
|
}
|
|
291
287
|
$$payload.out += `<!--]--><line x1="0" y1="0"${$.attr("x2", innerHeight - 7)}${$.attr("y2", innerHeight - 7)}${$.attr_style(`stroke: ${$.stringify(alloColors.css.verydarkgrey)}; stroke-width: 0.5;`)}></line>`;
|
|
292
288
|
Contours($$payload, {
|
|
@@ -369,9 +365,9 @@ function Wordshift($$payload, $$props) {
|
|
|
369
365
|
$$payload.out += `<svg${$.attr("width", width)}${$.attr("height", finalHeight)}${$.attr("viewBox", `0 0 ${$.stringify(width)} ${$.stringify(finalHeight)}`)} style="overflow: visible; display: block;"><g class="wordshift-container"${$.attr("transform", `translate(${$.stringify(marginLeft)}, ${$.stringify(marginTop - shiftSvgBy)})`)}><g class="wordshift-axis x"${$.attr("transform", `translate(0, ${$.stringify(xAxisYOffset)})`)}><!--[-->`;
|
|
370
366
|
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
|
371
367
|
let tick = each_array[$$index];
|
|
372
|
-
$$payload.out += `<line${$.attr("x1", xScale(tick))} y1="0"${$.attr("x2", xScale(tick))} y2="6" style="stroke: currentColor; stroke-width: 1;"></line><line class="wordshift-grid-line"${$.attr("x1", xScale(tick))} y1="0"${$.attr("x2", xScale(tick))}${$.attr("y2", innerHeight - xAxisYOffset + barYOffset)}${$.attr_style(tick === 0 ? `stroke: ${alloColors.css.verydarkgrey}; stroke-width: 1; stroke-opacity: 0.8;` : `stroke: currentColor; stroke-opacity: 0.1;`)}></line><text${$.attr("x", xScale(tick))} y="-12" text-anchor="middle"${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)};`)}>${$.escape(format(tick))}</text>`;
|
|
368
|
+
$$payload.out += `<line${$.attr("x1", xScale(tick))} y1="0"${$.attr("x2", xScale(tick))} y2="6" style="stroke: currentColor; stroke-width: 1;"></line><line class="wordshift-grid-line"${$.attr("x1", xScale(tick))} y1="0"${$.attr("x2", xScale(tick))}${$.attr("y2", innerHeight - xAxisYOffset + barYOffset)}${$.attr_style(tick === 0 ? `stroke: ${alloColors.css.verydarkgrey}; stroke-width: 1; stroke-opacity: 0.8;` : `stroke: currentColor; stroke-opacity: 0.1;`)}></line><text${$.attr("x", xScale(tick))} y="-12" text-anchor="middle"${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)};`)}>${$.escape(format(tick))}</text>`;
|
|
373
369
|
}
|
|
374
|
-
$$payload.out += `<!--]--><text${$.attr("x", xScale(0))} y="-35" text-anchor="middle"${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 16px; fill: ${$.stringify(alloColors.css.verydarkgrey)};`)}>${$.escape(xLabel)}</text></g><!--[-->`;
|
|
370
|
+
$$payload.out += `<!--]--><text${$.attr("x", xScale(0))} y="-35" text-anchor="middle"${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 16px; fill: ${$.stringify(alloColors.css.verydarkgrey)};`)}>${$.escape(xLabel)}</text></g><!--[-->`;
|
|
375
371
|
for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
|
|
376
372
|
let i = each_array_1[$$index_1];
|
|
377
373
|
$$payload.out += `<rect class="wordshift-bar"${$.attr("x", Math.min(xScale(0), xScale(X[i])))}${$.attr("y", yScale(Y[i]) + (yScale.bandwidth() - yScale.bandwidth() * barHeightFactor) / 2)}${$.attr("fill", colors[X[i] > 0 ? colors.length - 1 : 0])}${$.attr("width", Math.abs(xScale(X[i]) - xScale(0)))}${$.attr("height", yScale.bandwidth() * barHeightFactor)} style="mix-blend-mode: multiply;"></rect>`;
|
|
@@ -381,10 +377,10 @@ function Wordshift($$payload, $$props) {
|
|
|
381
377
|
let label = each_array_2[$$index_2];
|
|
382
378
|
const labelData = parseLabelData(label);
|
|
383
379
|
const xValue = YX.get(label);
|
|
384
|
-
$$payload.out += `<g class="wordshift-label-group"${$.attr("transform", `translate(0, ${$.stringify(yScale(label) + yScale.bandwidth() / 2)})`)}><text${$.attr("x", xValue > 0 ? 6 : -6)} dy="0.32em"${$.attr("text-anchor", xValue > 0 ? "start" : "end")}${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)};`)}>${$.escape(labelData.name_y)}</text>`;
|
|
380
|
+
$$payload.out += `<g class="wordshift-label-group"${$.attr("transform", `translate(0, ${$.stringify(yScale(label) + yScale.bandwidth() / 2)})`)}><text${$.attr("x", xValue > 0 ? 6 : -6)} dy="0.32em"${$.attr("text-anchor", xValue > 0 ? "start" : "end")}${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)};`)}>${$.escape(labelData.name_y)}</text>`;
|
|
385
381
|
if (labelData.numbers_y) {
|
|
386
382
|
$$payload.out += "<!--[-->";
|
|
387
|
-
$$payload.out += `<text${$.attr("x", xValue > 0 ? -6 : 6)} dy="0.32em"${$.attr("text-anchor", xValue > 0 ? "end" : "start")}${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 14px; fill: ${$.stringify(alloColors.css.darkergrey)}; opacity: 0.5;`)}>${$.escape(labelData.numbers_y)}</text>`;
|
|
383
|
+
$$payload.out += `<text${$.attr("x", xValue > 0 ? -6 : 6)} dy="0.32em"${$.attr("text-anchor", xValue > 0 ? "end" : "start")}${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; fill: ${$.stringify(alloColors.css.darkergrey)}; opacity: 0.5;`)}>${$.escape(labelData.numbers_y)}</text>`;
|
|
388
384
|
} else {
|
|
389
385
|
$$payload.out += "<!--[!-->";
|
|
390
386
|
}
|
|
@@ -428,12 +424,12 @@ function DivergingBarChart($$payload, $$props) {
|
|
|
428
424
|
$$payload.out += `<svg${$.attr("width", width)}${$.attr("height", height)}${$.attr("viewBox", `0 0 ${$.stringify(width)} ${$.stringify(height)}`)} style="overflow: visible; display: block;"><g class="balance-chart"><!--[-->`;
|
|
429
425
|
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
|
430
426
|
let i = each_array[$$index];
|
|
431
|
-
$$payload.out += `<rect${$.attr("x", Math.min(xScale(0), xScale(X[i])))}${$.attr("y", yScale(Y[i]))}${$.attr("fill", colors[X[i] > 0 ? colors.length - 1 : 0])}${$.attr("width", Math.abs(xScale(X[i]) - xScale(0)))}${$.attr("height", yScale.bandwidth())}></rect><text${$.attr("x", xScale(X[i]) + Math.sign(X[i] - 0) * 4)}${$.attr("y", yScale(Y[i]) + yScale.bandwidth() / 2)} dy="0.35em"${$.attr("text-anchor", X[i] < 0 ? "end" : "start")}${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size:
|
|
427
|
+
$$payload.out += `<rect${$.attr("x", Math.min(xScale(0), xScale(X[i])))}${$.attr("y", yScale(Y[i]))}${$.attr("fill", colors[X[i] > 0 ? colors.length - 1 : 0])}${$.attr("width", Math.abs(xScale(X[i]) - xScale(0)))}${$.attr("height", yScale.bandwidth())}></rect><text${$.attr("x", xScale(X[i]) + Math.sign(X[i] - 0) * 4)}${$.attr("y", yScale(Y[i]) + yScale.bandwidth() / 2)} dy="0.35em"${$.attr("text-anchor", X[i] < 0 ? "end" : "start")}${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 12px; fill: ${$.stringify(alloColors.css.darkergrey)}; opacity: 0.5;`)}>${$.escape(format(Math.abs(X[i])))}</text>`;
|
|
432
428
|
}
|
|
433
429
|
$$payload.out += `<!--]--><g class="y-axis"${$.attr("transform", `translate(${$.stringify(xScale(0))}, -12)`)}><!--[-->`;
|
|
434
430
|
for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
|
|
435
431
|
let label = each_array_1[$$index_1];
|
|
436
|
-
$$payload.out += `<text x="0"${$.attr("y", yScale(label) + yScale.bandwidth() / 2)} dy="0.35em" text-anchor="middle"${$.attr("opacity", YX.get(label) ? "0.5" : "1")}${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 14px; fill: ${$.stringify(alloColors.css.darkergrey)};`)}>${$.escape(label)}</text>`;
|
|
432
|
+
$$payload.out += `<text x="0"${$.attr("y", yScale(label) + yScale.bandwidth() / 2)} dy="0.35em" text-anchor="middle"${$.attr("opacity", YX.get(label) ? "0.5" : "1")}${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; fill: ${$.stringify(alloColors.css.darkergrey)};`)}>${$.escape(label)}</text>`;
|
|
437
433
|
}
|
|
438
434
|
$$payload.out += `<!--]--></g></g></svg>`;
|
|
439
435
|
$.pop();
|
|
@@ -465,9 +461,9 @@ function Legend($$payload, $$props) {
|
|
|
465
461
|
$$payload.out += `<!--]--><g transform="rotate(-90) translate(-60,5)"><!--[-->`;
|
|
466
462
|
for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
|
|
467
463
|
let tick = each_array_1[$$index_1];
|
|
468
|
-
$$payload.out += `<g class="tick"${$.attr("transform", `translate(${$.stringify(x2(tick))}, 0)`)}><text dx="30" dy="-30" transform="rotate(90)"${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)}; text-anchor: start;`)}>${$.escape(tick)}</text></g>`;
|
|
464
|
+
$$payload.out += `<g class="tick"${$.attr("transform", `translate(${$.stringify(x2(tick))}, 0)`)}><text dx="30" dy="-30" transform="rotate(90)"${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)}; text-anchor: start;`)}>${$.escape(tick)}</text></g>`;
|
|
469
465
|
}
|
|
470
|
-
$$payload.out += `<!--]--><text class="title"${$.attr("x", marginLeft - 25)}${$.attr("y", marginTop + marginBottom)} dx="30" dy="-5" transform="rotate(90)"${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)}; text-anchor: start;`)}>Counts per cell</text></g></svg>`;
|
|
466
|
+
$$payload.out += `<!--]--><text class="title"${$.attr("x", marginLeft - 25)}${$.attr("y", marginTop + marginBottom)} dx="30" dy="-5" transform="rotate(90)"${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; fill: ${$.stringify(alloColors.css.verydarkgrey)}; text-anchor: start;`)}>Counts per cell</text></g></svg>`;
|
|
471
467
|
$.pop();
|
|
472
468
|
}
|
|
473
469
|
function Dashboard($$payload, $$props) {
|
|
@@ -500,7 +496,7 @@ function Dashboard($$payload, $$props) {
|
|
|
500
496
|
} = $$props;
|
|
501
497
|
let max_shift = barData.length > 0 ? Math.max(...barData.map((d) => Math.abs(d.metric))) : 1;
|
|
502
498
|
let wordshiftXDomain = xDomain || [-max_shift * 1.5, max_shift * 1.5];
|
|
503
|
-
$$payload.out += `<div id="allotaxonometer-dashboard" style="position: relative; margin: 0; padding: 0;"><div style="display:flex; flex-wrap: wrap; align-items:center; justify-content: center; row-gap: 50px;"><div id="diamond-group" style="margin-top:20px; margin-right: -50px;"><div style="display:flex; gap: 10em; justify-content: center; margin-bottom: -70px; margin-right: 70px; position: relative;"><div style="position: relative;"><div${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 16px; color: ${$.stringify(alloColors.css.superdarkgrey)};`)}>${$.escape(title[0])}</div> <div${$.attr_style(`position: absolute; top: 100%; left: -8em; margin-top: 3em; font-family: ${$.stringify(alloFonts)}; font-size: 14px; color: ${$.stringify(alloColors.css.darkgrey)}; width: 150px; line-height: 1;`)}><div style="margin-bottom: 0.5em;">${$.escape(instrumentText)}</div> <div>α = ${$.escape(alpha)}</div></div></div> <div${$.attr_style(`font-family: ${$.stringify(alloFonts)}; font-size: 16px; color: ${$.stringify(alloColors.css.superdarkgrey)};`)}>${$.escape(title[1])}</div></div> <div id="diamondplot">`;
|
|
499
|
+
$$payload.out += `<div id="allotaxonometer-dashboard" style="position: relative; margin: 0; padding: 0;"><div style="display:flex; flex-wrap: wrap; align-items:center; justify-content: center; row-gap: 50px;"><div id="diamond-group" style="margin-top:20px; margin-right: -50px;"><div style="display:flex; gap: 10em; justify-content: center; margin-bottom: -70px; margin-right: 70px; position: relative;"><div style="position: relative;"><div${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 16px; color: ${$.stringify(alloColors.css.superdarkgrey)};`)}>${$.escape(title[0])}</div> <div${$.attr_style(`position: absolute; top: 100%; left: -8em; margin-top: 3em; font-family: ${$.stringify(alloFonts.family)}; font-size: 14px; color: ${$.stringify(alloColors.css.darkgrey)}; width: 150px; line-height: 1;`)}><div style="margin-bottom: 0.5em;">${$.escape(instrumentText)}</div> <div>α = ${$.escape(alpha)}</div></div></div> <div${$.attr_style(`font-family: ${$.stringify(alloFonts.family)}; font-size: 16px; color: ${$.stringify(alloColors.css.superdarkgrey)};`)}>${$.escape(title[1])}</div></div> <div id="diamondplot">`;
|
|
504
500
|
Diamond($$payload, {
|
|
505
501
|
dat,
|
|
506
502
|
alpha,
|
|
@@ -629,10 +625,10 @@ function balanceDat(elem1, elem2) {
|
|
|
629
625
|
return [
|
|
630
626
|
{ y_coord: "total count", frequency: +(types_2.length / tot_types).toFixed(3) },
|
|
631
627
|
{ y_coord: "total count", frequency: -(types_1.length / tot_types).toFixed(3) },
|
|
632
|
-
{ y_coord: "all
|
|
633
|
-
{ y_coord: "all
|
|
634
|
-
{ y_coord: "exclusive
|
|
635
|
-
{ y_coord: "exclusive
|
|
628
|
+
{ y_coord: "all types", frequency: +(types_2.length / union_types.size).toFixed(3) },
|
|
629
|
+
{ y_coord: "all types", frequency: -(types_1.length / union_types.size).toFixed(3) },
|
|
630
|
+
{ y_coord: "exclusive types", frequency: +(setdiff(types_2, types_1).size / types_2.length).toFixed(3) },
|
|
631
|
+
{ y_coord: "exclusive types", frequency: -(setdiff(types_1, types_2).size / types_1.length).toFixed(3) }
|
|
636
632
|
];
|
|
637
633
|
}
|
|
638
634
|
function wordShift_dat(me, dat) {
|
|
@@ -773,10 +769,10 @@ function diamond_count(mixedelements, wordshift) {
|
|
|
773
769
|
mixedelements[1]["counts"] = indices_deltas.map((i) => mixedelements[1]["counts"][i]);
|
|
774
770
|
mixedelements[1]["ranks"] = indices_deltas.map((i) => mixedelements[1]["ranks"][i]);
|
|
775
771
|
mixedelements[1]["probs"] = indices_deltas.map((i) => mixedelements[1]["probs"][i]);
|
|
776
|
-
const deltas_loss =
|
|
777
|
-
|
|
772
|
+
const deltas_loss = [...deltas];
|
|
773
|
+
[...deltas];
|
|
778
774
|
which(mixedelements[0]["ranks"].map((d, i) => mixedelements[0]["ranks"][i] > mixedelements[1]["ranks"][i])).map((e) => deltas_loss[e] = -1);
|
|
779
|
-
which(mixedelements[0]["ranks"].map((d, i) => mixedelements[1]["ranks"][i] < mixedelements[1]["ranks"][i])).map((e) =>
|
|
775
|
+
which(mixedelements[0]["ranks"].map((d, i) => mixedelements[1]["ranks"][i] < mixedelements[1]["ranks"][i])).map((e) => -1);
|
|
780
776
|
const counts = diamond_counts(mixedelements);
|
|
781
777
|
return { "counts": counts, "deltas": deltas, "max_delta_loss": Math.max(...deltas_loss) };
|
|
782
778
|
}
|