svelteplot 0.8.1 → 0.9.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/README.md +1 -1
  2. package/dist/Mark.svelte +1 -1
  3. package/dist/Mark.svelte.d.ts +1 -0
  4. package/dist/constants.d.ts +2 -0
  5. package/dist/constants.js +2 -0
  6. package/dist/core/Plot.svelte +4 -4
  7. package/dist/helpers/projection.js +7 -2
  8. package/dist/hooks/usePlot.svelte.d.ts +51 -0
  9. package/dist/hooks/usePlot.svelte.js +90 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/marks/Area.svelte +3 -5
  13. package/dist/marks/Area.svelte.d.ts +1 -0
  14. package/dist/marks/AreaX.svelte.d.ts +1 -0
  15. package/dist/marks/Arrow.svelte +3 -5
  16. package/dist/marks/Arrow.svelte.d.ts +1 -0
  17. package/dist/marks/AxisX.svelte +2 -3
  18. package/dist/marks/AxisX.svelte.d.ts +1 -0
  19. package/dist/marks/AxisY.svelte +3 -4
  20. package/dist/marks/AxisY.svelte.d.ts +1 -0
  21. package/dist/marks/BarX.svelte +2 -4
  22. package/dist/marks/BarX.svelte.d.ts +1 -0
  23. package/dist/marks/BarY.svelte +2 -4
  24. package/dist/marks/BarY.svelte.d.ts +1 -0
  25. package/dist/marks/BollingerX.svelte.d.ts +1 -0
  26. package/dist/marks/BollingerY.svelte.d.ts +1 -0
  27. package/dist/marks/BoxX.svelte +4 -138
  28. package/dist/marks/BoxY.svelte +20 -137
  29. package/dist/marks/BoxY.svelte.d.ts +8 -3
  30. package/dist/marks/Brush.svelte +3 -3
  31. package/dist/marks/Brush.svelte.d.ts +1 -0
  32. package/dist/marks/Cell.svelte +2 -4
  33. package/dist/marks/Cell.svelte.d.ts +1 -0
  34. package/dist/marks/ColorLegend.svelte +2 -4
  35. package/dist/marks/CustomMark.svelte.d.ts +1 -0
  36. package/dist/marks/CustomMarkHTML.svelte +5 -10
  37. package/dist/marks/DifferenceY.svelte +3 -5
  38. package/dist/marks/DifferenceY.svelte.d.ts +1 -0
  39. package/dist/marks/Dot.svelte +4 -5
  40. package/dist/marks/Dot.svelte.d.ts +1 -0
  41. package/dist/marks/DotX.svelte.d.ts +1 -0
  42. package/dist/marks/DotY.svelte.d.ts +1 -0
  43. package/dist/marks/Frame.svelte +3 -9
  44. package/dist/marks/Frame.svelte.d.ts +1 -0
  45. package/dist/marks/Geo.svelte +5 -5
  46. package/dist/marks/Geo.svelte.d.ts +2 -0
  47. package/dist/marks/GridX.svelte +3 -10
  48. package/dist/marks/GridX.svelte.d.ts +1 -0
  49. package/dist/marks/GridY.svelte +3 -4
  50. package/dist/marks/GridY.svelte.d.ts +1 -0
  51. package/dist/marks/HTMLTooltip.svelte +5 -5
  52. package/dist/marks/Image.svelte.d.ts +1 -0
  53. package/dist/marks/Line.svelte +7 -6
  54. package/dist/marks/Line.svelte.d.ts +1 -0
  55. package/dist/marks/LineX.svelte.d.ts +1 -0
  56. package/dist/marks/LineY.svelte.d.ts +1 -0
  57. package/dist/marks/Link.svelte +2 -4
  58. package/dist/marks/Link.svelte.d.ts +1 -0
  59. package/dist/marks/Pointer.svelte +4 -4
  60. package/dist/marks/Rect.svelte +2 -4
  61. package/dist/marks/Rect.svelte.d.ts +1 -0
  62. package/dist/marks/RectX.svelte +4 -4
  63. package/dist/marks/RectY.svelte +4 -4
  64. package/dist/marks/RuleX.svelte +2 -4
  65. package/dist/marks/RuleX.svelte.d.ts +1 -0
  66. package/dist/marks/RuleY.svelte +2 -4
  67. package/dist/marks/RuleY.svelte.d.ts +1 -0
  68. package/dist/marks/Spike.svelte.d.ts +1 -0
  69. package/dist/marks/SymbolLegend.svelte +2 -4
  70. package/dist/marks/SymbolLegend.svelte.d.ts +17 -2
  71. package/dist/marks/Text.svelte.d.ts +1 -0
  72. package/dist/marks/TickX.svelte +2 -3
  73. package/dist/marks/TickX.svelte.d.ts +1 -0
  74. package/dist/marks/TickY.svelte +2 -3
  75. package/dist/marks/TickY.svelte.d.ts +1 -0
  76. package/dist/marks/Trail.svelte +161 -0
  77. package/dist/marks/Trail.svelte.d.ts +107 -0
  78. package/dist/marks/Vector.svelte +3 -4
  79. package/dist/marks/Vector.svelte.d.ts +1 -0
  80. package/dist/marks/WaffleX.svelte +2 -3
  81. package/dist/marks/WaffleX.svelte.d.ts +1 -0
  82. package/dist/marks/WaffleY.svelte +2 -4
  83. package/dist/marks/WaffleY.svelte.d.ts +1 -0
  84. package/dist/marks/helpers/AreaCanvas.svelte +2 -4
  85. package/dist/marks/helpers/Box.svelte +271 -0
  86. package/dist/marks/helpers/Box.svelte.d.ts +118 -0
  87. package/dist/marks/helpers/CanvasLayer.svelte +2 -4
  88. package/dist/marks/helpers/DotCanvas.svelte +3 -5
  89. package/dist/marks/helpers/GeoCanvas.svelte +2 -4
  90. package/dist/marks/helpers/LineCanvas.svelte +2 -4
  91. package/dist/marks/helpers/LinearGradientX.svelte +3 -4
  92. package/dist/marks/helpers/LinearGradientY.svelte +3 -4
  93. package/dist/marks/helpers/MarkerPath.svelte +4 -5
  94. package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -0
  95. package/dist/marks/helpers/MultilineText.svelte +4 -4
  96. package/dist/marks/helpers/RectPath.svelte +5 -6
  97. package/dist/marks/helpers/Regression.svelte +4 -8
  98. package/dist/marks/helpers/TrailCanvas.svelte +138 -0
  99. package/dist/marks/helpers/TrailCanvas.svelte.d.ts +40 -0
  100. package/dist/marks/helpers/events.d.ts +2 -2
  101. package/dist/marks/helpers/events.js +4 -4
  102. package/dist/marks/helpers/trail.d.ts +23 -0
  103. package/dist/marks/helpers/trail.js +372 -0
  104. package/dist/marks/index.d.ts +1 -0
  105. package/dist/marks/index.js +1 -0
  106. package/dist/transforms/bollinger.d.ts +1 -0
  107. package/dist/transforms/interval.d.ts +2 -0
  108. package/dist/transforms/select.d.ts +7 -0
  109. package/dist/transforms/sort.d.ts +4 -0
  110. package/dist/transforms/window.d.ts +2 -0
  111. package/dist/types/mark.d.ts +2 -1
  112. package/dist/types/plot.d.ts +6 -1
  113. package/dist/ui/Spiral.svelte +4 -0
  114. package/package.json +24 -23
@@ -21,11 +21,10 @@
21
21
  * radius for point features
22
22
  */
23
23
  r?: ChannelAccessor<Datum>;
24
+ svgFilter?: ConstantAccessor<string | undefined, Datum>;
24
25
  }
25
- import { getContext } from 'svelte';
26
26
  import type {
27
27
  DataRecord,
28
- PlotContext,
29
28
  BaseMarkProps,
30
29
  ConstantAccessor,
31
30
  LinkableMarkProps,
@@ -42,9 +41,9 @@
42
41
  import { GEOJSON_PREFER_STROKE } from '../helpers/index.js';
43
42
  import Anchor from './helpers/Anchor.svelte';
44
43
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
44
+ import { usePlot } from '../hooks/usePlot.svelte.js';
45
45
 
46
- const { getPlotState } = getContext<PlotContext>('svelteplot');
47
- const plot = $derived(getPlotState());
46
+ const plot = usePlot();
48
47
 
49
48
  let markProps: GeoMarkProps = $props();
50
49
 
@@ -111,8 +110,9 @@
111
110
  d={path(geometry)}
112
111
  {style}
113
112
  class={[styleClass]}
113
+ filter={resolveProp(args.svgFilter, d.datum, undefined)}
114
114
  {@attach addEventHandlers({
115
- getPlotState,
115
+ plot,
116
116
  options: args,
117
117
  datum: d?.datum
118
118
  })}>
@@ -26,6 +26,7 @@ declare function $$render<Datum = DataRecord | GeoJSON.GeoJsonObject>(): {
26
26
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: ConstantAccessor<string, Datum>;
30
31
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: ConstantAccessor<string, Datum>;
@@ -83,6 +84,7 @@ declare function $$render<Datum = DataRecord | GeoJSON.GeoJsonObject>(): {
83
84
  * radius for point features
84
85
  */
85
86
  r?: ChannelAccessor<Datum>;
87
+ svgFilter?: ConstantAccessor<string | undefined, Datum>;
86
88
  };
87
89
  exports: {};
88
90
  bindings: "";
@@ -8,15 +8,8 @@
8
8
  y1?: ChannelAccessor<Datum>;
9
9
  y2?: ChannelAccessor<Datum>;
10
10
  }
11
- import { getContext } from 'svelte';
12
11
  import Mark from '../Mark.svelte';
13
- import type {
14
- PlotContext,
15
- BaseMarkProps,
16
- RawValue,
17
- DataRecord,
18
- ChannelAccessor
19
- } from '../types/index.js';
12
+ import type { BaseMarkProps, RawValue, DataRecord, ChannelAccessor } from '../types/index.js';
20
13
  import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
21
14
  import { autoTicks } from '../helpers/autoTicks.js';
22
15
  import { testFilter } from '../helpers/index.js';
@@ -24,6 +17,7 @@
24
17
  import isDataRecord from '../helpers/isDataRecord';
25
18
  import { INDEX } from '../constants';
26
19
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
20
+ import { usePlot } from '../hooks/usePlot.svelte.js';
27
21
 
28
22
  let markProps: GridXMarkProps = $props();
29
23
 
@@ -41,8 +35,7 @@
41
35
  ...markProps
42
36
  });
43
37
 
44
- const { getPlotState } = getContext<PlotContext>('svelteplot');
45
- const plot = $derived(getPlotState());
38
+ const plot = usePlot();
46
39
 
47
40
  const autoTickCount = $derived(
48
41
  Math.max(3, Math.round(plot.facetWidth / plot.options.x.tickSpacing))
@@ -26,6 +26,7 @@ declare function $$render<Datum = RawValue>(): {
26
26
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
30
31
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
@@ -8,14 +8,14 @@
8
8
  x1?: ChannelAccessor<Datum>;
9
9
  x2?: ChannelAccessor<Datum>;
10
10
  }
11
- import { getContext } from 'svelte';
12
11
  import Mark from '../Mark.svelte';
13
- import type { PlotContext, BaseMarkProps, RawValue, ChannelAccessor } from '../types/index.js';
12
+ import type { BaseMarkProps, RawValue, ChannelAccessor } from '../types/index.js';
14
13
  import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
15
14
  import { autoTicks } from '../helpers/autoTicks.js';
16
15
  import { testFilter } from '../helpers/index.js';
17
16
  import { RAW_VALUE } from '../transforms/recordize.js';
18
17
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
18
+ import { usePlot } from '../hooks/usePlot.svelte.js';
19
19
 
20
20
  let markProps: GridYMarkProps = $props();
21
21
 
@@ -33,8 +33,7 @@
33
33
  ...markProps
34
34
  });
35
35
 
36
- const { getPlotState } = getContext<PlotContext>('svelteplot');
37
- const plot = $derived(getPlotState());
36
+ const plot = usePlot();
38
37
 
39
38
  const autoTickCount = $derived(
40
39
  Math.max(2, Math.round(plot.facetHeight / plot.options.y.tickSpacing))
@@ -26,6 +26,7 @@ declare function $$render<Datum = RawValue>(): {
26
26
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
30
31
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
@@ -12,17 +12,17 @@
12
12
  fy?: ChannelAccessor<Datum>;
13
13
  children: Snippet<[{ datum: Datum }]>;
14
14
  }
15
- import { getContext, type Snippet } from 'svelte';
16
- import type { ChannelAccessor, DataRow, PlotContext } from '../types/index.js';
17
-
18
- const { getPlotState } = getContext<PlotContext>('svelteplot');
19
- let plot = $derived(getPlotState());
15
+ import { type Snippet } from 'svelte';
16
+ import type { ChannelAccessor, DataRow } from '../types/index.js';
17
+ import { usePlot } from '../hooks/usePlot.svelte.js';
20
18
 
21
19
  import { resolveChannel } from '../helpers/resolve.js';
22
20
  import { quadtree } from 'd3-quadtree';
23
21
  import { projectX, projectY } from '../helpers/scales.js';
24
22
  import { groupFacetsAndZ } from '../helpers/group.js';
25
23
 
24
+ const plot = usePlot();
25
+
26
26
  let { data, x, y, r, fx, fy, children }: HTMLTooltipMarkProps = $props();
27
27
 
28
28
  let datum = $state(false);
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
26
26
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: ConstantAccessor<string, Datum>;
30
31
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: ConstantAccessor<string, Datum>;
@@ -23,7 +23,6 @@
23
23
  }
24
24
  import type {
25
25
  CurveName,
26
- PlotContext,
27
26
  DataRecord,
28
27
  BaseMarkProps,
29
28
  ConstantAccessor,
@@ -33,7 +32,6 @@
33
32
  } from '../types/index.js';
34
33
  import Mark from '../Mark.svelte';
35
34
  import MarkerPath from './helpers/MarkerPath.svelte';
36
- import { getContext } from 'svelte';
37
35
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
38
36
  import { line, type CurveFactory, type Line as D3Line } from 'd3-shape';
39
37
  import { geoPath } from 'd3-geo';
@@ -48,6 +46,7 @@
48
46
  import { recordizeXY } from '../transforms/recordize.js';
49
47
  import GroupMultiple from './helpers/GroupMultiple.svelte';
50
48
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
49
+ import { usePlot } from '../hooks/usePlot.svelte.js';
51
50
 
52
51
  let markProps: LineMarkProps = $props();
53
52
 
@@ -76,7 +75,10 @@
76
75
 
77
76
  const args = $derived(sort(recordizeXY({ data, ...options })));
78
77
 
79
- function groupIndex(data: ScaledDataRecord[], groupByKey) {
78
+ /**
79
+ * Groups the data by the specified key
80
+ */
81
+ function groupIndex(data: ScaledDataRecord[], groupByKey: ChannelAccessor<Datum> | null) {
80
82
  if (!groupByKey) return [data];
81
83
  let group = [];
82
84
  const groups = [group];
@@ -95,10 +97,9 @@
95
97
  return groups;
96
98
  }
97
99
 
98
- const groupByKey = $derived(args.z || args.stroke);
100
+ const groupByKey = $derived(args.z || args.stroke) as ChannelAccessor<Datum> | null;
99
101
 
100
- const { getPlotState } = getContext<PlotContext>('svelteplot');
101
- const plot = $derived(getPlotState());
102
+ const plot = usePlot();
102
103
 
103
104
  const linePath: D3Line<ScaledDataRecord> = $derived(
104
105
  plot.scales.projection && curve === 'auto'
@@ -28,6 +28,7 @@ declare function $$render<Datum extends DataRecord>(): {
28
28
  strokeDashoffset: ConstantAccessor<number, Datum>;
29
29
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
30
30
  clipPath: string;
31
+ mask: string;
31
32
  imageFilter: ConstantAccessor<string, Datum>;
32
33
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
33
34
  paintOrder: ConstantAccessor<string, Datum>;
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
26
26
  strokeDashoffset: import("../types").ConstantAccessor<number, Record<string | symbol, import("../types").RawValue>>;
27
27
  mixBlendMode: import("../types").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types").RawValue>>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
30
31
  shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types").RawValue>>;
31
32
  paintOrder: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
26
26
  strokeDashoffset: import("../types").ConstantAccessor<number, Record<string | symbol, import("../types").RawValue>>;
27
27
  mixBlendMode: import("../types").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types").RawValue>>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
30
31
  shapeRendering: import("../types").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types").RawValue>>;
31
32
  paintOrder: import("../types").ConstantAccessor<string, Record<string | symbol, import("../types").RawValue>>;
@@ -34,9 +34,7 @@
34
34
  */
35
35
  text?: ConstantAccessor<string, Datum>;
36
36
  }
37
- import { getContext } from 'svelte';
38
37
  import type {
39
- PlotContext,
40
38
  DataRecord,
41
39
  BaseMarkProps,
42
40
  ConstantAccessor,
@@ -58,6 +56,7 @@
58
56
  import { sort } from '../transforms/sort.js';
59
57
  import { indexData } from '../transforms/recordize.js';
60
58
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
59
+ import { usePlot } from '../hooks/usePlot.svelte.js';
61
60
 
62
61
  let markProps: LinkMarkProps = $props();
63
62
  const DEFAULTS = {
@@ -75,8 +74,7 @@
75
74
  ...markProps
76
75
  });
77
76
 
78
- const { getPlotState } = getContext<PlotContext>('svelteplot');
79
- let plot = $derived(getPlotState());
77
+ const plot = usePlot();
80
78
 
81
79
  const args = $derived(
82
80
  replaceChannels(
@@ -27,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
27
27
  strokeDashoffset: ConstantAccessor<number, Datum>;
28
28
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
29
29
  clipPath: string;
30
+ mask: string;
30
31
  imageFilter: ConstantAccessor<string, Datum>;
31
32
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
32
33
  paintOrder: ConstantAccessor<string, Datum>;
@@ -23,8 +23,8 @@
23
23
  onupdate?: (data: Datum[]) => void;
24
24
  }
25
25
 
26
- import { getContext, type Snippet } from 'svelte';
27
- import type { ChannelAccessor, DataRow, PlotContext } from '../types/index.js';
26
+ import { type Snippet } from 'svelte';
27
+ import type { ChannelAccessor, DataRow } from '../types/index.js';
28
28
  import { resolveChannel } from '../helpers/resolve.js';
29
29
  import { quadtree } from 'd3-quadtree';
30
30
  import { projectXY } from '../helpers/scales.js';
@@ -32,9 +32,9 @@
32
32
  import { indexData, RAW_VALUE } from '../transforms/recordize.js';
33
33
  import { groupFacetsAndZ } from '../helpers/group.js';
34
34
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
35
+ import { usePlot } from '../hooks/usePlot.svelte.js';
35
36
 
36
- const { getPlotState } = getContext<PlotContext>('svelteplot');
37
- const plot = $derived(getPlotState());
37
+ const plot = usePlot();
38
38
 
39
39
  const POINTER_X = Symbol('pointerX');
40
40
  const POINTER_Y = Symbol('pointerY');
@@ -16,10 +16,8 @@
16
16
  className?: string;
17
17
  }
18
18
  import Mark from '../Mark.svelte';
19
- import { getContext } from 'svelte';
20
19
  import { intervalX, intervalY } from '../index.js';
21
20
  import type {
22
- PlotContext,
23
21
  DataRecord,
24
22
  BaseMarkProps,
25
23
  BaseRectMarkProps,
@@ -30,6 +28,7 @@
30
28
  import RectPath from './helpers/RectPath.svelte';
31
29
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
32
30
  import { IS_SORTED } from '../transforms/sort';
31
+ import { usePlot } from '../hooks/usePlot.svelte.js';
33
32
 
34
33
  let markProps: RectMarkProps = $props();
35
34
 
@@ -46,8 +45,7 @@
46
45
  ...markProps
47
46
  });
48
47
 
49
- const { getPlotState } = getContext<PlotContext>('svelteplot');
50
- let plot = $derived(getPlotState());
48
+ const plot = usePlot();
51
49
 
52
50
  const args = $derived(
53
51
  intervalY(intervalX({ data, ...options }, { plot }), { plot }) as RectMarkProps
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
26
26
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
30
31
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
@@ -9,10 +9,11 @@
9
9
 
10
10
  import Rect from './Rect.svelte';
11
11
  import { intervalY, stackX, recordizeX } from '../index.js';
12
- import type { DataRecord, PlotContext } from '../types/index.js';
13
- import { getContext, type ComponentProps } from 'svelte';
12
+ import type { DataRecord } from '../types/index.js';
13
+ import { type ComponentProps } from 'svelte';
14
14
  import type { StackOptions } from '../transforms/stack.js';
15
15
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
16
+ import { usePlot } from '../hooks/usePlot.svelte.js';
16
17
 
17
18
  let markProps: RectXMarkProps = $props();
18
19
 
@@ -30,8 +31,7 @@
30
31
  ...markProps
31
32
  });
32
33
 
33
- const { getPlotState } = getContext<PlotContext>('svelteplot');
34
- let plot = $derived(getPlotState());
34
+ const plot = usePlot();
35
35
 
36
36
  const args = $derived(stackX(intervalY(recordizeX({ data, ...options }), { plot }), stack));
37
37
  </script>
@@ -7,10 +7,11 @@
7
7
  }
8
8
  import Rect from './Rect.svelte';
9
9
  import { intervalX, stackY, recordizeY } from '../index.js';
10
- import type { DataRecord, PlotContext } from '../types/index.js';
11
- import { getContext, type ComponentProps } from 'svelte';
10
+ import type { DataRecord } from '../types/index.js';
11
+ import { type ComponentProps } from 'svelte';
12
12
  import type { StackOptions } from '../transforms/stack.js';
13
13
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
14
+ import { usePlot } from '../hooks/usePlot.svelte.js';
14
15
 
15
16
  let markProps: RectYMarkProps = $props();
16
17
 
@@ -28,8 +29,7 @@
28
29
  ...markProps
29
30
  });
30
31
 
31
- const { getPlotState } = getContext<PlotContext>('svelteplot');
32
- const plot = $derived(getPlotState());
32
+ const plot = usePlot();
33
33
 
34
34
  const args = $derived(stackY(intervalX(recordizeY({ data, ...options }), { plot }), stack));
35
35
  </script>
@@ -13,11 +13,9 @@
13
13
  }
14
14
  import Mark from '../Mark.svelte';
15
15
  import GroupMultiple from './helpers/GroupMultiple.svelte';
16
- import { getContext } from 'svelte';
17
16
  import { recordizeX } from '../transforms/recordize.js';
18
17
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
19
18
  import type {
20
- PlotContext,
21
19
  DataRecord,
22
20
  BaseMarkProps,
23
21
  ConstantAccessor,
@@ -25,6 +23,7 @@
25
23
  RawValue
26
24
  } from '../types/index.js';
27
25
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
26
+ import { usePlot } from '../hooks/usePlot.svelte.js';
28
27
 
29
28
  let markProps: RuleXMarkProps = $props();
30
29
  const DEFAULTS = {
@@ -40,8 +39,7 @@
40
39
  ...markProps
41
40
  });
42
41
 
43
- const { getPlotState } = getContext<PlotContext>('svelteplot');
44
- const plot = $derived(getPlotState());
42
+ const plot = usePlot();
45
43
  const args = $derived(recordizeX({ data, ...options }, { withIndex: false }));
46
44
  </script>
47
45
 
@@ -26,6 +26,7 @@ declare function $$render<Datum = DataRecord | RawValue>(): {
26
26
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: ConstantAccessor<string, Datum>;
30
31
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: ConstantAccessor<string, Datum>;
@@ -13,11 +13,9 @@
13
13
  }
14
14
  import Mark from '../Mark.svelte';
15
15
  import GroupMultiple from './helpers/GroupMultiple.svelte';
16
- import { getContext } from 'svelte';
17
16
  import { recordizeY } from '../transforms/recordize.js';
18
17
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
19
18
  import type {
20
- PlotContext,
21
19
  DataRecord,
22
20
  BaseMarkProps,
23
21
  ConstantAccessor,
@@ -25,6 +23,7 @@
25
23
  } from '../types/index.js';
26
24
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
27
25
  import { IS_SORTED } from '../transforms/sort';
26
+ import { usePlot } from '../hooks/usePlot.svelte.js';
28
27
 
29
28
  let markProps: RuleYMarkProps = $props();
30
29
  const DEFAULTS = {
@@ -40,8 +39,7 @@
40
39
  ...markProps
41
40
  });
42
41
 
43
- const { getPlotState } = getContext<PlotContext>('svelteplot');
44
- const plot = $derived(getPlotState());
42
+ const plot = usePlot();
45
43
  const args = $derived(recordizeY({ data, ...options }, { withIndex: false }));
46
44
  </script>
47
45
 
@@ -26,6 +26,7 @@ declare function $$render<Datum = DataRecord>(): {
26
26
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: ConstantAccessor<string, Datum>;
30
31
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: ConstantAccessor<string, Datum>;
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRecord>(): {
26
26
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
27
27
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
30
31
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
31
32
  paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
@@ -1,11 +1,9 @@
1
1
  <script lang="ts">
2
- import { getContext } from 'svelte';
3
2
  import { symbol as d3Symbol } from 'd3-shape';
4
3
  import { maybeSymbol } from '../helpers/symbols.js';
5
- import type { PlotContext } from '../types/index.js';
4
+ import { usePlot } from '../hooks/usePlot.svelte.js';
6
5
 
7
- const { getPlotState } = getContext<PlotContext>('svelteplot');
8
- let plot = $derived(getPlotState());
6
+ const plot = usePlot();
9
7
 
10
8
  // TODO: allow styling of legend
11
9
  </script>
@@ -1,8 +1,23 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
1
14
  /**
2
15
  * The SymbolLegend is an HTML mark that can be placed in the header, footer and overlay
3
16
  * snippets. You can activate an implicit SymbolLegend above the chart using the global
4
17
  * symbol.legend scale option.
5
18
  */
6
- declare const SymbolLegend: import("svelte").Component<Record<string, never>, {}, "">;
7
- type SymbolLegend = ReturnType<typeof SymbolLegend>;
19
+ declare const SymbolLegend: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
20
+ [evt: string]: CustomEvent<any>;
21
+ }, {}, {}, string>;
22
+ type SymbolLegend = InstanceType<typeof SymbolLegend>;
8
23
  export default SymbolLegend;
@@ -28,6 +28,7 @@ declare function $$render<Datum extends DataRecord>(): {
28
28
  strokeDashoffset: ConstantAccessor<number, Datum>;
29
29
  mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
30
30
  clipPath: string;
31
+ mask: string;
31
32
  imageFilter: ConstantAccessor<string, Datum>;
32
33
  shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
33
34
  paintOrder: ConstantAccessor<string, Datum>;
@@ -25,7 +25,6 @@
25
25
  import { getContext } from 'svelte';
26
26
  import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
27
27
  import type {
28
- PlotContext,
29
28
  BaseMarkProps,
30
29
  ChannelAccessor,
31
30
  DataRow,
@@ -37,9 +36,9 @@
37
36
  import { isValid } from '../helpers/index.js';
38
37
  import { testFilter, parseInset } from '../helpers/index.js';
39
38
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
39
+ import { usePlot } from '../hooks/usePlot.svelte.js';
40
40
 
41
- const { getPlotState } = getContext<PlotContext>('svelteplot');
42
- let plot = $derived(getPlotState());
41
+ const plot = usePlot();
43
42
 
44
43
  let markProps: TickXMarkProps = $props();
45
44
  const DEFAULTS = {
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
26
26
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: ConstantAccessor<string, Datum>;
30
31
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: ConstantAccessor<string, Datum>;
@@ -24,7 +24,6 @@
24
24
  import { getContext } from 'svelte';
25
25
  import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
26
26
  import type {
27
- PlotContext,
28
27
  BaseMarkProps,
29
28
  ChannelAccessor,
30
29
  DataRow,
@@ -36,9 +35,9 @@
36
35
  import { isValid } from '../helpers/index.js';
37
36
  import { testFilter, parseInset } from '../helpers/index.js';
38
37
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
38
+ import { usePlot } from '../hooks/usePlot.svelte.js';
39
39
 
40
- const { getPlotState } = getContext<PlotContext>('svelteplot');
41
- let plot = $derived(getPlotState());
40
+ const plot = usePlot();
42
41
 
43
42
  let markProps: TickYMarkProps = $props();
44
43
  const DEFAULTS = {
@@ -26,6 +26,7 @@ declare function $$render<Datum extends DataRow>(): {
26
26
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
27
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
28
  clipPath: string;
29
+ mask: string;
29
30
  imageFilter: ConstantAccessor<string, Datum>;
30
31
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
32
  paintOrder: ConstantAccessor<string, Datum>;