svelteplot 0.2.9 → 0.2.10-pr-110.1

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 (83) hide show
  1. package/README.md +1 -1
  2. package/dist/Mark.svelte +5 -4
  3. package/dist/Plot.svelte +3 -2
  4. package/dist/core/Plot.svelte +37 -20
  5. package/dist/helpers/colors.d.ts +1 -1
  6. package/dist/helpers/index.d.ts +2 -2
  7. package/dist/helpers/scales.d.ts +1 -1
  8. package/dist/helpers/scales.js +9 -1
  9. package/dist/helpers/typeChecks.d.ts +4 -4
  10. package/dist/marks/Area.svelte +31 -29
  11. package/dist/marks/AreaX.svelte +7 -3
  12. package/dist/marks/AreaX.svelte.d.ts +1 -6
  13. package/dist/marks/AreaY.svelte +7 -2
  14. package/dist/marks/AreaY.svelte.d.ts +1 -9
  15. package/dist/marks/Arrow.svelte +24 -7
  16. package/dist/marks/AxisX.svelte +24 -21
  17. package/dist/marks/AxisX.svelte.d.ts +3 -4
  18. package/dist/marks/AxisY.svelte +23 -20
  19. package/dist/marks/AxisY.svelte.d.ts +3 -4
  20. package/dist/marks/BarX.svelte +18 -2
  21. package/dist/marks/BarX.svelte.d.ts +2 -2
  22. package/dist/marks/BarY.svelte +18 -3
  23. package/dist/marks/BarY.svelte.d.ts +2 -2
  24. package/dist/marks/BollingerX.svelte.d.ts +1 -1
  25. package/dist/marks/BollingerY.svelte.d.ts +1 -1
  26. package/dist/marks/BoxX.svelte +23 -9
  27. package/dist/marks/BoxX.svelte.d.ts +3 -2
  28. package/dist/marks/BoxY.svelte +20 -10
  29. package/dist/marks/BoxY.svelte.d.ts +3 -3
  30. package/dist/marks/Brush.svelte +30 -10
  31. package/dist/marks/BrushX.svelte +9 -3
  32. package/dist/marks/BrushX.svelte.d.ts +1 -1
  33. package/dist/marks/BrushY.svelte +9 -3
  34. package/dist/marks/BrushY.svelte.d.ts +1 -1
  35. package/dist/marks/Cell.svelte +17 -2
  36. package/dist/marks/Cell.svelte.d.ts +2 -2
  37. package/dist/marks/ColorLegend.svelte +3 -2
  38. package/dist/marks/Dot.svelte +29 -24
  39. package/dist/marks/Dot.svelte.d.ts +2 -2
  40. package/dist/marks/Frame.svelte +24 -4
  41. package/dist/marks/Frame.svelte.d.ts +2 -2
  42. package/dist/marks/Geo.svelte +41 -37
  43. package/dist/marks/Geo.svelte.d.ts +4 -2
  44. package/dist/marks/Graticule.svelte +14 -5
  45. package/dist/marks/GridX.svelte +16 -2
  46. package/dist/marks/GridY.svelte +16 -2
  47. package/dist/marks/Line.svelte +22 -8
  48. package/dist/marks/Link.svelte +12 -4
  49. package/dist/marks/Pointer.svelte +12 -3
  50. package/dist/marks/Rect.svelte +17 -2
  51. package/dist/marks/Rect.svelte.d.ts +2 -2
  52. package/dist/marks/RectX.svelte +16 -2
  53. package/dist/marks/RectY.svelte +16 -2
  54. package/dist/marks/RuleX.svelte +15 -2
  55. package/dist/marks/RuleY.svelte +15 -2
  56. package/dist/marks/Sphere.svelte +17 -4
  57. package/dist/marks/Sphere.svelte.d.ts +3 -58
  58. package/dist/marks/Text.svelte +22 -4
  59. package/dist/marks/TickX.svelte +15 -2
  60. package/dist/marks/TickY.svelte +15 -2
  61. package/dist/marks/Vector.svelte +13 -5
  62. package/dist/marks/helpers/Anchor.svelte +37 -0
  63. package/dist/marks/helpers/Anchor.svelte.d.ts +15 -0
  64. package/dist/marks/helpers/BaseAxisX.svelte +59 -53
  65. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -0
  66. package/dist/marks/helpers/BaseAxisY.svelte +24 -18
  67. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -0
  68. package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
  69. package/dist/marks/helpers/RectPath.svelte +33 -30
  70. package/dist/marks/helpers/Regression.svelte +1 -1
  71. package/dist/transforms/bollinger.d.ts +1 -8
  72. package/dist/transforms/centroid.d.ts +1 -8
  73. package/dist/transforms/group.d.ts +4 -12
  74. package/dist/transforms/interval.d.ts +2 -6
  75. package/dist/transforms/map.d.ts +4 -10
  76. package/dist/transforms/normalize.d.ts +2 -6
  77. package/dist/transforms/select.d.ts +7 -21
  78. package/dist/transforms/sort.d.ts +5 -17
  79. package/dist/transforms/sort.js +23 -13
  80. package/dist/transforms/window.d.ts +2 -14
  81. package/dist/types.d.ts +251 -78
  82. package/dist/ui/ExamplesGrid.svelte +1 -1
  83. package/package.json +121 -120
@@ -6,9 +6,9 @@ export type DotMarkProps = BaseMarkProps & {
6
6
  symbol?: ChannelAccessor | Snippet<[number, string]>;
7
7
  canvas?: boolean;
8
8
  dotClass?: ConstantAccessor<string>;
9
- };
9
+ } & LinkableMarkProps;
10
10
  import { type Snippet } from 'svelte';
11
- import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor } from '../types.js';
11
+ import type { DataRecord, BaseMarkProps, ConstantAccessor, ChannelAccessor, LinkableMarkProps } from '../types.js';
12
12
  /** Creates dots or symbols at specified positions with customizable size and appearance */
13
13
  declare const Dot: import("svelte").Component<DotMarkProps, {}, "">;
14
14
  type Dot = ReturnType<typeof Dot>;
@@ -7,6 +7,7 @@
7
7
  BaseMarkProps,
8
8
  'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'
9
9
  > &
10
+ LinkableMarkProps &
10
11
  Omit<
11
12
  BaseRectMarkProps,
12
13
  'inset' | 'insetLeft' | 'insetRight' | 'insetTop' | 'insetBottom'
@@ -27,19 +28,38 @@
27
28
  <script lang="ts">
28
29
  import Mark from '../Mark.svelte';
29
30
  import { getContext } from 'svelte';
30
- import type { PlotContext, BaseRectMarkProps } from '../types.js';
31
+ import type {
32
+ PlotContext,
33
+ BaseRectMarkProps,
34
+ LinkableMarkProps,
35
+ PlotDefaults
36
+ } from '../types.js';
31
37
  import type { BaseMarkProps } from '../types.js';
32
38
  import RectPath from './helpers/RectPath.svelte';
33
39
 
34
- let {
40
+ let markProps: FrameMarkProps = $props();
41
+
42
+ const DEFAULTS: FrameMarkProps = {
43
+ fill: 'none',
44
+ class: 'frame',
45
+ stroke: 'currentColor',
46
+ fillOpacity: 1,
47
+ strokeOpacity: 1,
48
+ ...getContext<PlotDefaults>('svelteplot/_defaults').frame
49
+ };
50
+
51
+ const {
35
52
  automatic,
36
- class: className = 'frame',
53
+ class: className,
37
54
  fill,
38
55
  stroke,
39
56
  fillOpacity,
40
57
  strokeOpacity,
41
58
  ...options
42
- }: FrameMarkProps = $props();
59
+ }: FrameMarkProps = $derived({
60
+ ...DEFAULTS,
61
+ ...markProps
62
+ });
43
63
 
44
64
  const { getPlotState } = getContext<PlotContext>('svelteplot');
45
65
  const plot = $derived(getPlotState());
@@ -1,4 +1,4 @@
1
- export type FrameMarkProps = Omit<BaseMarkProps, 'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'> & Omit<BaseRectMarkProps, 'inset' | 'insetLeft' | 'insetRight' | 'insetTop' | 'insetBottom'> & {
1
+ export type FrameMarkProps = Omit<BaseMarkProps, 'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'> & LinkableMarkProps & Omit<BaseRectMarkProps, 'inset' | 'insetLeft' | 'insetRight' | 'insetTop' | 'insetBottom'> & {
2
2
  fill: string;
3
3
  stroke: string;
4
4
  fillOpacity: number;
@@ -10,7 +10,7 @@ export type FrameMarkProps = Omit<BaseMarkProps, 'fill' | 'stroke' | 'fillOpacit
10
10
  insetTop?: number;
11
11
  insetBottom?: number;
12
12
  };
13
- import type { BaseRectMarkProps } from '../types.js';
13
+ import type { BaseRectMarkProps, LinkableMarkProps } from '../types.js';
14
14
  import type { BaseMarkProps } from '../types.js';
15
15
  /** Renders a simple frame around the entire plot domain */
16
16
  declare const Frame: import("svelte").Component<FrameMarkProps, {}, "">;
@@ -7,8 +7,10 @@
7
7
  geoType?: 'sphere' | 'graticule';
8
8
  dragRotate: boolean;
9
9
  canvas: boolean;
10
- href: ConstantAccessor<string>;
11
- target: ConstantAccessor<string>;
10
+ /**
11
+ * simple browser tooltip to be displayed on mouseover
12
+ */
13
+ title: ConstantAccessor<string>;
12
14
  } & BaseMarkProps &
13
15
  LinkableMarkProps;
14
16
  </script>
@@ -20,7 +22,8 @@
20
22
  PlotContext,
21
23
  BaseMarkProps,
22
24
  ConstantAccessor,
23
- LinkableMarkProps
25
+ LinkableMarkProps,
26
+ PlotDefaults
24
27
  } from '../types.js';
25
28
  import Mark from '../Mark.svelte';
26
29
  import { geoPath } from 'd3-geo';
@@ -31,18 +34,28 @@
31
34
  import GeoCanvas from './helpers/GeoCanvas.svelte';
32
35
  import { recordize } from '../transforms/recordize.js';
33
36
  import { GEOJSON_PREFER_STROKE } from '../helpers/index.js';
37
+ import Anchor from './helpers/Anchor.svelte';
34
38
 
35
39
  const { getPlotState } = getContext<PlotContext>('svelteplot');
36
40
  const plot = $derived(getPlotState());
37
41
 
38
- let {
42
+ let markProps: GeoMarkProps = $props();
43
+
44
+ const DEFAULTS = {
45
+ ...getContext<PlotDefaults>('svelteplot/_defaults').geo
46
+ };
47
+
48
+ const {
39
49
  data = [{}],
40
50
  canvas = false,
41
51
  geoType,
42
52
  dragRotate,
43
- class: className = null,
53
+ class: className = '',
44
54
  ...options
45
- }: GeoMarkProps = $props();
55
+ }: GeoMarkProps = $derived({
56
+ ...DEFAULTS,
57
+ ...markProps
58
+ });
46
59
 
47
60
  const path = $derived(
48
61
  callWithProps(geoPath, [plot.scales.projection], {
@@ -68,28 +81,6 @@
68
81
  channels={['fill', 'stroke', 'opacity', 'fillOpacity', 'strokeOpacity', 'r']}
69
82
  {...args}>
70
83
  {#snippet children({ mark, scaledData, usedScales })}
71
- {#snippet el(d)}
72
- {@const title = resolveProp(args.title, d.datum, '')}
73
- {@const geometry = resolveProp(args.geometry, d.datum, d.datum)}
74
- {@const [style, styleClass] = resolveStyles(
75
- plot,
76
- d,
77
- args,
78
- GEOJSON_PREFER_STROKE.has(geometry.type) ? 'stroke' : 'fill',
79
- usedScales
80
- )}
81
- <path
82
- d={path(geometry)}
83
- {style}
84
- class={[styleClass]}
85
- use:addEventHandlers={{
86
- getPlotState,
87
- options: args,
88
- datum: d.datum
89
- }}>
90
- {#if title}<title>{title}</title>{/if}
91
- </path>
92
- {/snippet}
93
84
  <g
94
85
  aria-label="geo"
95
86
  class={['geo', geoType && `geo-${geoType}`, className]}
@@ -99,15 +90,28 @@
99
90
  {:else}
100
91
  {#each scaledData as d, i (i)}
101
92
  {#if d.valid}
102
- {#if options.href}
103
- <a
104
- href={resolveProp(args.href, d.datum, '')}
105
- target={resolveProp(args.target, d.datum, '_self')}>
106
- {@render el(d)}
107
- </a>
108
- {:else}
109
- {@render el(d)}
110
- {/if}
93
+ <Anchor {options} datum={d.datum}>
94
+ {@const title = resolveProp(args.title, d.datum, '')}
95
+ {@const geometry = resolveProp(args.geometry, d.datum, d.datum)}
96
+ {@const [style, styleClass] = resolveStyles(
97
+ plot,
98
+ d,
99
+ args,
100
+ GEOJSON_PREFER_STROKE.has(geometry.type) ? 'stroke' : 'fill',
101
+ usedScales
102
+ )}
103
+ <path
104
+ d={path(geometry)}
105
+ {style}
106
+ class={[styleClass]}
107
+ use:addEventHandlers={{
108
+ getPlotState,
109
+ options: args,
110
+ datum: d.datum
111
+ }}>
112
+ {#if title}<title>{title}</title>{/if}
113
+ </path>
114
+ </Anchor>
111
115
  {/if}
112
116
  {/each}
113
117
  {/if}
@@ -3,8 +3,10 @@ export type GeoMarkProps = {
3
3
  geoType?: 'sphere' | 'graticule';
4
4
  dragRotate: boolean;
5
5
  canvas: boolean;
6
- href: ConstantAccessor<string>;
7
- target: ConstantAccessor<string>;
6
+ /**
7
+ * simple browser tooltip to be displayed on mouseover
8
+ */
9
+ title: ConstantAccessor<string>;
8
10
  } & BaseMarkProps & LinkableMarkProps;
9
11
  import type { DataRecord, BaseMarkProps, ConstantAccessor, LinkableMarkProps } from '../types.js';
10
12
  /** Renders geographical data using projections and GeoJSON geometries */
@@ -2,7 +2,7 @@
2
2
  Renders a geographic graticule grid with customizable step sizes
3
3
  -->
4
4
  <script module lang="ts">
5
- import type { DefaultOptions, BaseMarkProps } from '../types.js';
5
+ import type { PlotDefaults, BaseMarkProps } from '../types.js';
6
6
  export type GraticuleMarkProps = Omit<
7
7
  BaseMarkProps,
8
8
  'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target' | 'cursor'
@@ -17,17 +17,26 @@
17
17
  import Geo from './Geo.svelte';
18
18
  import { geoGraticule } from 'd3-geo';
19
19
  import { getContext } from 'svelte';
20
+ import type { PlotDefaults } from '../types.js';
21
+
22
+ let markProps: GraticuleMarkProps = $props();
20
23
 
21
24
  const DEFAULTS = {
22
- graticuleStep: 10,
23
- ...getContext<Partial<DefaultOptions>>('svelteplot/defaults')
25
+ ...getContext<PlotDefaults>('svelteplot/_defaults').graticule
24
26
  };
25
27
 
26
- let { step = DEFAULTS.graticuleStep, stepX, stepY, ...options }: GraticuleMarkProps = $props();
28
+ const {
29
+ data = [{}],
30
+ class: className = '',
31
+ ...options
32
+ }: GraticuleMarkProps = $derived({
33
+ ...DEFAULTS,
34
+ ...markProps
35
+ });
27
36
 
28
37
  let graticule = $derived.by(() => {
29
38
  const graticule = geoGraticule();
30
- graticule.stepMinor([stepX || step, stepY || step]);
39
+ graticule.stepMinor([options.stepX || options.step, options.stepY || options.step]);
31
40
  return graticule;
32
41
  });
33
42
  </script>
@@ -11,13 +11,27 @@
11
11
  <script lang="ts">
12
12
  import { getContext } from 'svelte';
13
13
  import Mark from '../Mark.svelte';
14
- import type { PlotContext, BaseMarkProps, RawValue } from '../types.js';
14
+ import type { PlotContext, BaseMarkProps, RawValue, PlotDefaults } from '../types.js';
15
15
  import { resolveChannel, resolveStyles } from '../helpers/resolve.js';
16
16
  import { autoTicks } from '../helpers/autoTicks.js';
17
17
  import { testFilter } from '../helpers/index.js';
18
18
  import { RAW_VALUE } from '../transforms/recordize.js';
19
19
 
20
- let { data = [], automatic = false, ...options }: GridXMarkProps = $props();
20
+ let markProps: GridXMarkProps = $props();
21
+
22
+ const DEFAULTS = {
23
+ ...getContext<PlotDefaults>('svelteplot/_defaults').grid,
24
+ ...getContext<PlotDefaults>('svelteplot/_defaults').gridX
25
+ };
26
+
27
+ const {
28
+ data = [],
29
+ automatic = false,
30
+ ...options
31
+ }: GridXMarkProps = $derived({
32
+ ...DEFAULTS,
33
+ ...markProps
34
+ });
21
35
 
22
36
  const { getPlotState } = getContext<PlotContext>('svelteplot');
23
37
  const plot = $derived(getPlotState());
@@ -11,13 +11,27 @@
11
11
  <script lang="ts">
12
12
  import { getContext } from 'svelte';
13
13
  import Mark from '../Mark.svelte';
14
- import type { PlotContext, BaseMarkProps, RawValue } from '../types.js';
14
+ import type { PlotContext, BaseMarkProps, RawValue, PlotDefaults } from '../types.js';
15
15
  import { resolveChannel, resolveStyles } from '../helpers/resolve.js';
16
16
  import { autoTicks } from '../helpers/autoTicks.js';
17
17
  import { testFilter } from '../helpers/index.js';
18
18
  import { RAW_VALUE } from '../transforms/recordize.js';
19
19
 
20
- let { data = [], automatic = false, ...options }: GridYMarkProps = $props();
20
+ let markProps: GridYMarkProps = $props();
21
+
22
+ const DEFAULTS = {
23
+ ...getContext<PlotDefaults>('svelteplot/_defaults').grid,
24
+ ...getContext<PlotDefaults>('svelteplot/_defaults').gridY
25
+ };
26
+
27
+ const {
28
+ data = [],
29
+ automatic = false,
30
+ ...options
31
+ }: GridYMarkProps = $derived({
32
+ ...DEFAULTS,
33
+ ...markProps
34
+ });
21
35
 
22
36
  const { getPlotState } = getContext<PlotContext>('svelteplot');
23
37
  const plot = $derived(getPlotState());
@@ -47,22 +47,36 @@
47
47
  import { pick } from 'es-toolkit';
48
48
  import LineCanvas from './helpers/LineCanvas.svelte';
49
49
 
50
- import type { RawValue } from '../types.js';
50
+ import type { RawValue, PlotDefaults } from '../types.js';
51
51
  import { isValid } from '../helpers/index.js';
52
52
  import { sort } from '../transforms/sort.js';
53
53
  import { recordizeXY } from '../transforms/recordize.js';
54
54
  import GroupMultiple from './helpers/GroupMultiple.svelte';
55
55
 
56
- let {
56
+ let markProps: LineMarkProps = $props();
57
+
58
+ const DEFAULTS: LineMarkProps = {
59
+ curve: 'auto',
60
+ tension: 0,
61
+ canvas: false,
62
+ class: null,
63
+ lineClass: null,
64
+ ...getContext<PlotDefaults>('svelteplot/_defaults').line
65
+ };
66
+
67
+ const {
57
68
  data = [{}],
58
- curve = 'auto',
59
- tension = 0,
69
+ curve,
70
+ tension,
60
71
  text,
61
- canvas = false,
62
- class: className = null,
63
- lineClass = null,
72
+ canvas,
73
+ class: className,
74
+ lineClass,
64
75
  ...options
65
- }: LineMarkProps = $props();
76
+ }: LineMarkProps = $derived({
77
+ ...DEFAULTS,
78
+ ...markProps
79
+ });
66
80
 
67
81
  const args = $derived(sort(recordizeXY({ data, ...options })));
68
82
 
@@ -28,7 +28,8 @@
28
28
  CurveName,
29
29
  MarkerOptions,
30
30
  RawValue,
31
- ScaledDataRecord
31
+ ScaledDataRecord,
32
+ PlotDefaults
32
33
  } from '../types.js';
33
34
  import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
34
35
  import { maybeData } from '../helpers/index.js';
@@ -41,14 +42,21 @@
41
42
  import { geoPath } from 'd3-geo';
42
43
  import { pick } from 'es-toolkit';
43
44
 
44
- let {
45
+ let markProps: LinkMarkProps = $props();
46
+ const DEFAULTS = {
47
+ ...getContext<PlotDefaults>('svelteplot/_defaults').link
48
+ };
49
+ const {
45
50
  data = [{}],
46
51
  curve = 'auto',
47
52
  tension = 0,
48
53
  text,
49
- class: className = null,
54
+ class: className = '',
50
55
  ...options
51
- }: LinkMarkProps = $props();
56
+ }: LinkMarkProps = $derived({
57
+ ...DEFAULTS,
58
+ ...markProps
59
+ });
52
60
 
53
61
  const { getPlotState } = getContext<PlotContext>('svelteplot');
54
62
  let plot = $derived(getPlotState());
@@ -21,7 +21,7 @@
21
21
 
22
22
  <script lang="ts">
23
23
  import { getContext, type Snippet } from 'svelte';
24
- import type { PlotContext } from '../types.js';
24
+ import type { PlotContext, PlotDefaults } from '../types.js';
25
25
  import { groups as d3Groups } from 'd3-array';
26
26
 
27
27
  const { getPlotState } = getContext<PlotContext>('svelteplot');
@@ -33,7 +33,13 @@
33
33
  import isDataRecord from '../helpers/isDataRecord.js';
34
34
  import { RAW_VALUE } from '../transforms/recordize.js';
35
35
 
36
- let {
36
+ let markProps: PointerMarkProps = $props();
37
+
38
+ const DEFAULTS = {
39
+ ...getContext<PlotDefaults>('svelteplot/_defaults').pointer
40
+ };
41
+
42
+ const {
37
43
  data = [{}],
38
44
  children,
39
45
  x,
@@ -41,7 +47,10 @@
41
47
  z,
42
48
  maxDistance = 15,
43
49
  onupdate = null
44
- }: PointerMarkProps = $props();
50
+ }: PointerMarkProps = $derived({
51
+ ...DEFAULTS,
52
+ ...markProps
53
+ });
45
54
 
46
55
  let selectedData = $state([]);
47
56
 
@@ -13,6 +13,7 @@
13
13
  y2?: ChannelAccessor;
14
14
  interval?: number | string;
15
15
  } & BaseMarkProps &
16
+ LinkableMarkProps &
16
17
  BaseRectMarkProps;
17
18
  </script>
18
19
 
@@ -25,12 +26,26 @@
25
26
  DataRecord,
26
27
  BaseMarkProps,
27
28
  BaseRectMarkProps,
28
- ChannelAccessor
29
+ ChannelAccessor,
30
+ PlotDefaults
29
31
  } from '../types.js';
30
32
  import GroupMultiple from './helpers/GroupMultiple.svelte';
31
33
  import RectPath from './helpers/RectPath.svelte';
32
34
 
33
- let { data = [{}], class: className = 'rect', ...options }: RectMarkProps = $props();
35
+ let markProps: RectMarkProps = $props();
36
+
37
+ const DEFAULTS = {
38
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rect
39
+ };
40
+
41
+ const {
42
+ data = [{}],
43
+ class: className = '',
44
+ ...options
45
+ }: RectMarkProps = $derived({
46
+ ...DEFAULTS,
47
+ ...markProps
48
+ });
34
49
 
35
50
  const { getPlotState } = getContext<PlotContext>('svelteplot');
36
51
  let plot = $derived(getPlotState());
@@ -7,9 +7,9 @@ export type RectMarkProps = {
7
7
  y1?: ChannelAccessor;
8
8
  y2?: ChannelAccessor;
9
9
  interval?: number | string;
10
- } & BaseMarkProps & BaseRectMarkProps;
10
+ } & BaseMarkProps & LinkableMarkProps & BaseRectMarkProps;
11
11
  import type { DataRecord, BaseMarkProps, BaseRectMarkProps, ChannelAccessor } from '../types.js';
12
12
  /** For arbitrary rectangles, requires quantitative x and y scales */
13
- declare const Rect: import("svelte").Component<RectMarkProps, {}, "">;
13
+ declare const Rect: import("svelte").Component<any, {}, "">;
14
14
  type Rect = ReturnType<typeof Rect>;
15
15
  export default Rect;
@@ -8,11 +8,25 @@
8
8
  <script lang="ts">
9
9
  import Rect, { type RectMarkProps } from './Rect.svelte';
10
10
  import { intervalY, stackX, recordizeX } from '../index.js';
11
- import type { PlotContext } from '../types.js';
11
+ import type { PlotContext, PlotDefaults } from '../types.js';
12
12
  import { getContext } from 'svelte';
13
13
  import type { StackOptions } from '../transforms/stack';
14
14
 
15
- let { data = [{}], stack, ...options }: RectXMarkProps = $props();
15
+ let markProps: RectXMarkProps = $props();
16
+
17
+ const DEFAULTS = {
18
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rect,
19
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rectX
20
+ };
21
+
22
+ const {
23
+ data = [{}],
24
+ stack,
25
+ ...options
26
+ }: RectXMarkProps = $derived({
27
+ ...DEFAULTS,
28
+ ...markProps
29
+ });
16
30
 
17
31
  const { getPlotState } = getContext<PlotContext>('svelteplot');
18
32
  let plot = $derived(getPlotState());
@@ -8,11 +8,25 @@
8
8
  <script lang="ts">
9
9
  import Rect, { type RectMarkProps } from './Rect.svelte';
10
10
  import { intervalX, stackY, recordizeY } from '../index.js';
11
- import type { PlotContext } from '../types.js';
11
+ import type { PlotContext, PlotDefaults } from '../types.js';
12
12
  import { getContext } from 'svelte';
13
13
  import type { StackOptions } from '../transforms/stack';
14
14
 
15
- let { data = [{}], stack, ...options }: RectYMarkProps = $props();
15
+ let markProps: RectYMarkProps = $props();
16
+
17
+ const DEFAULTS = {
18
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rect,
19
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rectY
20
+ };
21
+
22
+ const {
23
+ data = [{}],
24
+ stack,
25
+ ...options
26
+ }: RectYMarkProps = $derived({
27
+ ...DEFAULTS,
28
+ ...markProps
29
+ });
16
30
 
17
31
  const { getPlotState } = getContext<PlotContext>('svelteplot');
18
32
  const plot = $derived(getPlotState());
@@ -24,10 +24,23 @@
24
24
  DataRecord,
25
25
  BaseMarkProps,
26
26
  ConstantAccessor,
27
- ChannelAccessor
27
+ ChannelAccessor,
28
+ PlotDefaults
28
29
  } from '../types.js';
29
30
 
30
- let { data = [{}], class: className = null, ...options }: RuleXMarkProps = $props();
31
+ let markProps: RuleXMarkProps = $props();
32
+ const DEFAULTS = {
33
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rule,
34
+ ...getContext<PlotDefaults>('svelteplot/_defaults').ruleX
35
+ };
36
+ const {
37
+ data = [{}],
38
+ class: className = '',
39
+ ...options
40
+ }: RuleXMarkProps = $derived({
41
+ ...DEFAULTS,
42
+ ...markProps
43
+ });
31
44
 
32
45
  const { getPlotState } = getContext<PlotContext>('svelteplot');
33
46
  const plot = $derived(getPlotState());
@@ -24,10 +24,23 @@
24
24
  DataRecord,
25
25
  BaseMarkProps,
26
26
  ConstantAccessor,
27
- ChannelAccessor
27
+ ChannelAccessor,
28
+ PlotDefaults
28
29
  } from '../types.js';
29
30
 
30
- let { data = [{}], class: className = null, ...options }: RuleYMarkProps = $props();
31
+ let markProps: RuleYMarkProps = $props();
32
+ const DEFAULTS = {
33
+ ...getContext<PlotDefaults>('svelteplot/_defaults').rule,
34
+ ...getContext<PlotDefaults>('svelteplot/_defaults').ruleY
35
+ };
36
+ const {
37
+ data = [{}],
38
+ class: className = '',
39
+ ...options
40
+ }: RuleYMarkProps = $derived({
41
+ ...DEFAULTS,
42
+ ...markProps
43
+ });
31
44
 
32
45
  const { getPlotState } = getContext<PlotContext>('svelteplot');
33
46
  const plot = $derived(getPlotState());
@@ -2,14 +2,27 @@
2
2
  Geo mark with Sphere geometry object -->
3
3
 
4
4
  <script module lang="ts">
5
- import { type BaseMarkProps } from '../types.js';
6
- export type SphereMarkProps = BaseMarkProps;
5
+ import { type BaseMarkProps, type LinkableMarkProps } from '../types.js';
6
+ export type SphereMarkProps = BaseMarkProps & LinkableMarkProps;
7
7
  </script>
8
8
 
9
9
  <script lang="ts">
10
10
  import Geo from './Geo.svelte';
11
+ import { getContext } from 'svelte';
12
+ import type { PlotDefaults } from '../types.js';
11
13
 
12
- let { ...args }: SphereMarkProps = $props();
14
+ let markProps: SphereMarkProps = $props();
15
+ const DEFAULTS = {
16
+ ...getContext<PlotDefaults>('svelteplot/_defaults').sphere
17
+ };
18
+ const {
19
+ data = [{}],
20
+ class: className = '',
21
+ ...options
22
+ }: SphereMarkProps = $derived({
23
+ ...DEFAULTS,
24
+ ...markProps
25
+ });
13
26
  </script>
14
27
 
15
- <Geo data={[{ type: 'Sphere' }]} {...args} geoType="sphere" />
28
+ <Geo {data} {...options} geoType="sphere" />