layerchart 0.41.6 → 0.43.0

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.
Files changed (114) hide show
  1. package/dist/components/Arc.svelte +27 -20
  2. package/dist/components/Arc.svelte.d.ts +2 -2
  3. package/dist/components/Area.svelte +11 -7
  4. package/dist/components/Area.svelte.d.ts +3 -3
  5. package/dist/components/AreaStack.svelte +3 -2
  6. package/dist/components/Axis.svelte +38 -41
  7. package/dist/components/Axis.svelte.d.ts +5 -4
  8. package/dist/components/Bar.svelte +6 -5
  9. package/dist/components/Bar.svelte.d.ts +3 -2
  10. package/dist/components/Bars.svelte +5 -4
  11. package/dist/components/Bars.svelte.d.ts +3 -2
  12. package/dist/components/Bounds.svelte +7 -5
  13. package/dist/components/Bounds.svelte.d.ts +8 -8
  14. package/dist/components/Brush.svelte +8 -6
  15. package/dist/components/Brush.svelte.d.ts +2 -2
  16. package/dist/components/Calendar.svelte +4 -3
  17. package/dist/components/Chart.svelte +72 -86
  18. package/dist/components/Chart.svelte.d.ts +216 -24
  19. package/dist/components/ChartClipPath.svelte +6 -6
  20. package/dist/components/ChartContext.svelte +19 -0
  21. package/dist/components/ChartContext.svelte.d.ts +89 -0
  22. package/dist/components/Circle.svelte +1 -0
  23. package/dist/components/ClipPath.svelte +1 -0
  24. package/dist/components/ForceSimulation.svelte +182 -25
  25. package/dist/components/ForceSimulation.svelte.d.ts +11 -1
  26. package/dist/components/Frame.svelte +8 -7
  27. package/dist/components/Frame.svelte.d.ts +1 -1
  28. package/dist/components/GeoCircle.svelte.d.ts +1 -2
  29. package/dist/components/GeoContext.svelte +2 -1
  30. package/dist/components/GeoContext.svelte.d.ts +5 -5
  31. package/dist/components/GeoEdgeFade.svelte +2 -5
  32. package/dist/components/GeoPath.svelte +9 -5
  33. package/dist/components/GeoPath.svelte.d.ts +7 -4
  34. package/dist/components/GeoPoint.svelte +0 -1
  35. package/dist/components/GeoSpline.svelte +2 -11
  36. package/dist/components/GeoTile.svelte +3 -1
  37. package/dist/components/Group.svelte +4 -2
  38. package/dist/components/Highlight.svelte +16 -10
  39. package/dist/components/Highlight.svelte.d.ts +16 -15
  40. package/dist/components/HitCanvas.svelte +5 -2
  41. package/dist/components/HitCanvas.svelte.d.ts +1 -1
  42. package/dist/components/Hull.svelte +6 -3
  43. package/dist/components/Labels.svelte +5 -4
  44. package/dist/components/Labels.svelte.d.ts +0 -1
  45. package/dist/components/Legend.svelte +4 -4
  46. package/dist/components/Legend.svelte.d.ts +2 -2
  47. package/dist/components/Line.svelte +1 -0
  48. package/dist/components/Link.svelte +3 -1
  49. package/dist/components/Pack.svelte +4 -3
  50. package/dist/components/Partition.svelte +3 -3
  51. package/dist/components/Partition.svelte.d.ts +2 -1
  52. package/dist/components/Pie.svelte +7 -6
  53. package/dist/components/Pie.svelte.d.ts +2 -4
  54. package/dist/components/Point.svelte +2 -2
  55. package/dist/components/Points.svelte +4 -3
  56. package/dist/components/RadialGradient.svelte +2 -2
  57. package/dist/components/RadialGradient.svelte.d.ts +0 -1
  58. package/dist/components/Rect.svelte +1 -0
  59. package/dist/components/Rule.svelte +3 -3
  60. package/dist/components/Sankey.svelte +9 -3
  61. package/dist/components/Sankey.svelte.d.ts +2 -2
  62. package/dist/components/Spline.svelte +9 -6
  63. package/dist/components/Spline.svelte.d.ts +2 -2
  64. package/dist/components/Text.svelte +1 -2
  65. package/dist/components/Threshold.svelte +2 -2
  66. package/dist/components/Threshold.svelte.d.ts +2 -2
  67. package/dist/components/TileImage.svelte +4 -1
  68. package/dist/components/Tooltip.svelte +3 -3
  69. package/dist/components/TooltipContext.svelte +46 -15
  70. package/dist/components/TooltipContext.svelte.d.ts +1 -1
  71. package/dist/components/TooltipItem.svelte.d.ts +1 -1
  72. package/dist/components/TransformContext.svelte +17 -6
  73. package/dist/components/TransformControls.svelte +1 -0
  74. package/dist/components/Tree.svelte +4 -3
  75. package/dist/components/Tree.svelte.d.ts +3 -3
  76. package/dist/components/Treemap.svelte +11 -12
  77. package/dist/components/Treemap.svelte.d.ts +6 -6
  78. package/dist/components/Voronoi.svelte +8 -3
  79. package/dist/components/layout/Canvas.svelte +5 -3
  80. package/dist/components/layout/Html.svelte +3 -3
  81. package/dist/components/layout/Svg.svelte +6 -3
  82. package/dist/docs/Code.svelte +2 -3
  83. package/dist/docs/GeoDebug.svelte +4 -4
  84. package/dist/docs/Link.svelte +2 -4
  85. package/dist/docs/Link.svelte.d.ts +14 -5
  86. package/dist/docs/Preview.svelte +1 -1
  87. package/dist/docs/TilesetField.svelte +1 -1
  88. package/dist/docs/TilesetField.svelte.d.ts +1 -1
  89. package/dist/docs/ViewSourceButton.svelte +4 -4
  90. package/dist/docs/ViewSourceButton.svelte.d.ts +5 -3
  91. package/dist/stores/motionStore.d.ts +2 -2
  92. package/dist/stores/motionStore.js +4 -2
  93. package/dist/utils/array.d.ts +5 -0
  94. package/dist/utils/array.js +7 -0
  95. package/dist/utils/common.d.ts +2 -0
  96. package/dist/utils/common.js +18 -0
  97. package/dist/utils/genData.d.ts +23 -23
  98. package/dist/utils/genData.js +3 -2
  99. package/dist/utils/geo.d.ts +3 -3
  100. package/dist/utils/geo.js +2 -0
  101. package/dist/utils/graph.d.ts +1 -1
  102. package/dist/utils/graph.js +3 -3
  103. package/dist/utils/hierarchy.d.ts +1 -1
  104. package/dist/utils/hierarchy.js +1 -0
  105. package/dist/utils/rect.d.ts +5 -3
  106. package/dist/utils/rect.js +7 -11
  107. package/dist/utils/scales.d.ts +21 -12
  108. package/dist/utils/scales.js +3 -1
  109. package/dist/utils/stack.d.ts +5 -2
  110. package/dist/utils/stack.js +20 -7
  111. package/dist/utils/threshold.js +1 -0
  112. package/dist/utils/treemap.d.ts +5 -2
  113. package/dist/utils/treemap.js +1 -1
  114. package/package.json +6 -3
@@ -1,10 +1,12 @@
1
- <script>import { createEventDispatcher, getContext, onMount, setContext } from 'svelte';
1
+ <script>import { createEventDispatcher, onMount, setContext } from 'svelte';
2
2
  import { writable } from 'svelte/store';
3
3
  import { scaleCanvas } from 'layercake';
4
4
  import { cls } from 'svelte-ux';
5
+ import { chartContext } from './ChartContext.svelte';
5
6
  import Canvas from './layout/Canvas.svelte';
6
7
  import { transformContext } from './TransformContext.svelte';
7
- const { width, height } = getContext('LayerCake');
8
+ const { width, height } = chartContext();
9
+ // @ts-expect-error: this will immediately be defined on mount via `bind:context`
8
10
  export let context = undefined;
9
11
  /** Show canvas for debugging */
10
12
  export let debug = false;
@@ -29,6 +31,7 @@ function* rgbColorGenerator(step = 500) {
29
31
  nextColor += step;
30
32
  yield `rgb(${rgb.join(',')})`;
31
33
  }
34
+ return 'rgb(0,0,0)';
32
35
  }
33
36
  $: colorGenerator = rgbColorGenerator();
34
37
  // Reset color generator whenever updated (width/height) so always reusing same colors (and not exhausting)
@@ -19,7 +19,7 @@ declare const __propDef: {
19
19
  };
20
20
  slots: {
21
21
  default: {
22
- nextColor: () => string | void;
22
+ nextColor: () => string;
23
23
  setColorData: (color: string, data: any) => void;
24
24
  };
25
25
  };
@@ -1,13 +1,15 @@
1
- <script>import { createEventDispatcher, getContext } from 'svelte';
1
+ <script>import { createEventDispatcher } from 'svelte';
2
2
  import { cls } from 'svelte-ux';
3
3
  import { min } from 'd3-array';
4
4
  import { Delaunay } from 'd3-delaunay';
5
+ // @ts-expect-error
5
6
  import { geoVoronoi } from 'd3-geo-voronoi';
7
+ import { curveLinearClosed } from 'd3-shape';
8
+ import { chartContext } from './ChartContext.svelte';
6
9
  import GeoPath from './GeoPath.svelte';
7
10
  import { geoContext } from './GeoContext.svelte';
8
11
  import Spline from './Spline.svelte';
9
- import { curveLinearClosed } from 'd3-shape';
10
- const { flatData, x: xContext, y: yContext } = getContext('LayerCake');
12
+ const { flatData, x: xContext, y: yContext } = chartContext();
11
13
  const geo = geoContext();
12
14
  /** Override data instead of using context */
13
15
  export let data = undefined;
@@ -20,6 +22,7 @@ $: points = (data ?? $flatData).map((d) => {
20
22
  const x = Array.isArray(xValue) ? min(xValue) : xValue;
21
23
  const y = Array.isArray(yValue) ? min(yValue) : yValue;
22
24
  const point = [x, y];
25
+ // @ts-expect-error
23
26
  point.data = d;
24
27
  return point;
25
28
  });
@@ -3,24 +3,25 @@
3
3
  * - [ ] Support step curves (center like scaleBand())
4
4
  * - [ ] Support multiple values (threshold, stacks, etc)
5
5
  */
6
- import { getContext } from 'svelte';
6
+ import {} from 'svelte';
7
7
  import { format as formatValue, cls } from 'svelte-ux';
8
8
  import { greatestAbs } from 'svelte-ux/utils/array';
9
+ const { flatData, yScale, x, y, custom } = chartContext();
9
10
  import Text from './Text.svelte';
10
11
  import { isScaleBand } from '../utils/scales.js';
11
12
  import { createDimensionGetter } from '../utils/rect.js';
12
- const { flatData, yScale, x, y, custom } = getContext('LayerCake');
13
+ import { chartContext } from './ChartContext.svelte';
13
14
  // TODO: Support 'auto' to switch `inside` to `outside` if not enough room
14
15
  export let placement = 'outside';
15
16
  export let offset = 4;
16
- export let significantDigits = 3;
17
17
  export let format = undefined;
18
18
  // export let overlap = false;
19
+ // @ts-expect-error
19
20
  $: yBaseline = $custom?.yBaseline ?? 0;
20
21
  export let groupBy = undefined;
21
22
  export let groupPaddingInner = 0.2;
22
23
  export let groupPaddingOuter = 0;
23
- $: getDimensions = createDimensionGetter(getContext('LayerCake'), {
24
+ $: getDimensions = createDimensionGetter(chartContext(), {
24
25
  // x,
25
26
  // y,
26
27
  groupBy,
@@ -5,7 +5,6 @@ declare const __propDef: {
5
5
  [x: string]: any;
6
6
  placement?: "inside" | "outside";
7
7
  offset?: number;
8
- significantDigits?: number;
9
8
  format?: FormatType | undefined;
10
9
  groupBy?: string | undefined;
11
10
  groupPaddingInner?: number;
@@ -1,11 +1,11 @@
1
- <script>import { getContext } from 'svelte';
2
- import { scaleBand, scaleLinear } from 'd3-scale';
1
+ <script>import { scaleBand, scaleLinear } from 'd3-scale';
3
2
  import { quantize, interpolate, interpolateRound } from 'd3-interpolate';
4
3
  import { quantile, range } from 'd3-array';
5
4
  import { format } from 'svelte-ux';
5
+ import { chartContext } from './ChartContext.svelte';
6
6
  import ColorRamp from './ColorRamp.svelte';
7
7
  import { cls } from 'svelte-ux';
8
- const { rScale } = getContext('LayerCake') ?? {};
8
+ const { rScale } = chartContext() ?? {};
9
9
  export let scale = undefined;
10
10
  export let title = '';
11
11
  export let width = 320;
@@ -123,7 +123,7 @@ else {
123
123
  )}
124
124
  >
125
125
  <div class={cls('text-[10px] font-semibold', classes.title)}>{title}</div>
126
- <slot values={tickValues} {scale}>
126
+ <slot values={tickValues ?? []} {scale}>
127
127
  <svg
128
128
  {width}
129
129
  height={height + tickLength + tickFontSize}
@@ -8,7 +8,7 @@ declare const __propDef: {
8
8
  width?: number;
9
9
  height?: number;
10
10
  ticks?: number;
11
- tickFormat?: FormatType;
11
+ tickFormat?: FormatType | undefined;
12
12
  tickValues?: any[] | undefined;
13
13
  tickFontSize?: number;
14
14
  tickLength?: number;
@@ -25,7 +25,7 @@ declare const __propDef: {
25
25
  };
26
26
  slots: {
27
27
  default: {
28
- values: any[] | undefined;
28
+ values: any[];
29
29
  scale: any;
30
30
  };
31
31
  };
@@ -23,6 +23,7 @@ $: tick().then(() => {
23
23
  });
24
24
  </script>
25
25
 
26
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
26
27
  <line
27
28
  x1={$tweened_x1}
28
29
  y1={$tweened_y1}
@@ -15,17 +15,19 @@ export let x = (d) => (sankey ? d[0] : orientation === 'horizontal' ? d.y : d.x)
15
15
  export let y = (d) => (sankey ? d[1] : orientation === 'horizontal' ? d.x : d.y);
16
16
  export let curve = orientation === 'horizontal' ? curveBumpX : curveBumpY;
17
17
  export let tweened = undefined;
18
+ // @ts-expect-error
18
19
  $: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
19
20
  $: tweened_d = motionStore('', { tweened: tweenedOptions });
20
21
  $: {
21
22
  orientation; // subscribe to orientation changes to update link
22
23
  const link = d3Link(curve).source(source).target(target).x(x).y(y);
23
- const d = link(data);
24
+ const d = link(data) ?? '';
24
25
  tweened_d.set(d);
25
26
  }
26
27
  </script>
27
28
 
28
29
  <!-- svelte-ignore a11y-mouse-events-have-key-events -->
30
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
29
31
  <path
30
32
  class="path-link"
31
33
  d={$tweened_d}
@@ -1,6 +1,6 @@
1
- <script>import { getContext } from 'svelte';
2
- import { pack as d3Pack } from 'd3-hierarchy';
3
- const { data, width, height } = getContext('LayerCake');
1
+ <script>import { pack as d3Pack } from 'd3-hierarchy';
2
+ import { chartContext } from './ChartContext.svelte';
3
+ const { data, width, height } = chartContext();
4
4
  export let size = undefined;
5
5
  /**
6
6
  * see: https://github.com/d3/d3-hierarchy#pack_padding
@@ -13,6 +13,7 @@ $: {
13
13
  pack.padding(padding);
14
14
  }
15
15
  }
16
+ // @ts-expect-error
16
17
  $: packData = pack($data);
17
18
  </script>
18
19
 
@@ -1,6 +1,6 @@
1
- <script>import { getContext } from 'svelte';
2
- import { partition as d3Partition } from 'd3-hierarchy';
3
- const { data, width, height } = getContext('LayerCake');
1
+ <script>import { partition as d3Partition, } from 'd3-hierarchy';
2
+ import { chartContext } from './ChartContext.svelte';
3
+ const { data, width, height } = chartContext();
4
4
  export let orientation = 'horizontal';
5
5
  export let size = undefined;
6
6
  /**
@@ -1,4 +1,5 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import { type HierarchyRectangularNode } from 'd3-hierarchy';
2
3
  declare const __propDef: {
3
4
  props: {
4
5
  orientation?: "vertical" | "horizontal";
@@ -15,7 +16,7 @@ declare const __propDef: {
15
16
  };
16
17
  slots: {
17
18
  default: {
18
- nodes: import("d3-hierarchy").HierarchyRectangularNode<unknown>[];
19
+ nodes: HierarchyRectangularNode<any>[];
19
20
  };
20
21
  };
21
22
  };
@@ -1,7 +1,7 @@
1
- <script>import { getContext } from 'svelte';
2
- import { pie as d3pie } from 'd3-shape';
1
+ <script>import { pie as d3pie } from 'd3-shape';
3
2
  import { min, max } from 'd3-array';
4
3
  import Arc from './Arc.svelte';
4
+ import { chartContext } from './ChartContext.svelte';
5
5
  import Group from './Group.svelte';
6
6
  import { degreesToRadians } from '../utils/math.js';
7
7
  import { motionStore } from '../stores/motionStore.js';
@@ -51,17 +51,18 @@ export let offset = 0;
51
51
  * Tooltip context to setup mouse events to show tooltip for related data
52
52
  */
53
53
  export let tooltip = undefined;
54
- const { data: contextData, x, y, xRange, rGet, config, width, height } = getContext('LayerCake');
54
+ const { data: contextData, x, y, xRange, rGet, config, width, height } = chartContext();
55
+ // @ts-expect-error
55
56
  $: resolved_endAngle = endAngle ?? degreesToRadians($config.xRange ? max($xRange) : max(range));
56
57
  let tweened_endAngle = motionStore(0, { spring, tweened });
57
58
  $: tweened_endAngle.set(resolved_endAngle);
58
59
  $: pie = d3pie()
60
+ // @ts-expect-error
59
61
  .startAngle(startAngle ?? degreesToRadians($config.xRange ? min($xRange) : min(range)))
60
62
  .endAngle($tweened_endAngle)
61
63
  .padAngle(padAngle)
62
64
  .value($x);
63
- $: arcs = pie(data ?? $contextData);
64
- // $: console.log({ arcs, $yRange });
65
+ $: arcs = pie(data ?? (Array.isArray($contextData) ? $contextData : []));
65
66
  $: radius = Math.min($width / 2, $height / 2);
66
67
  $: coords = {
67
68
  x: placement === 'left'
@@ -77,7 +78,7 @@ $: coords = {
77
78
 
78
79
  <Group x={coords.x} y={coords.y}>
79
80
  <slot {arcs}>
80
- {#each arcs as arc, index}
81
+ {#each arcs as arc}
81
82
  <Arc
82
83
  startAngle={arc.startAngle}
83
84
  endAngle={arc.endAngle}
@@ -3,7 +3,7 @@ import type { spring as springStore, tweened as tweenedStore } from 'svelte/moti
3
3
  import type { TooltipContextValue } from './TooltipContext.svelte';
4
4
  declare const __propDef: {
5
5
  props: {
6
- data?: any;
6
+ data?: any[] | undefined;
7
7
  /**
8
8
  * Range [min,max] in degrees. See also startAngle/endAngle
9
9
  */ range?: number[];
@@ -40,9 +40,7 @@ declare const __propDef: {
40
40
  };
41
41
  slots: {
42
42
  default: {
43
- arcs: import("d3-shape").PieArcDatum<number | {
44
- valueOf(): number;
45
- }>[];
43
+ arcs: import("d3-shape").PieArcDatum<any>[];
46
44
  };
47
45
  };
48
46
  };
@@ -1,5 +1,5 @@
1
- <script>import { getContext } from 'svelte';
2
- const context = getContext('LayerCake');
1
+ <script>import { chartContext } from './ChartContext.svelte';
2
+ const context = chartContext();
3
3
  const { xGet, yGet } = context;
4
4
  /** Single data point to translate to x/y */
5
5
  export let d;
@@ -1,11 +1,12 @@
1
- <script>import { getContext } from 'svelte';
1
+ <script>import {} from 'svelte';
2
2
  import { extent } from 'd3-array';
3
+ import { pointRadial } from 'd3-shape';
3
4
  import { notNull } from 'svelte-ux';
5
+ import { chartContext } from './ChartContext.svelte';
4
6
  import Circle from './Circle.svelte';
5
7
  import Link from './Link.svelte';
6
8
  import { isScaleBand } from '../utils/scales.js';
7
- import { pointRadial } from 'd3-shape';
8
- const context = getContext('LayerCake');
9
+ const context = chartContext();
9
10
  const { data: contextData, xGet, y, yGet, xScale, yScale, rGet, config } = context;
10
11
  /** Override data instead of using context */
11
12
  export let data = undefined;
@@ -11,7 +11,8 @@ export let cy = '50%';
11
11
  export let fx = cx;
12
12
  export let fy = cy;
13
13
  export let r = '50%';
14
- export let fr = '0%';
14
+ // TODO: Svelte / Typescript does not know `<radialRadiant fr="...">`
15
+ // export let fr = '0%';
15
16
  /** Indicates how the gradient behaves if it starts or ends inside the bounds of the shape containing the gradient */
16
17
  export let spreadMethod = 'pad';
17
18
  export let transform = undefined;
@@ -27,7 +28,6 @@ export let units = 'objectBoundingBox';
27
28
  {fx}
28
29
  {fy}
29
30
  {r}
30
- {fr}
31
31
  {spreadMethod}
32
32
  gradientTransform={transform}
33
33
  gradientUnits={units}
@@ -9,7 +9,6 @@ declare const __propDef: {
9
9
  fx?: string;
10
10
  fy?: string;
11
11
  r?: string;
12
- fr?: string;
13
12
  spreadMethod?: "pad" | "reflect" | "repeat";
14
13
  transform?: string | null | undefined;
15
14
  units?: "objectBoundingBox" | "userSpaceOnUse";
@@ -24,6 +24,7 @@ $: tick().then(() => {
24
24
  </script>
25
25
 
26
26
  <!-- svelte-ignore a11y-mouse-events-have-key-events -->
27
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
27
28
  <rect
28
29
  x={$tweened_x}
29
30
  y={$tweened_y}
@@ -1,8 +1,8 @@
1
- <script>import { getContext } from 'svelte';
1
+ <script>import { extent } from 'd3-array';
2
2
  import { cls } from 'svelte-ux';
3
- import { extent } from 'd3-array';
3
+ import { chartContext } from './ChartContext.svelte';
4
4
  import Line from './Line.svelte';
5
- const { xScale, yScale, xRange, yRange } = getContext('LayerCake');
5
+ const { xScale, yScale, xRange, yRange } = chartContext();
6
6
  $: [xRangeMin, xRangeMax] = extent($xRange);
7
7
  $: [yRangeMin, yRangeMax] = extent($yRange);
8
8
  /**
@@ -1,8 +1,9 @@
1
1
  <script>// https://github.com/d3/d3-sankey
2
- import { createEventDispatcher, getContext } from 'svelte';
2
+ import { createEventDispatcher } from 'svelte';
3
3
  import { sankey as d3Sankey, sankeyLeft, sankeyCenter, sankeyRight, sankeyJustify, } from 'd3-sankey';
4
+ import { chartContext } from './ChartContext.svelte';
4
5
  const dispatch = createEventDispatcher();
5
- const { data, width, height, padding } = getContext('LayerCake');
6
+ const { data, width, height } = chartContext();
6
7
  export let nodes = (d) => d.nodes;
7
8
  export let nodeId = (d) => d.index;
8
9
  /**
@@ -29,11 +30,16 @@ $: sankey = d3Sankey()
29
30
  : nodeAlign)
30
31
  .nodeWidth(nodeWidth)
31
32
  .nodePadding(nodePadding)
33
+ // @ts-expect-error
32
34
  .nodeSort(nodeSort)
33
35
  .links(links)
36
+ // @ts-expect-error
34
37
  .linkSort(linkSort);
38
+ // @ts-expect-error
35
39
  $: sankeyData = sankey($data);
40
+ $: _nodes = sankeyData.nodes;
41
+ $: _links = sankeyData.links;
36
42
  $: dispatch('update', sankeyData);
37
43
  </script>
38
44
 
39
- <slot nodes={sankeyData.nodes} links={sankeyData.links} />
45
+ <slot nodes={_nodes} links={_links} />
@@ -20,8 +20,8 @@ declare const __propDef: {
20
20
  };
21
21
  slots: {
22
22
  default: {
23
- nodes: import("d3-sankey").SankeyNodeMinimal<{}, {}>[];
24
- links: import("d3-sankey").SankeyLinkMinimal<{}, {}>[];
23
+ nodes: SankeyNode<Record<string, any>, any>[];
24
+ links: any[];
25
25
  };
26
26
  };
27
27
  };
@@ -1,4 +1,4 @@
1
- <script>import { getContext, tick } from 'svelte';
1
+ <script>import { tick } from 'svelte';
2
2
  import { writable } from 'svelte/store';
3
3
  import { tweened as tweenedStore } from 'svelte/motion';
4
4
  import { draw as _drawTransition } from 'svelte/transition';
@@ -7,9 +7,10 @@ import { line as d3Line, lineRadial } from 'd3-shape';
7
7
  // import { interpolateString } from 'd3-interpolate';
8
8
  import { interpolatePath } from 'd3-interpolate-path';
9
9
  import { cls } from 'svelte-ux';
10
- import { motionStore } from '../stores/motionStore.js';
10
+ import { chartContext } from './ChartContext.svelte';
11
11
  import Group from './Group.svelte';
12
- const { data: contextData, xScale, yScale, x: contextX, y: contextY } = getContext('LayerCake');
12
+ import { motionStore } from '../stores/motionStore.js';
13
+ const { data: contextData, xScale, yScale, x: contextX, y: contextY } = chartContext();
13
14
  /** Override data instead of using context */
14
15
  export let data = undefined;
15
16
  /** Pass `<path d={...} />` explicitly instead of calculating from data / context */
@@ -46,6 +47,7 @@ function getScaleValue(data, scale, accessor) {
46
47
  }
47
48
  }
48
49
  let d = '';
50
+ // @ts-expect-error
49
51
  $: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
50
52
  $: tweened_d = motionStore('', { tweened: tweenedOptions });
51
53
  $: {
@@ -60,7 +62,7 @@ $: {
60
62
  path.curve(curve);
61
63
  if (defined)
62
64
  path.defined(defined);
63
- d = pathData ?? path(data ?? $contextData);
65
+ d = pathData ?? path(data ?? $contextData) ?? '';
64
66
  tweened_d.set(d);
65
67
  }
66
68
  $: drawTransition = draw ? _drawTransition : () => ({});
@@ -79,8 +81,8 @@ $: endPoint = motionStore(undefined, {
79
81
  easing: (typeof draw === 'object' && draw.easing) || cubicInOut,
80
82
  interpolate(a, b) {
81
83
  return (t) => {
82
- const totalLength = pathEl.getTotalLength();
83
- const point = pathEl.getPointAtLength(totalLength * t);
84
+ const totalLength = pathEl?.getTotalLength() ?? 0;
85
+ const point = pathEl?.getPointAtLength(totalLength * t);
84
86
  return point;
85
87
  };
86
88
  },
@@ -103,6 +105,7 @@ $: {
103
105
  </script>
104
106
 
105
107
  {#key key}
108
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
106
109
  <path
107
110
  d={$tweened_d}
108
111
  {...$$restProps}
@@ -8,8 +8,8 @@ declare const __propDef: {
8
8
  data?: any;
9
9
  pathData?: string | undefined | null;
10
10
  radial?: boolean;
11
- x?: any;
12
- y?: any;
11
+ x?: ((d: any) => any) | undefined;
12
+ y?: ((d: any) => any) | undefined;
13
13
  tweened?: boolean | Parameters<typeof tweenedStore>[1];
14
14
  draw?: boolean | Parameters<typeof _drawTransition>[1];
15
15
  curve?: CurveFactory | CurveFactoryLineOnly | undefined;
@@ -73,9 +73,8 @@ $: lines = wordsByLines.length;
73
73
  */
74
74
  function getPixelValue(cssValue) {
75
75
  // TODO: Properly measure pixel values using DOM (handle inherited font size, zoom, etc)
76
- // console.log(cssValue);
76
+ // @ts-expect-error
77
77
  const [match, value, units] = cssValue.match(/([\d.]+)(\D+)/);
78
- // console.log({ value, units });
79
78
  const number = Number(value);
80
79
  switch (units) {
81
80
  case 'px':
@@ -3,10 +3,10 @@
3
3
  - https://observablehq.com/@d3/difference-chart
4
4
  - https://github.com/airbnb/visx/issues/245
5
5
  */
6
- import { getContext } from 'svelte';
7
6
  import { area as d3Area, line as d3Line } from 'd3-shape';
8
7
  import { min, max } from 'd3-array';
9
- const { data: contextData, xGet, yGet, yRange } = getContext('LayerCake');
8
+ import { chartContext } from './ChartContext.svelte';
9
+ const { data: contextData, xGet, yGet, yRange } = chartContext();
10
10
  // Properties to override what is used from context
11
11
  export let data = undefined; // TODO: Update Type
12
12
  export let x = undefined; // TODO: Update Type
@@ -6,12 +6,12 @@ declare const __propDef: {
6
6
  x?: any;
7
7
  y0?: any;
8
8
  y1?: any;
9
- curve?: CurveFactory;
9
+ curve?: CurveFactory | undefined;
10
10
  defined?: Parameters<{
11
11
  (): (d: [number, number], index: number, data: [number, number][]) => boolean;
12
12
  (defined: boolean): import("d3-shape").Area<[number, number]>;
13
13
  (defined: (d: [number, number], index: number, data: [number, number][]) => boolean): import("d3-shape").Area<[number, number]>;
14
- }>[0];
14
+ }>[0] | undefined;
15
15
  id?: string;
16
16
  };
17
17
  events: {
@@ -32,8 +32,11 @@ function loadImage(url) {
32
32
  img.onload = function () {
33
33
  var canvas = document.createElement('canvas');
34
34
  var context = canvas.getContext('2d');
35
+ // @ts-expect-error
35
36
  canvas.height = this.naturalHeight;
37
+ // @ts-expect-error
36
38
  canvas.width = this.naturalWidth;
39
+ // @ts-expect-error
37
40
  context.drawImage(this, 0, 0);
38
41
  var dataUri = canvas.toDataURL('image/jpeg');
39
42
  // console.log('from load', { x, y, z });
@@ -41,7 +44,7 @@ function loadImage(url) {
41
44
  resolve(dataUri);
42
45
  };
43
46
  img.onerror = (err) => {
44
- cache.delete(key);
47
+ tileCache.delete(key);
45
48
  reject(err);
46
49
  };
47
50
  img.src = url;
@@ -1,6 +1,6 @@
1
- <script>import { getContext } from 'svelte';
2
- import { fade } from 'svelte/transition';
1
+ <script>import { fade } from 'svelte/transition';
3
2
  import { cls } from 'svelte-ux';
3
+ import { chartContext } from './ChartContext.svelte';
4
4
  import { tooltipContext } from './TooltipContext.svelte';
5
5
  import { motionStore } from '../stores/motionStore.js';
6
6
  /** `x` position of tooltip. By default uses the pointer/mouse, can also snap to data or an explicit fixed position. */
@@ -18,7 +18,7 @@ export let variant = 'default';
18
18
  export let motion = true;
19
19
  export let header = undefined;
20
20
  export let classes = {};
21
- const { padding, xGet, yGet, containerWidth, containerHeight } = getContext('LayerCake');
21
+ const { padding, xGet, yGet, containerWidth, containerHeight } = chartContext();
22
22
  const tooltip = tooltipContext();
23
23
  let tooltipWidth = 0;
24
24
  let tooltipHeight = 0;