allotaxonometer-ui 0.1.7 → 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 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.sm,
87
- fill: alloColors.css.darkergrey,
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.darkergreyy);
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.sm,
206
- fill: alloColors.css.darkergrey,
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.darkergreyy);
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 ?? ''}; font-size: 12px; fill: ${alloColors.css.darkergrey ?? ''};`);
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 ?? ''}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''};`);
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 ?? ''}; font-size: 14px; fill: ${alloColors.css.darkergrey ?? ''}; opacity: 0.5;`);
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 ?? ''}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''};`);
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 ?? ''}; font-size: 16px; fill: ${alloColors.css.verydarkgrey ?? ''};`);
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 ?? ''}; font-size: 10px; fill: ${alloColors.css.darkergrey ?? ''}; opacity: 0.5;`);
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 ?? ''}; font-size: 14px; fill: ${alloColors.css.darkergrey ?? ''};`);
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 ?? ''}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''}; text-anchor: start;`);
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 ?? ''}; font-size: 14px; fill: ${alloColors.css.verydarkgrey ?? ''}; text-anchor: start;`);
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 ?? ''}; font-size: 16px; color: ${alloColors.css.superdarkgrey ?? ''};`);
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 ?? ''}; font-size: 14px; color: ${alloColors.css.darkgrey ?? ''}; width: 150px; line-height: 1;`);
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 ?? ''}; font-size: 16px; color: ${alloColors.css.superdarkgrey ?? ''};`);
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 names", frequency: +(types_2.length / union_types.size).toFixed(3) },
1557
- { y_coord: "all names", frequency: -(types_1.length / union_types.size).toFixed(3) },
1558
- { y_coord: "exclusive names", frequency: +(setdiff(types_2, types_1).size / types_2.length).toFixed(3) },
1559
- { y_coord: "exclusive names", frequency: -(setdiff(types_1, types_2).size / types_1.length).toFixed(3) }
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
 
package/dist/ssr/index.js CHANGED
@@ -38,11 +38,8 @@ const alloColors = {
38
38
  const alloFonts = {
39
39
  family: `"EB Garamond", "Garamond", "Century Schoolbook L", "URW Bookman L", "Bookman Old Style", "Times", serif`,
40
40
  sizes: {
41
- xs: "10px",
42
- sm: "12px",
43
41
  md: "14px",
44
- lg: "16px",
45
- xl: "18px"
42
+ lg: "16px"
46
43
  }
47
44
  };
48
45
  function AxisX($$payload, $$props) {
@@ -58,15 +55,15 @@ function AxisX($$payload, $$props) {
58
55
  });
59
56
  let helperText = () => style({
60
57
  fontFamily: alloFonts.family,
61
- fontSize: alloFonts.sizes.sm,
62
- fill: alloColors.css.darkergrey,
58
+ fontSize: alloFonts.sizes.md,
59
+ fill: alloColors.css.darkgrey,
63
60
  textAnchor: "middle"
64
61
  });
65
62
  const each_array = $.ensure_array_like(xTicks);
66
63
  $$payload.out += `<g class="axis x"${$.attr("transform", `translate(0, ${$.stringify(innerHeight)})`)}><!--[-->`;
67
64
  for (let index = 0, $$length = each_array.length; index < $$length; index++) {
68
65
  let tick = each_array[index];
69
- $$payload.out += `<g${$.attr("transform", `translate(${$.stringify(scale(tick))}, 0)`)}><line x1="0" x2="0" y1="0" y2="6"${$.attr("stroke", alloColors.css.darkergreyy)} 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>`;
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>`;
70
67
  }
71
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>`;
72
69
  $.pop();
@@ -84,15 +81,15 @@ function AxisY($$payload, $$props) {
84
81
  });
85
82
  let helperText = () => style({
86
83
  fontFamily: alloFonts.family,
87
- fontSize: alloFonts.sizes.sm,
88
- fill: alloColors.css.darkergrey,
84
+ fontSize: alloFonts.sizes.md,
85
+ fill: alloColors.css.darkgrey,
89
86
  textAnchor: "middle"
90
87
  });
91
88
  const each_array = $.ensure_array_like(yTicks);
92
89
  $$payload.out += `<g class="axis y"${$.attr("transform", `translate(${$.stringify(innerHeight)}, 0) scale(-1, 1)`)}><!--[-->`;
93
90
  for (let index = 0, $$length = each_array.length; index < $$length; index++) {
94
91
  let tick = each_array[index];
95
- $$payload.out += `<g${$.attr("transform", `translate(0, ${$.stringify(scale(tick))})`)}><line x1="0" x2="-6" y1="0" y2="0"${$.attr("stroke", alloColors.css.darkergreyy)} 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>`;
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>`;
96
93
  }
97
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>`;
98
95
  $.pop();
@@ -285,7 +282,7 @@ function Diamond($$payload, $$props) {
285
282
  $$payload.out += `<!--]--><!--[-->`;
286
283
  for (let $$index_2 = 0, $$length = each_array_2.length; $$index_2 < $$length; $$index_2++) {
287
284
  let d = each_array_2[$$index_2];
288
- $$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>`;
289
286
  }
290
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>`;
291
288
  Contours($$payload, {
@@ -368,9 +365,9 @@ function Wordshift($$payload, $$props) {
368
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)})`)}><!--[-->`;
369
366
  for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
370
367
  let tick = each_array[$$index];
371
- $$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>`;
372
369
  }
373
- $$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><!--[-->`;
374
371
  for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
375
372
  let i = each_array_1[$$index_1];
376
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>`;
@@ -380,10 +377,10 @@ function Wordshift($$payload, $$props) {
380
377
  let label = each_array_2[$$index_2];
381
378
  const labelData = parseLabelData(label);
382
379
  const xValue = YX.get(label);
383
- $$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>`;
384
381
  if (labelData.numbers_y) {
385
382
  $$payload.out += "<!--[-->";
386
- $$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>`;
387
384
  } else {
388
385
  $$payload.out += "<!--[!-->";
389
386
  }
@@ -427,12 +424,12 @@ function DivergingBarChart($$payload, $$props) {
427
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"><!--[-->`;
428
425
  for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
429
426
  let i = each_array[$$index];
430
- $$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: 10px; fill: ${$.stringify(alloColors.css.darkergrey)}; opacity: 0.5;`)}>${$.escape(format(Math.abs(X[i])))}</text>`;
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>`;
431
428
  }
432
429
  $$payload.out += `<!--]--><g class="y-axis"${$.attr("transform", `translate(${$.stringify(xScale(0))}, -12)`)}><!--[-->`;
433
430
  for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
434
431
  let label = each_array_1[$$index_1];
435
- $$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>`;
436
433
  }
437
434
  $$payload.out += `<!--]--></g></g></svg>`;
438
435
  $.pop();
@@ -464,9 +461,9 @@ function Legend($$payload, $$props) {
464
461
  $$payload.out += `<!--]--><g transform="rotate(-90) translate(-60,5)"><!--[-->`;
465
462
  for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
466
463
  let tick = each_array_1[$$index_1];
467
- $$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>`;
468
465
  }
469
- $$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>`;
470
467
  $.pop();
471
468
  }
472
469
  function Dashboard($$payload, $$props) {
@@ -499,7 +496,7 @@ function Dashboard($$payload, $$props) {
499
496
  } = $$props;
500
497
  let max_shift = barData.length > 0 ? Math.max(...barData.map((d) => Math.abs(d.metric))) : 1;
501
498
  let wordshiftXDomain = xDomain || [-max_shift * 1.5, max_shift * 1.5];
502
- $$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">`;
503
500
  Diamond($$payload, {
504
501
  dat,
505
502
  alpha,
@@ -628,10 +625,10 @@ function balanceDat(elem1, elem2) {
628
625
  return [
629
626
  { y_coord: "total count", frequency: +(types_2.length / tot_types).toFixed(3) },
630
627
  { y_coord: "total count", frequency: -(types_1.length / tot_types).toFixed(3) },
631
- { y_coord: "all names", frequency: +(types_2.length / union_types.size).toFixed(3) },
632
- { y_coord: "all names", frequency: -(types_1.length / union_types.size).toFixed(3) },
633
- { y_coord: "exclusive names", frequency: +(setdiff(types_2, types_1).size / types_2.length).toFixed(3) },
634
- { y_coord: "exclusive names", frequency: -(setdiff(types_1, types_2).size / types_1.length).toFixed(3) }
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) }
635
632
  ];
636
633
  }
637
634
  function wordShift_dat(me, dat) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allotaxonometer-ui",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Headless UI components for allotaxonometer visualizations built with Svelte 5",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,8 @@
37
37
  "bugs": {
38
38
  "url": "https://github.com/Vermont-Complex-Systems/allotaxonometer-ui/issues"
39
39
  },
40
- "dependencies": {
40
+ "peerDependencies": {
41
+ "@ungap/structured-clone": "1.3.0",
41
42
  "d3": "^7.0.0",
42
43
  "svelte": "^5.0.0"
43
44
  },