allotaxonometer-ui 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jonathan St-Onge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -1,7 +1,67 @@
1
1
  import 'svelte/internal/disclose-version';
2
2
  import * as $ from 'svelte/internal/client';
3
+ import { scaleLinear } from 'd3-scale';
4
+ import { range, extent } from 'd3-array';
3
5
  import * as d3 from 'd3';
4
- import { extent, InternSet, range, rollup, scaleLinear, scaleBand, rgb, interpolateInferno, scaleOrdinal, max, scaleLog } from 'd3';
6
+ import { extent as extent$1, InternSet, range as range$1, rollup, scaleLinear as scaleLinear$1, scaleBand, rgb, interpolateInferno, scaleOrdinal, max, scaleLog } from 'd3';
7
+
8
+ var root_1$8 = $.from_svg(`<circle stroke="white" stroke-width="1"></circle>`);
9
+ var root$9 = $.from_svg(`<svg width="400" height="200" xmlns="http://www.w3.org/2000/svg"><rect width="400" height="200" fill="#f8f9fa" stroke="#dee2e6"></rect><text x="200" y="25" text-anchor="middle" font-size="16" font-weight="bold"> </text><g class="chart"></g><line x1="20" y1="180" x2="380" y2="180" stroke="#666" stroke-width="1"></line><line x1="20" y1="20" x2="20" y2="180" stroke="#666" stroke-width="1"></line><text x="200" y="198" text-anchor="middle" font-size="12" fill="#666">X Axis</text><text x="12" y="100" text-anchor="middle" font-size="12" fill="#666" transform="rotate(-90, 12, 100)">Y Axis</text></svg>`);
10
+
11
+ function Test($$anchor, $$props) {
12
+ $.push($$props, true);
13
+
14
+ let message = $.prop($$props, 'message', 3, "Hello World"),
15
+ data = $.prop($$props, 'data', 19, () => []);
16
+
17
+ // If no data provided, generate some test data
18
+ let testData = data().length > 0
19
+ ? data()
20
+ : range(10).map((i) => ({
21
+ x: i,
22
+ y: Math.sin(i / 2) * 20 + 50,
23
+ value: Math.random()
24
+ }));
25
+ // Pure D3 calculations - no DOM manipulation
26
+ let xScale = scaleLinear().domain(extent(testData, (d) => d.x)).range([20, 380]);
27
+ let yScale = scaleLinear().domain(extent(testData, (d) => d.y)).range([180, 20]);
28
+
29
+ // Calculate positions
30
+ let points = testData.map((d) => ({
31
+ cx: xScale(d.x),
32
+ cy: yScale(d.y),
33
+ r: 4 + d.value * 6,
34
+ fill: `hsl(${d.value * 360}, 70%, 50%)`
35
+ }));
36
+
37
+ var svg = root$9();
38
+ var text = $.sibling($.child(svg));
39
+ var text_1 = $.child(text, true);
40
+
41
+ $.reset(text);
42
+
43
+ var g = $.sibling(text);
44
+
45
+ $.each(g, 21, () => points, $.index, ($$anchor, point) => {
46
+ var circle = root_1$8();
47
+
48
+ $.template_effect(() => {
49
+ $.set_attribute(circle, 'cx', $.get(point).cx);
50
+ $.set_attribute(circle, 'cy', $.get(point).cy);
51
+ $.set_attribute(circle, 'r', $.get(point).r);
52
+ $.set_attribute(circle, 'fill', $.get(point).fill);
53
+ });
54
+
55
+ $.append($$anchor, circle);
56
+ });
57
+
58
+ $.reset(g);
59
+ $.next(4);
60
+ $.reset(svg);
61
+ $.template_effect(() => $.set_text(text_1, message()));
62
+ $.append($$anchor, svg);
63
+ $.pop();
64
+ }
5
65
 
6
66
  var root_1$7 = $.from_svg(`<g class="xtick"><line x1="0" x2="0" y1="0" y2="6" stroke="hsla(212, 10%, 53%, 1)"></line></g><g class="tick-text"><text font-size="10" dx="13" dy="13"> </text></g>`, 1);
7
67
  var root$8 = $.from_svg(`<g class="axis x"><!><g class="xlab svelte-1y8xk6i"><text dy="45">Rank r</text><text dy="63">for</text><text dy="80"> </text><text dy="60" fill="hsla(212, 10%, 53%, 1)" opacity="0.7">more →</text><text dy="75" fill="hsla(212, 10%, 53%, 1)" opacity="0.7">frequent</text><text dy="60" fill="hsla(212, 10%, 53%, 1)" opacity="0.7">← less</text><text dy="75" fill="hsla(212, 10%, 53%, 1)" opacity="0.7">frequent</text></g></g>`);
@@ -190,7 +250,7 @@ function Grid($$anchor, $$props) {
190
250
  $.pop();
191
251
  }
192
252
 
193
- var root_1$4 = $.from_svg(`<g><path fill="none" stroke="grey" stroke-width="0.9" stroke-opacity="0.9"></path></g>`);
253
+ var root_1$4 = $.from_svg(`<path fill="none" stroke="grey" stroke-width="0.9" stroke-opacity="0.9"></path>`);
194
254
  var root$5 = $.from_svg(`<g class="contours"></g>`);
195
255
 
196
256
  function Contours($$anchor, $$props) {
@@ -210,13 +270,8 @@ function Contours($$anchor, $$props) {
210
270
  }
211
271
 
212
272
  function make_grid(Ninset, tmpr1, tmpr2, alpha, rtd) {
213
- // No matrix in js :(
214
- // we could try to do like in the original d3.contour, where they do
215
- // calculation to work with a flat array.
216
- // Instead we flatten that List of list later.
217
273
  const deltamatrix = Array.from({ length: Ninset }, () => Array(Ninset).fill(0));
218
274
 
219
- // Populate deltamatrix with alpha_norm_type2 values and set the diagonal and adjacent values
220
275
  for (let i = 0; i < Ninset; i++) {
221
276
  for (let j = 0; j < Ninset; j++) {
222
277
  const divElem = alpha_norm_type2(1 / tmpr1[i], 1 / tmpr2[j], alpha);
@@ -224,10 +279,8 @@ function Contours($$anchor, $$props) {
224
279
  deltamatrix[i][j] = divElem / rtd.normalization;
225
280
  }
226
281
 
227
- // %% prevent contours from crossing the center line
228
282
  deltamatrix[i][i] = -1;
229
283
 
230
- // Set adjacent diagonal elements to -1 if within bounds
231
284
  if (i < Ninset - 1) {
232
285
  deltamatrix[i][i + 1] = -1;
233
286
  deltamatrix[i + 1][i] = -1;
@@ -238,37 +291,27 @@ function Contours($$anchor, $$props) {
238
291
  }
239
292
 
240
293
  function filter_contours(tmpcontours, Ninset, maxlog10) {
241
- const chart2val = d3.scaleLinear().domain([0, Ninset]).range([
242
- 0, // unit: km
243
- maxlog10
244
- ]); // unit: pixels
245
-
294
+ const chart2val = d3.scaleLinear().domain([0, Ninset]).range([0, maxlog10]);
246
295
  let out = [];
247
296
 
248
- // Extract Coordinates:
249
297
  tmpcontours.forEach((contour) => {
250
298
  contour.coordinates.forEach((pair, i) => {
251
- const tmpr1 = pair[0].map((d) => d[0]); // x-coordinates
252
- const tmpr2 = pair[0].map((d) => d[1]); // y-coordinates
253
- // Array to store filtered coordinate pairs in zipped format
299
+ const tmpr1 = pair[0].map((d) => d[0]);
300
+ const tmpr2 = pair[0].map((d) => d[1]);
254
301
  const filteredPairs = [];
255
302
 
256
- // Loop through each coordinate and calculate `tmpxrot`
257
303
  for (let index = 0; index < tmpr1.length - 1; index++) {
258
304
  const x1 = chart2val(tmpr1[index]);
259
305
  const x2 = chart2val(tmpr2[index]);
260
- // Calculate tmpxrot
261
306
  const tmpxrot = Math.abs(x2 - x1) / Math.sqrt(2);
262
307
 
263
- // If the condition is met, add the coordinate pair [x1, x2] to `filteredPairs`
264
308
  if (Math.abs(tmpxrot) >= 0.1 & x1 != maxlog10 & x2 != 0 & x1 != 0 & x2 != maxlog10) {
265
309
  filteredPairs.push([x1, x2]);
266
310
  }
267
311
  }
268
312
 
269
- // Only push to `out` if we have filtered pairs
270
313
  if (filteredPairs.length > 0) {
271
- out.push(filteredPairs); // Store each set of filtered pairs in `out`
314
+ out.push(filteredPairs);
272
315
  }
273
316
  });
274
317
  });
@@ -276,56 +319,37 @@ function Contours($$anchor, $$props) {
276
319
  return out;
277
320
  }
278
321
 
279
- function get_contours(alpha, maxlog10) {
280
- // only for alpha != 0 and alpha != Infinity
322
+ function get_contours(alpha, maxlog10, rtd) {
281
323
  const Ninset = 10 ** 3;
282
324
  const tmpr1 = d3.range(0, 1000).map((d) => Math.pow(10, d / 999 * 5));
283
325
  const tmpr2 = d3.range(0, 1000).map((d) => Math.pow(10, d / 999 * 5));
284
- // Create a scale to generate `Ncontours + 2` values linearly spaced between 1 and `tmpr1Length`
285
326
  const Ncontours = 10;
286
327
  const scale = d3.scaleLinear().domain([0, Ncontours + 1]).range([1, tmpr1.length]);
287
328
  const contour_indices = d3.range(Ncontours + 2).map((i) => Math.round(scale(i)));
288
- const grid = make_grid(Ninset, tmpr1, tmpr2, alpha, $$props.rtd);
329
+ const grid = make_grid(Ninset, tmpr1, tmpr2, alpha, rtd);
289
330
  const indices = contour_indices.slice(1, -1);
290
331
  const lastRow = grid[grid.length - 1];
291
332
  const heights = indices.map((index) => lastRow[index]);
292
- // equivalent to `contourc`
293
- // we first create a generator
294
- // then we pass to Z (flatDeltamatrix)
295
333
  const logTmpr = tmpr1.map(Math.log10);
296
- const contourGenerator = d3.contours().size([logTmpr.length, logTmpr.length]).thresholds(heights); // Set the grid size
297
- // I guess this is equivalent? These are levels.
334
+ const contourGenerator = d3.contours().size([logTmpr.length, logTmpr.length]).thresholds(heights);
298
335
  const flatDeltamatrix = grid.flat();
299
336
  const tmpcontours = contourGenerator(flatDeltamatrix);
300
337
 
301
338
  return filter_contours(tmpcontours, Ninset, maxlog10);
302
339
  }
303
340
 
304
- let mycontours = $.derived(() => get_contours($$props.alpha, $$props.maxlog10));
341
+ // Only calculate contours in browser
342
+ let mycontours = $.derived(() => get_contours($$props.alpha, $$props.maxlog10, $$props.rtd));
305
343
  const x = $.derived(() => d3.scaleLinear([0, $$props.maxlog10], [0, $$props.DiamondInnerHeight]));
306
344
  const y = $.derived(() => d3.scaleLinear([$$props.maxlog10, 0], [$$props.DiamondInnerHeight, 0]));
307
345
  const pathData = d3.line().x((d, i) => $.get(x)(d[0])).y((d, i) => $.get(y)(d[1]));
308
346
  var g = root$5();
309
347
 
310
348
  $.each(g, 21, () => $.get(mycontours), $.index, ($$anchor, contour) => {
311
- var g_1 = root_1$4();
312
- var path = $.child(g_1);
349
+ var path = root_1$4();
313
350
 
314
- $.reset(g_1);
315
-
316
- $.template_effect(
317
- ($0, $1, $2) => {
318
- $.set_attribute(g_1, 'transform', `translate(${$0 ?? ''}, ${$1 ?? ''})`);
319
- $.set_attribute(path, 'd', $2);
320
- },
321
- [
322
- () => $.get(x)($.get(contour)),
323
- () => $.get(y)($.get(contour)),
324
- () => pathData($.get(contour))
325
- ]
326
- );
327
-
328
- $.append($$anchor, g_1);
351
+ $.template_effect(($0) => $.set_attribute(path, 'd', $0), [() => pathData($.get(contour))]);
352
+ $.append($$anchor, path);
329
353
  });
330
354
 
331
355
  $.reset(g);
@@ -334,7 +358,7 @@ function Contours($$anchor, $$props) {
334
358
  }
335
359
 
336
360
  var root_1$3 = $.from_svg(`<rect stroke="black" stroke-width="0.2"></rect>`);
337
- var root_2$3 = $.from_svg(`<g class="diamond-lab"><text font-size="10"> </text></g>`);
361
+ var root_2$3 = $.from_svg(`<g class="diamond-lab"><text dy="20" font-size="10"> </text></g>`);
338
362
  var root$4 = $.from_svg(`<g class="diamond-chart"><polygon fill="#89CFF0" fill-opacity="0.2" stroke="black" stroke-width="0.5"></polygon><polygon fill="grey" fill-opacity="0.2" stroke="black" stroke-width="0.5"></polygon><!><!><!><!><!><!></g>`);
339
363
 
340
364
  function Diamond($$anchor, $$props) {
@@ -358,7 +382,9 @@ function Diamond($$anchor, $$props) {
358
382
  });
359
383
 
360
384
  const max_dist_idx = cos_dists.indexOf(max_dist);
361
- const name = d3.shuffle(filtered_dat[max_dist_idx]['types'].split(","))[0];
385
+ // Use a simple random selection instead of d3.shuffle during SSR
386
+ const types = filtered_dat[max_dist_idx]['types'].split(",");
387
+ const name = types[Math.floor(Math.random() * types.length)];
362
388
 
363
389
  relevant_types.push(name);
364
390
  }
@@ -369,13 +395,6 @@ function Diamond($$anchor, $$props) {
369
395
  }
370
396
 
371
397
  function rin(arr1, arr2) {
372
- // Find element arr1 presents in arr2, i.e. arr1 %in% arr2
373
- //
374
- // examples
375
- // A = ["bob", "george", "jesus"]
376
- // B = ["bob", "jesus", "terrence"]
377
- // rin(A, B)
378
- // [true, false, true]
379
398
  return Array.from(arr1, (x) => {
380
399
  return arr2.indexOf(x) == -1 ? false : true;
381
400
  });
@@ -383,13 +402,13 @@ function Diamond($$anchor, $$props) {
383
402
 
384
403
  // Wrangling data
385
404
  let relevant_types = $.derived(() => get_relevant_types($$props.diamond_dat));
386
- // Extracting constant
405
+ // Extracting constants - all these should be SSR-safe
387
406
  let max_rank_raw = $.derived(() => d3.range(d3.max($$props.diamond_count, (d) => d.x1)));
388
407
  let max_rank = $.derived(() => d3.max($$props.diamond_dat, (d) => d.rank_L[1]));
389
408
  let rounded_max_rank = $.derived(() => 10 ** Math.ceil(Math.max(Math.log10($.get(max_rank)))));
390
409
  let ncells = $.derived(() => d3.max($.get(max_rank_raw)));
391
410
  let xyDomain = $.derived(() => [1, $.get(rounded_max_rank)]);
392
- // All the Scales!
411
+ // All the Scales! - These should be SSR-safe
393
412
  let linScale = $.derived(() => d3.scaleLinear().domain([0, $.get(ncells) - 1]).range([0, $$props.DiamondInnerHeight]));
394
413
  let wxy = $.derived(() => d3.scaleBand().domain($.get(max_rank_raw)).range([0, $$props.DiamondInnerHeight]));
395
414
  let logScale = $.derived(() => d3.scaleLog().domain($.get(xyDomain)).range([0, $$props.DiamondInnerHeight]).nice());
@@ -498,9 +517,6 @@ function Diamond($$anchor, $$props) {
498
517
  $.each(node_4, 17, () => $$props.diamond_dat.filter((d) => filter_labs(d, $.get(relevant_types))), $.index, ($$anchor, d) => {
499
518
  var g_1 = root_2$3();
500
519
  var text = $.child(g_1);
501
-
502
- $.set_attribute(text, 'dy', 20);
503
-
504
520
  var text_1 = $.child(text, true);
505
521
 
506
522
  $.reset(text);
@@ -728,12 +744,12 @@ function DivergingBarChart($$anchor, $$props) {
728
744
  let X = $.derived(() => dat.map((d) => d.frequency));
729
745
  let Y = $.derived(() => dat.map((d) => d.y_coord));
730
746
  let xRange = $.derived(() => [margin.left, width - margin.right]);
731
- let xDomain = $.derived(() => extent($.get(X)));
747
+ let xDomain = $.derived(() => extent$1($.get(X)));
732
748
  let yDomain = $.derived(() => new InternSet($.get(Y)));
733
749
  let height = $.derived(() => Math.ceil(($.get(yDomain).size + yPadding) * 25) + margin.top + margin.bottom);
734
- let I = $.derived(() => range($.get(X).length).filter((i) => $.get(yDomain).has($.get(Y)[i])));
750
+ let I = $.derived(() => range$1($.get(X).length).filter((i) => $.get(yDomain).has($.get(Y)[i])));
735
751
  $.derived(() => rollup($.get(I), ([i]) => $.get(X)[i], (i) => $.get(Y)[i]));
736
- let xScale = $.derived(() => scaleLinear($.get(xDomain), $.get(xRange)));
752
+ let xScale = $.derived(() => scaleLinear$1($.get(xDomain), $.get(xRange)));
737
753
  let yScale = $.derived(() => scaleBand().domain($.get(yDomain)).range([margin.top, $.get(height) - margin.bottom]).padding(yPadding));
738
754
  let format = $.derived(() => $.get(xScale).tickFormat(100, "%"));
739
755
  var g = root$2();
@@ -813,8 +829,8 @@ function Legend($$anchor, $$props) {
813
829
  $.push($$props, true);
814
830
 
815
831
  const N_CATEGO = 20;
816
- const myramp = range(N_CATEGO).map((i) => rgb(interpolateInferno(i / (N_CATEGO - 1))).hex());
817
- const color = scaleOrdinal(range(N_CATEGO), myramp);
832
+ const myramp = range$1(N_CATEGO).map((i) => rgb(interpolateInferno(i / (N_CATEGO - 1))).hex());
833
+ const color = scaleOrdinal(range$1(N_CATEGO), myramp);
818
834
  let height = 370;
819
835
  const margin = { right: 40, top: 65, left: 10 };
820
836
  let innerHeight = $.derived(() => height - margin.top - margin.right);
@@ -1091,4 +1107,4 @@ function Dashboard($$anchor, $$props) {
1091
1107
  $.append($$anchor, div);
1092
1108
  }
1093
1109
 
1094
- export { Dashboard, Diamond, DivergingBarChart, Legend, Wordshift };
1110
+ export { Dashboard, Diamond, DivergingBarChart, Legend, Test, Wordshift };
@@ -0,0 +1,505 @@
1
+ import * as $ from "svelte/internal/server";
2
+ import { scaleLinear } from "d3-scale";
3
+ import { range, extent } from "d3-array";
4
+ import * as d3 from "d3";
5
+ import { extent as extent$1, InternSet, range as range$1, rollup, scaleLinear as scaleLinear$1, scaleBand, rgb, interpolateInferno, scaleOrdinal, max, scaleLog } from "d3";
6
+ function Test($$payload, $$props) {
7
+ $.push();
8
+ let { message = "Hello World", data = [] } = $$props;
9
+ let testData = data.length > 0 ? data : range(10).map((i) => ({
10
+ x: i,
11
+ y: Math.sin(i / 2) * 20 + 50,
12
+ value: Math.random()
13
+ }));
14
+ let xScale = scaleLinear().domain(extent(testData, (d) => d.x)).range([20, 380]);
15
+ let yScale = scaleLinear().domain(extent(testData, (d) => d.y)).range([180, 20]);
16
+ let points = testData.map((d) => ({
17
+ cx: xScale(d.x),
18
+ cy: yScale(d.y),
19
+ r: 4 + d.value * 6,
20
+ fill: `hsl(${d.value * 360}, 70%, 50%)`
21
+ }));
22
+ const each_array = $.ensure_array_like(points);
23
+ $$payload.out += `<svg width="400" height="200" xmlns="http://www.w3.org/2000/svg"><rect width="400" height="200" fill="#f8f9fa" stroke="#dee2e6"></rect><text x="200" y="25" text-anchor="middle" font-size="16" font-weight="bold">${$.escape(message)}</text><g class="chart"><!--[-->`;
24
+ for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
25
+ let point = each_array[$$index];
26
+ $$payload.out += `<circle${$.attr("cx", point.cx)}${$.attr("cy", point.cy)}${$.attr("r", point.r)}${$.attr("fill", point.fill)} stroke="white" stroke-width="1"></circle>`;
27
+ }
28
+ $$payload.out += `<!--]--></g><line x1="20" y1="180" x2="380" y2="180" stroke="#666" stroke-width="1"></line><line x1="20" y1="20" x2="20" y2="180" stroke="#666" stroke-width="1"></line><text x="200" y="198" text-anchor="middle" font-size="12" fill="#666">X Axis</text><text x="12" y="100" text-anchor="middle" font-size="12" fill="#666" transform="rotate(-90, 12, 100)">Y Axis</text></svg>`;
29
+ $.pop();
30
+ }
31
+ function AxisX($$payload, $$props) {
32
+ $.push();
33
+ let {
34
+ height,
35
+ scale,
36
+ title
37
+ } = $$props;
38
+ let logFormat10 = scale.tickFormat();
39
+ let xTicks = scale.ticks();
40
+ const each_array = $.ensure_array_like(xTicks);
41
+ $$payload.out += `<g class="axis x"${$.attr("transform", `translate(0, ${$.stringify(height)})`)}><!--[-->`;
42
+ for (let index = 0, $$length = each_array.length; index < $$length; index++) {
43
+ let tick = each_array[index];
44
+ $$payload.out += `<g class="xtick"${$.attr("transform", `translate(${$.stringify(scale(tick))}, 0)`)}><line x1="0" x2="0" y1="0" y2="6" stroke="hsla(212, 10%, 53%, 1)"></line></g><g class="tick-text"${$.attr("transform", `translate(${$.stringify(scale(tick))}, 0) scale(-1,1) rotate(45)`)}><text font-size="10" dx="13" dy="13">${$.escape(logFormat10(tick))}</text></g>`;
45
+ }
46
+ $$payload.out += `<!--]--><g class="xlab svelte-1y8xk6i"${$.attr("transform", `scale(-1,1) translate(-${$.stringify(height)}, 0)`)}><text dy="45"${$.attr("x", height / 2)}>Rank r</text><text dy="63"${$.attr("x", height / 2)}>for</text><text dy="80"${$.attr("x", height / 2)}>${$.escape(title[1])}</text><text dy="60"${$.attr("x", height - 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">more →</text><text dy="75"${$.attr("x", height - 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">frequent</text><text dy="60"${$.attr("x", 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">← less</text><text dy="75"${$.attr("x", 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">frequent</text></g></g>`;
47
+ $.pop();
48
+ }
49
+ function AxisY($$payload, $$props) {
50
+ $.push();
51
+ let { height, scale, title } = $$props;
52
+ let logFormat10 = scale.tickFormat();
53
+ let yTicks = scale.ticks();
54
+ const each_array = $.ensure_array_like(yTicks);
55
+ $$payload.out += `<g class="axis y"${$.attr("transform", `translate(${$.stringify(height)}, 0) scale(-1, 1)`)}><!--[-->`;
56
+ for (let index = 0, $$length = each_array.length; index < $$length; index++) {
57
+ let tick = each_array[index];
58
+ $$payload.out += `<g class="ytick"${$.attr("transform", `translate(0, ${$.stringify(scale(tick))})`)}><line x1="0" x2="-6" y1="0" y2="0" stroke="hsla(212, 10%, 53%, 1)"></line></g><g class="tick-text"${$.attr("transform", `translate(0, ${$.stringify(scale(tick))}) rotate(45)`)}><text font-size="10" dx="-23" dy="10">${$.escape(logFormat10(tick))}</text></g>`;
59
+ }
60
+ $$payload.out += `<!--]--><g class="ylab svelte-1y8visx" transform="rotate(90)"><text dy="45"${$.attr("x", height / 2)}>Rank r</text><text dy="63"${$.attr("x", height / 2)}>for</text><text dy="80"${$.attr("x", height / 2)}>${$.escape(title[0])}</text><text dy="60"${$.attr("x", height - 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">more →</text><text dy="75"${$.attr("x", height - 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">frequent</text><text dy="60"${$.attr("x", 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">← less</text><text dy="75"${$.attr("x", 40)} fill="hsla(212, 10%, 53%, 1)" opacity="0.7">frequent</text></g></g>`;
61
+ $.pop();
62
+ }
63
+ function Grid($$payload, $$props) {
64
+ $.push();
65
+ let { scale, height, wxy, ncells } = $$props;
66
+ let xygridLines = scale.ticks(ncells / 2);
67
+ const each_array = $.ensure_array_like(xygridLines);
68
+ $$payload.out += `<g class="grid"><!--[-->`;
69
+ for (let index = 0, $$length = each_array.length; index < $$length; index++) {
70
+ let yline = each_array[index];
71
+ $$payload.out += `<g${$.attr("transform", `translate(${$.stringify(wxy(yline))}, 0)`)}><line${$.attr("y1", height)} y2="0" stroke="#d3d3d3" stroke-dasharray="3,3"${$.attr("opacity", index === 0 ? 0 : 1)}></line></g><g${$.attr("transform", `translate(0, ${$.stringify(wxy(yline))})`)}><line${$.attr("x1", height)} x2="0" stroke="#d3d3d3" stroke-dasharray="3,3"${$.attr("opacity", index === 0 ? 0 : 1)}></line></g>`;
72
+ }
73
+ $$payload.out += `<!--]--></g>`;
74
+ $.pop();
75
+ }
76
+ function Contours($$payload, $$props) {
77
+ $.push();
78
+ let { alpha, maxlog10, rtd, DiamondInnerHeight } = $$props;
79
+ function alpha_norm_type2(x1, x2, alpha2) {
80
+ if (alpha2 == 0) {
81
+ return Math.abs(Math.log(x1 / x2));
82
+ } else if (alpha2 === Infinity) {
83
+ return x1 === x2 ? 0 : Math.max(x1, x2);
84
+ } else {
85
+ const prefactor = (alpha2 + 1) / alpha2;
86
+ const power = 1 / (alpha2 + 1);
87
+ return prefactor * Math.abs(Math.pow(x1, alpha2) - Math.pow(x2, alpha2)) ** power;
88
+ }
89
+ }
90
+ function make_grid(Ninset, tmpr1, tmpr2, alpha2, rtd2) {
91
+ const deltamatrix = Array.from({ length: Ninset }, () => Array(Ninset).fill(0));
92
+ for (let i = 0; i < Ninset; i++) {
93
+ for (let j = 0; j < Ninset; j++) {
94
+ const divElem = alpha_norm_type2(1 / tmpr1[i], 1 / tmpr2[j], alpha2);
95
+ deltamatrix[i][j] = divElem / rtd2.normalization;
96
+ }
97
+ deltamatrix[i][i] = -1;
98
+ if (i < Ninset - 1) {
99
+ deltamatrix[i][i + 1] = -1;
100
+ deltamatrix[i + 1][i] = -1;
101
+ }
102
+ }
103
+ return deltamatrix;
104
+ }
105
+ function filter_contours(tmpcontours, Ninset, maxlog102) {
106
+ const chart2val = d3.scaleLinear().domain([0, Ninset]).range([0, maxlog102]);
107
+ let out = [];
108
+ tmpcontours.forEach((contour) => {
109
+ contour.coordinates.forEach((pair, i) => {
110
+ const tmpr1 = pair[0].map((d) => d[0]);
111
+ const tmpr2 = pair[0].map((d) => d[1]);
112
+ const filteredPairs = [];
113
+ for (let index = 0; index < tmpr1.length - 1; index++) {
114
+ const x1 = chart2val(tmpr1[index]);
115
+ const x2 = chart2val(tmpr2[index]);
116
+ const tmpxrot = Math.abs(x2 - x1) / Math.sqrt(2);
117
+ if (Math.abs(tmpxrot) >= 0.1 & x1 != maxlog102 & x2 != 0 & x1 != 0 & x2 != maxlog102) {
118
+ filteredPairs.push([x1, x2]);
119
+ }
120
+ }
121
+ if (filteredPairs.length > 0) {
122
+ out.push(filteredPairs);
123
+ }
124
+ });
125
+ });
126
+ return out;
127
+ }
128
+ function get_contours(alpha2, maxlog102, rtd2) {
129
+ const Ninset = 10 ** 3;
130
+ const tmpr1 = d3.range(0, 1e3).map((d) => Math.pow(10, d / 999 * 5));
131
+ const tmpr2 = d3.range(0, 1e3).map((d) => Math.pow(10, d / 999 * 5));
132
+ const Ncontours = 10;
133
+ const scale = d3.scaleLinear().domain([0, Ncontours + 1]).range([1, tmpr1.length]);
134
+ const contour_indices = d3.range(Ncontours + 2).map((i) => Math.round(scale(i)));
135
+ const grid = make_grid(Ninset, tmpr1, tmpr2, alpha2, rtd2);
136
+ const indices = contour_indices.slice(1, -1);
137
+ const lastRow = grid[grid.length - 1];
138
+ const heights = indices.map((index) => lastRow[index]);
139
+ const logTmpr = tmpr1.map(Math.log10);
140
+ const contourGenerator = d3.contours().size([logTmpr.length, logTmpr.length]).thresholds(heights);
141
+ const flatDeltamatrix = grid.flat();
142
+ const tmpcontours = contourGenerator(flatDeltamatrix);
143
+ return filter_contours(tmpcontours, Ninset, maxlog102);
144
+ }
145
+ let mycontours = get_contours(alpha, maxlog10, rtd);
146
+ const x = d3.scaleLinear([0, maxlog10], [0, DiamondInnerHeight]);
147
+ const y = d3.scaleLinear([maxlog10, 0], [DiamondInnerHeight, 0]);
148
+ const pathData = d3.line().x((d, i) => x(d[0])).y((d, i) => y(d[1]));
149
+ const each_array = $.ensure_array_like(mycontours);
150
+ $$payload.out += `<g class="contours"><!--[-->`;
151
+ for (let index = 0, $$length = each_array.length; index < $$length; index++) {
152
+ let contour = each_array[index];
153
+ $$payload.out += `<path fill="none" stroke="grey"${$.attr("d", pathData(contour))} stroke-width="0.9" stroke-opacity="0.9"></path>`;
154
+ }
155
+ $$payload.out += `<!--]--></g>`;
156
+ $.pop();
157
+ }
158
+ function Diamond($$payload, $$props) {
159
+ $.push();
160
+ let {
161
+ diamond_count,
162
+ diamond_dat,
163
+ margin,
164
+ DiamondInnerHeight,
165
+ trueDiamondHeight,
166
+ alpha,
167
+ maxlog10,
168
+ rtd,
169
+ title
170
+ } = $$props;
171
+ function get_relevant_types(diamond_dat2) {
172
+ const ncells2 = 60;
173
+ const bin_size = 1.5;
174
+ const cummulative_bin = d3.range(0, ncells2, bin_size);
175
+ const relevant_types2 = [];
176
+ for (let sys of ["right", "left"]) {
177
+ for (let i = 1; i < cummulative_bin.length; i++) {
178
+ const filtered_dat = diamond_dat2.filter((d) => d.value > 0 && d.which_sys == sys).filter((d) => d.coord_on_diag >= cummulative_bin[i - 1] && d.coord_on_diag < cummulative_bin[i]);
179
+ if (filtered_dat.length > 0) {
180
+ const cos_dists = filtered_dat.map((d) => d.cos_dist);
181
+ const max_dist = cos_dists.reduce((a, b) => {
182
+ return Math.max(a, b);
183
+ });
184
+ const max_dist_idx = cos_dists.indexOf(max_dist);
185
+ const types = filtered_dat[max_dist_idx]["types"].split(",");
186
+ const name = types[Math.floor(Math.random() * types.length)];
187
+ relevant_types2.push(name);
188
+ }
189
+ }
190
+ }
191
+ return relevant_types2;
192
+ }
193
+ function rin(arr1, arr2) {
194
+ return Array.from(arr1, (x) => {
195
+ return arr2.indexOf(x) == -1 ? false : true;
196
+ });
197
+ }
198
+ let relevant_types = get_relevant_types(diamond_dat);
199
+ let max_rank_raw = d3.range(d3.max(diamond_count, (d) => d.x1));
200
+ let max_rank = d3.max(diamond_dat, (d) => d.rank_L[1]);
201
+ let rounded_max_rank = 10 ** Math.ceil(Math.max(Math.log10(max_rank)));
202
+ let ncells = d3.max(max_rank_raw);
203
+ let xyDomain = [1, rounded_max_rank];
204
+ let linScale = d3.scaleLinear().domain([0, ncells - 1]).range([0, DiamondInnerHeight]);
205
+ let wxy = d3.scaleBand().domain(max_rank_raw).range([0, DiamondInnerHeight]);
206
+ let logScale = d3.scaleLog().domain(xyDomain).range([0, DiamondInnerHeight]).nice();
207
+ let xy = d3.scaleBand().domain(max_rank_raw).range([0, trueDiamondHeight]);
208
+ let color_scale = d3.scaleSequentialLog().domain([rounded_max_rank, 1]).interpolator(d3.interpolateInferno);
209
+ let blue_triangle = [
210
+ [DiamondInnerHeight, DiamondInnerHeight],
211
+ [0, 0],
212
+ [0, DiamondInnerHeight]
213
+ ].join(" ");
214
+ let grey_triangle = [
215
+ [DiamondInnerHeight, DiamondInnerHeight],
216
+ [0, 0],
217
+ [DiamondInnerHeight, 0]
218
+ ].join(" ");
219
+ function filter_labs(d, relevant_types2) {
220
+ return rin(relevant_types2, d.types.split(",")).some((x) => x === true);
221
+ }
222
+ const each_array = $.ensure_array_like(diamond_dat);
223
+ const each_array_1 = $.ensure_array_like(diamond_dat.filter((d) => filter_labs(d, relevant_types)));
224
+ $$payload.out += `<g class="diamond-chart"${$.attr("transform", `translate(360, 0) scale (-1,1) rotate(45) translate(${$.stringify(margin.inner / 2)}, ${$.stringify(margin.inner / 2)})`)}><polygon${$.attr("points", blue_triangle)} fill="#89CFF0" fill-opacity="0.2" stroke="black" stroke-width="0.5"></polygon><polygon${$.attr("points", grey_triangle)} fill="grey" fill-opacity="0.2" stroke="black" stroke-width="0.5"></polygon>`;
225
+ AxisX($$payload, {
226
+ height: DiamondInnerHeight,
227
+ scale: logScale,
228
+ title
229
+ });
230
+ $$payload.out += `<!---->`;
231
+ AxisY($$payload, {
232
+ height: DiamondInnerHeight,
233
+ scale: logScale,
234
+ title
235
+ });
236
+ $$payload.out += `<!---->`;
237
+ Grid($$payload, {
238
+ height: DiamondInnerHeight,
239
+ wxy,
240
+ ncells,
241
+ scale: linScale
242
+ });
243
+ $$payload.out += `<!----><!--[-->`;
244
+ for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
245
+ let d = each_array[$$index];
246
+ $$payload.out += `<rect${$.attr("x", xy(d.x1))}${$.attr("y", xy(d.y1))}${$.attr("width", xy.bandwidth())}${$.attr("height", xy.bandwidth())}${$.attr("fill", color_scale(d.value))}${$.attr("opacity", d.value === null ? 0 : 1)} stroke="black" stroke-width="0.2"></rect>`;
247
+ }
248
+ $$payload.out += `<!--]--><!--[-->`;
249
+ for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
250
+ let d = each_array_1[$$index_1];
251
+ $$payload.out += `<g class="diamond-lab"${$.attr("transform", `
252
+ scale(1,-1)
253
+ rotate(-90)
254
+ rotate(-45, ${$.stringify(xy(d.x1))}, ${$.stringify(xy(d.y1))})
255
+ translate(${$.stringify(d.which_sys === "right" ? xy(Math.sqrt(d.cos_dist)) * 1.5 : -xy(Math.sqrt(d.cos_dist)) * 1.5)}, 0)
256
+ `)}><text${$.attr("x", xy(d.x1))}${$.attr("y", Number.isInteger(d.coord_on_diag) ? xy(d.y1) : xy(d.y1) - 1)} dy="20" font-size="10"${$.attr("text-anchor", d.x1 - d.y1 <= 0 ? "start" : "end")}>${$.escape(d.types.split(",")[0])}</text></g>`;
257
+ }
258
+ $$payload.out += `<!--]-->`;
259
+ Contours($$payload, { alpha, maxlog10, rtd, DiamondInnerHeight });
260
+ $$payload.out += `<!----></g>`;
261
+ $.pop();
262
+ }
263
+ function Wordshift($$payload, $$props) {
264
+ $.push();
265
+ let { barData, DashboardHeight, DashboardWidth } = $$props;
266
+ let margin = { top: 80, left: 140, right: 50, bottom: 10 };
267
+ let width = 640;
268
+ let yPadding = 0.2;
269
+ let Y = d3.map(barData, (d) => d.type);
270
+ let max_shift = d3.max(barData, (d) => Math.abs(d.metric)) * 1.5;
271
+ let xDomain = [-max_shift, max_shift];
272
+ let yDomain = new d3.InternSet(Y);
273
+ let xRange = [
274
+ DashboardWidth - width + margin.left,
275
+ DashboardWidth - margin.right
276
+ ];
277
+ let yRange = [margin.top, DashboardHeight - margin.bottom];
278
+ let xScale = d3.scaleLinear().domain(xDomain).range(xRange);
279
+ let yScale = d3.scaleBand(yDomain, yRange).padding(yPadding);
280
+ let xTicks = xScale.ticks(width / 80);
281
+ const colors = ["lightgrey", "lightblue"];
282
+ const each_array = $.ensure_array_like(xTicks);
283
+ const each_array_1 = $.ensure_array_like(barData);
284
+ $$payload.out += `<g class="barChart-container svelte-37sv8o"><g class="axis x"${$.attr("transform", `translate(0, ${$.stringify(margin.top)})`)}><!--[-->`;
285
+ for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
286
+ let tick = each_array[$$index];
287
+ $$payload.out += `<g class="tick"><line${$.attr("x1", xScale(tick))} y1="0"${$.attr("x2", xScale(tick))}${$.attr("y2", DashboardHeight - margin.top - margin.bottom)} stroke="hsla(212, 10%, 53%, 1)" stroke-opacity="0.2">${$.escape(tick)}</line><text${$.attr("x", xScale(tick))} y="-12" font-size="0.8em">${$.escape(tick * 100)}%</text></g>`;
288
+ }
289
+ $$payload.out += `<!--]--></g><!--[-->`;
290
+ for (let i = 0, $$length = each_array_1.length; i < $$length; i++) {
291
+ let d = each_array_1[i];
292
+ $$payload.out += `<rect${$.attr("x", Math.min(xScale(0), xScale(d.metric)))}${$.attr("y", yScale(d.type))}${$.attr("fill", colors[d.metric > 0 ? colors.length - 1 : 0])}${$.attr("width", Math.abs(xScale(d.metric) - xScale(0)))}${$.attr("height", yScale.bandwidth())}></rect><text${$.attr("x", Math.min(xScale(0), xScale(d.metric)))}${$.attr("y", yScale(d.type))} dy="14" font-size="0.7em">${$.escape(d.type)}</text>`;
293
+ }
294
+ $$payload.out += `<!--]--></g>`;
295
+ $.pop();
296
+ }
297
+ function DivergingBarChart($$payload, $$props) {
298
+ $.push();
299
+ let {
300
+ test_elem_1,
301
+ test_elem_2,
302
+ DiamondHeight,
303
+ DiamondWidth
304
+ } = $$props;
305
+ const setdiff = (x, y) => {
306
+ let a = new Set(x);
307
+ let b = new Set(y);
308
+ return new Set([...a].filter((x2) => !b.has(x2)));
309
+ };
310
+ const union = (x, y) => {
311
+ let a = new Set(x);
312
+ let b = new Set(y);
313
+ return /* @__PURE__ */ new Set([...a, ...b]);
314
+ };
315
+ let types_1 = test_elem_1.map((d) => d.types);
316
+ let types_2 = test_elem_2.map((d) => d.types);
317
+ let union_types = union(types_1, types_2);
318
+ let tot_types = types_1.length + types_2.length;
319
+ let width = 200;
320
+ let margin = { right: 40, top: 30, left: 40, bottom: 10 };
321
+ let yPadding = 0.5;
322
+ let colors = ["lightgrey", "lightblue"];
323
+ let dat = [
324
+ {
325
+ y_coord: "total count",
326
+ frequency: +(types_2.length / tot_types).toFixed(3)
327
+ },
328
+ {
329
+ y_coord: "total count",
330
+ frequency: -(types_1.length / tot_types).toFixed(3)
331
+ },
332
+ {
333
+ y_coord: "all names",
334
+ frequency: +(types_2.length / union_types.size).toFixed(3)
335
+ },
336
+ {
337
+ y_coord: "all names",
338
+ frequency: -(types_1.length / union_types.size).toFixed(3)
339
+ },
340
+ {
341
+ y_coord: "exclusive names",
342
+ frequency: +(setdiff(types_2, types_1).size / types_2.length).toFixed(3)
343
+ },
344
+ {
345
+ y_coord: "exclusive names",
346
+ frequency: -(setdiff(types_1, types_2).size / types_1.length).toFixed(3)
347
+ }
348
+ ];
349
+ let X = dat.map((d) => d.frequency);
350
+ let Y = dat.map((d) => d.y_coord);
351
+ let xRange = [margin.left, width - margin.right];
352
+ let xDomain = extent$1(X);
353
+ let yDomain = new InternSet(Y);
354
+ let height = Math.ceil((yDomain.size + yPadding) * 25) + margin.top + margin.bottom;
355
+ let I = range$1(X.length).filter((i) => yDomain.has(Y[i]));
356
+ rollup(I, ([i]) => X[i], (i) => Y[i]);
357
+ let xScale = scaleLinear$1(xDomain, xRange);
358
+ let yScale = scaleBand().domain(yDomain).range([margin.top, height - margin.bottom]).padding(yPadding);
359
+ let format = xScale.tickFormat(100, "%");
360
+ const each_array = $.ensure_array_like(dat);
361
+ const each_array_1 = $.ensure_array_like(yScale.domain());
362
+ $$payload.out += `<g class="balance-chart"${$.attr("transform", `translate(${$.stringify(DiamondWidth - 75)}, ${$.stringify(DiamondHeight + 75)})`)}><!--[-->`;
363
+ for (let i = 0, $$length = each_array.length; i < $$length; i++) {
364
+ let d = each_array[i];
365
+ $$payload.out += `<rect${$.attr("x", Math.min(xScale(0), xScale(d.frequency)))}${$.attr("y", yScale(d.y_coord))}${$.attr("fill", colors[X[i] > 0 ? colors.length - 1 : 0])}${$.attr("width", Math.abs(xScale(d.frequency) - 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)} opacity="0.5" dy="0.35em" font-size="10"${$.attr("text-anchor", d.frequency < 0 ? "end" : "start")}>${$.escape(format(Math.abs(d.frequency)))}</text>`;
366
+ }
367
+ $$payload.out += `<!--]--><!--[-->`;
368
+ for (let i = 0, $$length = each_array_1.length; i < $$length; i++) {
369
+ let text = each_array_1[i];
370
+ $$payload.out += `<g class="diverging-ticks"><text${$.attr("x", xScale(0))}${$.attr("y", yScale(text) + yScale.bandwidth() / 2)} dy="-.9em" dx="-3em" font-size="10">${$.escape(text)}</text></g>`;
371
+ }
372
+ $$payload.out += `<!--]--></g>`;
373
+ $.pop();
374
+ }
375
+ function Legend($$payload, $$props) {
376
+ $.push();
377
+ let { diamond_dat, DiamondHeight } = $$props;
378
+ const N_CATEGO = 20;
379
+ const myramp = range$1(N_CATEGO).map((i) => rgb(interpolateInferno(i / (N_CATEGO - 1))).hex());
380
+ const color = scaleOrdinal(range$1(N_CATEGO), myramp);
381
+ let height = 370;
382
+ const margin = { right: 40, top: 65, left: 10 };
383
+ let innerHeight = height - margin.top - margin.right;
384
+ let max_rank = max(diamond_dat, (d) => d.rank_L[1]);
385
+ let y = scaleBand().domain(color.domain().reverse()).rangeRound([0, innerHeight]);
386
+ let logY = scaleLog().domain([
387
+ 1,
388
+ 10 ** Math.ceil(Math.max(Math.log10(max_rank)) - 1)
389
+ ]).rangeRound([0, innerHeight]).nice();
390
+ let logFormat10 = logY.tickFormat();
391
+ let yTicks = logY.ticks();
392
+ const each_array = $.ensure_array_like(color.domain());
393
+ const each_array_1 = $.ensure_array_like(yTicks);
394
+ $$payload.out += `<g class="legend-container"${$.attr("transform", `translate(${$.stringify(margin.left)}, ${$.stringify(DiamondHeight - margin.top)})`)}><!--[-->`;
395
+ for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
396
+ let d = each_array[$$index];
397
+ $$payload.out += `<rect${$.attr("x", 0)}${$.attr("y", y(d))}${$.attr("width", 14)}${$.attr("height", 13)}${$.attr("fill", color(d))} stroke="whitesmoke" stroke-width="1"></rect>`;
398
+ }
399
+ $$payload.out += `<!--]--></g><!--[-->`;
400
+ for (let i = 0, $$length = each_array_1.length; i < $$length; i++) {
401
+ let tick = each_array_1[i];
402
+ $$payload.out += `<g class="legend-text"${$.attr("transform", `translate(${$.stringify(margin.left)}, ${$.stringify(DiamondHeight + logY(tick) - margin.top)})`)}><text font-size="10"${$.attr("dy", yTicks.length - 1 == i ? "-3" : "13")} dx="20">${$.escape(logFormat10(tick))}</text></g>`;
403
+ if (i === yTicks.length - 1) {
404
+ $$payload.out += "<!--[-->";
405
+ $$payload.out += `<g class="legend-title"${$.attr("transform", `translate(${$.stringify(margin.left)}, ${$.stringify(DiamondHeight + logY(tick) - margin.top)})`)}><text font-size="13" dy="9">Counts per cell</text></g>`;
406
+ } else {
407
+ $$payload.out += "<!--[!-->";
408
+ }
409
+ $$payload.out += `<!--]-->`;
410
+ }
411
+ $$payload.out += `<!--]-->`;
412
+ $.pop();
413
+ }
414
+ function Dashboard($$payload, $$props) {
415
+ let {
416
+ diamond_count = [],
417
+ diamond_dat = [],
418
+ barData = [],
419
+ test_elem_1 = null,
420
+ test_elem_2 = null,
421
+ height = 815,
422
+ width = 1200,
423
+ DiamondHeight = 600,
424
+ DiamondWidth = 600,
425
+ DiamondInnerHeight = 440,
426
+ margin = { inner: 160, diamond: 40 },
427
+ trueDiamondHeight = 400,
428
+ alpha = 0.58,
429
+ maxlog10 = 0,
430
+ rtd = null,
431
+ title = ["System 1", "System 2"],
432
+ class: className = "",
433
+ style = "",
434
+ showDiamond = true,
435
+ showWordshift = true,
436
+ showDivergingBar = true,
437
+ showLegend = true,
438
+ $$slots,
439
+ $$events,
440
+ ...restProps
441
+ } = $$props;
442
+ $$payload.out += `<div${$.spread_attributes(
443
+ {
444
+ class: `allotaxonometer-dashboard ${$.stringify(className)}`,
445
+ style,
446
+ ...restProps
447
+ },
448
+ "svelte-n6o6ey"
449
+ )}><svg id="allotaxonometer-svg"${$.attr("height", height)}${$.attr("width", width)} class="svelte-n6o6ey">`;
450
+ if (showDiamond) {
451
+ $$payload.out += "<!--[-->";
452
+ Diamond($$payload, {
453
+ diamond_count,
454
+ diamond_dat,
455
+ DiamondInnerHeight,
456
+ margin,
457
+ trueDiamondHeight,
458
+ alpha,
459
+ maxlog10,
460
+ rtd,
461
+ title
462
+ });
463
+ } else {
464
+ $$payload.out += "<!--[!-->";
465
+ }
466
+ $$payload.out += `<!--]-->`;
467
+ if (showWordshift) {
468
+ $$payload.out += "<!--[-->";
469
+ Wordshift($$payload, {
470
+ barData,
471
+ DashboardHeight: height,
472
+ DashboardWidth: width
473
+ });
474
+ } else {
475
+ $$payload.out += "<!--[!-->";
476
+ }
477
+ $$payload.out += `<!--]-->`;
478
+ if (showDivergingBar) {
479
+ $$payload.out += "<!--[-->";
480
+ DivergingBarChart($$payload, {
481
+ test_elem_1,
482
+ test_elem_2,
483
+ DiamondHeight,
484
+ DiamondWidth
485
+ });
486
+ } else {
487
+ $$payload.out += "<!--[!-->";
488
+ }
489
+ $$payload.out += `<!--]-->`;
490
+ if (showLegend) {
491
+ $$payload.out += "<!--[-->";
492
+ Legend($$payload, { diamond_dat, DiamondHeight });
493
+ } else {
494
+ $$payload.out += "<!--[!-->";
495
+ }
496
+ $$payload.out += `<!--]--></svg></div>`;
497
+ }
498
+ export {
499
+ Dashboard,
500
+ Diamond,
501
+ DivergingBarChart,
502
+ Legend,
503
+ Test,
504
+ Wordshift
505
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "allotaxonometer-ui",
3
- "version": "0.1.0",
4
- "description": "Headless UI components for allotaxonometer visualizations",
3
+ "version": "0.1.2",
4
+ "description": "Headless UI components for allotaxonometer visualizations built with Svelte 5",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -10,19 +10,38 @@
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js"
13
- }
13
+ },
14
+ "./ssr": "./dist/ssr/index.js"
14
15
  },
15
- "files": ["dist", "README.md"],
16
- "keywords": ["svelte", "visualization", "allotaxonometer", "dashboard"],
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "keywords": [
22
+ "svelte",
23
+ "svelte5",
24
+ "visualization",
25
+ "allotaxonometer",
26
+ "dashboard",
27
+ "headless-ui",
28
+ "components"
29
+ ],
17
30
  "author": "Your Name <your.email@example.com>",
18
31
  "license": "MIT",
19
32
  "repository": {
20
33
  "type": "git",
21
- "url": "https://github.com/yourusername/allotaxonometer-ui.git"
34
+ "url": "https://github.com/Vermont-Complex-Systems/allotaxonometer-ui.git"
35
+ },
36
+ "homepage": "https://github.com/Vermont-Complex-Systems/allotaxonometer-ui#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/Vermont-Complex-Systems/allotaxonometer-ui/issues"
22
39
  },
23
- "homepage": "https://github.com/yourusername/allotaxonometer-ui#readme",
24
40
  "peerDependencies": {
25
- "svelte": "^5.0.0"
41
+ "svelte": "^5.0.0",
42
+ "d3": "^7.0.0",
43
+ "allotaxonometer": "1.1.11",
44
+ "@ungap/structured-clone": "1.3.0"
26
45
  },
27
46
  "devDependencies": {
28
47
  "@sveltejs/vite-plugin-svelte": "^4.0.0",
@@ -31,8 +50,8 @@
31
50
  "vite": "^5.0.3"
32
51
  },
33
52
  "scripts": {
34
- "dev": "vite",
35
53
  "build": "vite build",
36
- "prepublishOnly": "npm run build"
54
+ "build:ssr": "vite build --config vite.ssr.config.js",
55
+ "build:all": "npm run build && npm run build:ssr"
37
56
  }
38
- }
57
+ }