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
@@ -26,16 +26,13 @@
26
26
  tickClass?: ConstantAccessor<string>;
27
27
  /** ticks is a shorthand for defining data, tickCount or interval */
28
28
  ticks?: number | string | RawValue[];
29
- } & XOR<
30
- {
31
- /** approximate number of ticks to be generated */
32
- tickCount?: number;
33
- },
34
- {
35
- /** approximate number of pixels between generated ticks */
36
- tickSpacing?: number;
37
- }
38
- >;
29
+ /** set to false or null to disable tick labels */
30
+ text: boolean | null;
31
+ /** approximate number of ticks to be generated */
32
+ tickCount?: number;
33
+ /** approximate number of pixels between generated ticks */
34
+ tickSpacing?: number;
35
+ };
39
36
  </script>
40
37
 
41
38
  <script lang="ts">
@@ -47,39 +44,44 @@
47
44
  BaseMarkProps,
48
45
  RawValue,
49
46
  FacetContext,
50
- DefaultOptions
47
+ PlotDefaults,
48
+ ChannelName
51
49
  } from '../types.js';
52
50
  import autoTimeFormat from '../helpers/autoTimeFormat.js';
53
51
  import type { ConstantAccessor } from '../types.js';
54
52
  import { autoTicks } from '../helpers/autoTicks.js';
55
53
  import { resolveScaledStyles } from '../helpers/resolve.js';
56
54
 
57
- const DEFAULTS = {
55
+ let markProps: AxisYMarkProps = $props();
56
+
57
+ const DEFAULTS: Omit<AxisYMarkProps, 'data' | ChannelName> = {
58
58
  tickSize: 6,
59
59
  tickPadding: 3,
60
60
  tickFontSize: 11,
61
- axisYAnchor: 'left',
62
- ...getContext<Partial<DefaultOptions>>('svelteplot/_defaults')
61
+ anchor: 'left',
62
+ ...getContext<PlotDefaults>('svelteplot/_defaults').axis,
63
+ ...getContext<PlotDefaults>('svelteplot/_defaults').axisY
63
64
  };
64
65
 
65
- let {
66
+ const {
66
67
  ticks: magicTicks,
67
68
  data = Array.isArray(magicTicks) ? magicTicks : [],
68
69
  automatic = false,
69
70
  title,
70
- anchor = DEFAULTS.axisYAnchor as 'left' | 'right',
71
+ anchor,
71
72
  facetAnchor = 'auto',
72
73
  interval = typeof magicTicks === 'string' ? magicTicks : undefined,
73
74
  lineAnchor = 'center',
74
- tickSize = DEFAULTS.tickSize,
75
- tickFontSize = DEFAULTS.tickFontSize,
76
- tickPadding = DEFAULTS.tickPadding,
75
+ tickSize,
76
+ tickFontSize,
77
+ tickPadding,
77
78
  tickFormat,
78
79
  tickClass,
79
80
  tickCount = typeof magicTicks === 'number' ? magicTicks : undefined,
80
81
  tickSpacing,
82
+ text = true,
81
83
  ...options
82
- }: AxisYMarkProps = $props();
84
+ }: AxisYMarkProps = $derived({ ...DEFAULTS, ...markProps });
83
85
 
84
86
  const { getPlotState } = getContext<PlotContext>('svelteplot');
85
87
  const plot = $derived(getPlotState());
@@ -200,6 +202,7 @@
200
202
  {tickFontSize}
201
203
  {tickClass}
202
204
  {options}
205
+ {text}
203
206
  title={useTitle}
204
207
  {plot} />
205
208
  {/if}
@@ -1,4 +1,3 @@
1
- import type { XOR } from 'ts-essentials';
2
1
  export type AxisYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'> & {
3
2
  data?: RawValue[];
4
3
  automatic?: boolean;
@@ -15,13 +14,13 @@ export type AxisYMarkProps = Omit<BaseMarkProps, 'fill' | 'fillOpacity' | 'paint
15
14
  tickClass?: ConstantAccessor<string>;
16
15
  /** ticks is a shorthand for defining data, tickCount or interval */
17
16
  ticks?: number | string | RawValue[];
18
- } & XOR<{
17
+ /** set to false or null to disable tick labels */
18
+ text: boolean | null;
19
19
  /** approximate number of ticks to be generated */
20
20
  tickCount?: number;
21
- }, {
22
21
  /** approximate number of pixels between generated ticks */
23
22
  tickSpacing?: number;
24
- }>;
23
+ };
25
24
  import type { BaseMarkProps, RawValue } from '../types.js';
26
25
  import type { ConstantAccessor } from '../types.js';
27
26
  /** Renders a vertical axis with labels and tick marks */
@@ -7,10 +7,13 @@
7
7
  PlotContext,
8
8
  BaseMarkProps,
9
9
  BaseRectMarkProps,
10
- ChannelAccessor
10
+ ChannelAccessor,
11
+ LinkableMarkProps,
12
+ PlotDefaults
11
13
  } from '../types.js';
12
14
 
13
15
  export type BarXMarkProps = BaseMarkProps &
16
+ LinkableMarkProps &
14
17
  BaseRectMarkProps & {
15
18
  data: DataRow[];
16
19
  x?: ChannelAccessor;
@@ -36,7 +39,20 @@
36
39
  import GroupMultiple from './helpers/GroupMultiple.svelte';
37
40
  import RectPath from './helpers/RectPath.svelte';
38
41
 
39
- let { data = [{}], class: className = null, stack, ...options }: BarXMarkProps = $props();
42
+ const DEFAULTS = {
43
+ fill: 'currentColor',
44
+ ...getContext<PlotDefaults>('svelteplot/_defaults').bar,
45
+ ...getContext<PlotDefaults>('svelteplot/_defaults').barX
46
+ };
47
+
48
+ let markProps: BarXMarkProps = $props();
49
+
50
+ const {
51
+ data = [{}],
52
+ class: className = null,
53
+ stack,
54
+ ...options
55
+ }: BarXMarkProps = $derived({ ...DEFAULTS, ...markProps });
40
56
 
41
57
  const { getPlotState } = getContext<PlotContext>('svelteplot');
42
58
  const plot = $derived(getPlotState());
@@ -1,5 +1,5 @@
1
- import type { BaseMarkProps, BaseRectMarkProps, ChannelAccessor } from '../types.js';
2
- export type BarXMarkProps = BaseMarkProps & BaseRectMarkProps & {
1
+ import type { BaseMarkProps, BaseRectMarkProps, ChannelAccessor, LinkableMarkProps } from '../types.js';
2
+ export type BarXMarkProps = BaseMarkProps & LinkableMarkProps & BaseRectMarkProps & {
3
3
  data: DataRow[];
4
4
  x?: ChannelAccessor;
5
5
  x1?: ChannelAccessor;
@@ -8,10 +8,12 @@
8
8
  BaseMarkProps,
9
9
  BaseRectMarkProps,
10
10
  ChannelAccessor,
11
- DataRow
11
+ DataRow,
12
+ PlotDefaults
12
13
  } from '../types.js';
13
14
 
14
15
  export type BarYMarkProps = BaseMarkProps &
16
+ LinkableMarkProps &
15
17
  BaseRectMarkProps & {
16
18
  data: DataRow[];
17
19
  x?: ChannelAccessor;
@@ -36,11 +38,24 @@
36
38
  import GroupMultiple from './helpers/GroupMultiple.svelte';
37
39
  import RectPath from './helpers/RectPath.svelte';
38
40
 
39
- let { data = [{}], class: className = null, stack, ...options }: BarYMarkProps = $props();
40
-
41
41
  const { getPlotState } = getContext<PlotContext>('svelteplot');
42
42
  const plot = $derived(getPlotState());
43
43
 
44
+ const DEFAULTS = {
45
+ fill: 'currentColor',
46
+ ...getContext<PlotDefaults>('svelteplot/_defaults').bar,
47
+ ...getContext<PlotDefaults>('svelteplot/_defaults').barY
48
+ };
49
+
50
+ let markProps: BarYMarkProps = $props();
51
+
52
+ const {
53
+ data = [{}],
54
+ class: className = null,
55
+ stack,
56
+ ...options
57
+ }: BarYMarkProps = $derived({ ...DEFAULTS, ...markProps });
58
+
44
59
  const args = $derived(
45
60
  stackY(
46
61
  intervalY(
@@ -1,5 +1,5 @@
1
1
  import type { BaseMarkProps, BaseRectMarkProps, ChannelAccessor, DataRow } from '../types.js';
2
- export type BarYMarkProps = BaseMarkProps & BaseRectMarkProps & {
2
+ export type BarYMarkProps = BaseMarkProps & LinkableMarkProps & BaseRectMarkProps & {
3
3
  data: DataRow[];
4
4
  x?: ChannelAccessor;
5
5
  y?: ChannelAccessor;
@@ -14,6 +14,6 @@ export type BarYMarkProps = BaseMarkProps & BaseRectMarkProps & {
14
14
  };
15
15
  import type { StackOptions } from '../transforms/stack.js';
16
16
  /** For vertical column charts using a band scale as x axis */
17
- declare const BarY: import("svelte").Component<BarYMarkProps, {}, "">;
17
+ declare const BarY: import("svelte").Component<any, {}, "">;
18
18
  type BarY = ReturnType<typeof BarY>;
19
19
  export default BarY;
@@ -13,6 +13,6 @@ export type BollingerXMarkProps = BaseMarkProps & {
13
13
  };
14
14
  import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
15
15
  /** line representing a moving average and an area representing volatility as a band */
16
- declare const BollingerX: import("svelte").Component<BollingerXMarkProps, {}, "">;
16
+ declare const BollingerX: import("svelte").Component<any, {}, "">;
17
17
  type BollingerX = ReturnType<typeof BollingerX>;
18
18
  export default BollingerX;
@@ -13,6 +13,6 @@ export type BollingerYMarkProps = BaseMarkProps & {
13
13
  };
14
14
  import type { BaseMarkProps, ChannelAccessor, DataRow } from '../types.js';
15
15
  /** line representing a moving average and an area representing volatility as a band */
16
- declare const BollingerY: import("svelte").Component<BollingerYMarkProps, {}, "">;
16
+ declare const BollingerY: import("svelte").Component<any, {}, "">;
17
17
  type BollingerY = ReturnType<typeof BollingerY>;
18
18
  export default BollingerY;
@@ -1,23 +1,37 @@
1
1
  <!-- @component
2
2
  Creates a horizontal box plot for visualizing data distribution with quartiles and outliers
3
3
  -->
4
+ <script module lang="ts">
5
+ export type BoxXMarkProps = BoxYMarkProps;
6
+ </script>
7
+
4
8
  <script lang="ts">
5
9
  import GroupMultiple from './helpers/GroupMultiple.svelte';
6
- import type { BoxProps } from './BoxY.svelte';
10
+ import type { BoxYMarkProps } from './BoxY.svelte';
7
11
  import { BarX, TickX, RuleY, Dot, groupY } from '../index.js';
8
12
  import { resolveChannel } from '../helpers/resolve.js';
13
+ import { getContext } from 'svelte';
14
+ import type { PlotDefaults } from '../types.js';
9
15
 
10
- let {
16
+ let markProps: BoxXMarkProps = $props();
17
+ const DEFAULTS = {
18
+ ...getContext<PlotDefaults>('svelteplot/_defaults').box,
19
+ ...getContext<PlotDefaults>('svelteplot/_defaults').boxX
20
+ };
21
+ const {
11
22
  data = [{}],
12
- x,
13
- y,
14
- rule,
15
23
  bar,
16
- tickMedian = true,
17
- tickMinMax = false,
24
+ rule,
25
+ tickMedian,
26
+ tickMinMax,
18
27
  dot,
19
- class: className = null
20
- }: BoxProps = $props();
28
+ x,
29
+ y,
30
+ class: className = ''
31
+ }: BoxXMarkProps = $derived({
32
+ ...DEFAULTS,
33
+ ...markProps
34
+ });
21
35
 
22
36
  const { data: grouped } = $derived(
23
37
  groupY(
@@ -1,5 +1,6 @@
1
- import type { BoxProps } from './BoxY.svelte';
1
+ export type BoxXMarkProps = BoxYMarkProps;
2
+ import type { BoxYMarkProps } from './BoxY.svelte';
2
3
  /** Creates a horizontal box plot for visualizing data distribution with quartiles and outliers */
3
- declare const BoxX: import("svelte").Component<BoxProps, {}, "">;
4
+ declare const BoxX: import("svelte").Component<BoxYMarkProps, {}, "">;
4
5
  type BoxX = ReturnType<typeof BoxX>;
5
6
  export default BoxX;
@@ -2,7 +2,7 @@
2
2
  Creates a vertical box plot for visualizing data distribution with quartiles and outliers
3
3
  -->
4
4
  <script lang="ts" module>
5
- export type BoxProps = {
5
+ export type BoxYMarkProps = Pick<BaseMarkProps, 'class'> & {
6
6
  data: DataRecord[];
7
7
  x: ChannelAccessor;
8
8
  y: ChannelAccessor;
@@ -31,21 +31,31 @@
31
31
 
32
32
  <script lang="ts">
33
33
  import GroupMultiple from './helpers/GroupMultiple.svelte';
34
- import type { ChannelAccessor, DataRecord } from '../types.js';
34
+ import type { BaseMarkProps, ChannelAccessor, DataRecord } from '../types.js';
35
35
  import { groupX, BarY, TickY, RuleX, Dot } from '../index.js';
36
36
  import { resolveChannel } from '../helpers/resolve.js';
37
+ import { getContext } from 'svelte';
38
+ import type { PlotDefaults } from '../types.js';
37
39
 
38
- let {
40
+ let markProps: BoxYMarkProps = $props();
41
+ const DEFAULTS = {
42
+ ...getContext<PlotDefaults>('svelteplot/_defaults').box,
43
+ ...getContext<PlotDefaults>('svelteplot/_defaults').boxY
44
+ };
45
+ const {
39
46
  data = [{}],
40
- x,
41
- y,
42
- rule,
47
+ class: className = '',
43
48
  bar,
44
- tickMedian = true,
45
- tickMinMax = false,
49
+ rule,
50
+ tickMedian,
51
+ tickMinMax,
46
52
  dot,
47
- class: className = null
48
- }: BoxProps = $props();
53
+ x,
54
+ y
55
+ }: BoxYMarkProps = $derived({
56
+ ...DEFAULTS,
57
+ ...markProps
58
+ });
49
59
 
50
60
  let { data: grouped } = $derived(
51
61
  groupX(
@@ -1,4 +1,4 @@
1
- export type BoxProps = {
1
+ export type BoxYMarkProps = Pick<BaseMarkProps, 'class'> & {
2
2
  data: DataRecord[];
3
3
  x: ChannelAccessor;
4
4
  y: ChannelAccessor;
@@ -23,8 +23,8 @@ export type BoxProps = {
23
23
  */
24
24
  dot: Record<string, ChannelAccessor>;
25
25
  };
26
- import type { ChannelAccessor, DataRecord } from '../types.js';
26
+ import type { BaseMarkProps, ChannelAccessor, DataRecord } from '../types.js';
27
27
  /** Creates a vertical box plot for visualizing data distribution with quartiles and outliers */
28
- declare const BoxY: import("svelte").Component<BoxProps, {}, "">;
28
+ declare const BoxY: import("svelte").Component<BoxYMarkProps, {}, "">;
29
29
  type BoxY = ReturnType<typeof BoxY>;
30
30
  export default BoxY;
@@ -44,27 +44,41 @@
44
44
  import { getContext } from 'svelte';
45
45
  import Frame from './Frame.svelte';
46
46
  import Rect from './Rect.svelte';
47
- import type { BaseMarkProps, PlotContext } from '../types.js';
47
+ import type { BaseMarkProps, PlotContext, PlotDefaults } from '../types.js';
48
48
  import { clientToLayerCoordinates } from './helpers/events.js';
49
49
 
50
- let {
51
- brush = $bindable({ enabled: false }),
52
- stroke = 'currentColor',
50
+ let { brush = $bindable(), ...markProps }: BrushMarkProps = $props();
51
+
52
+ const DEFAULTS = {
53
+ stroke: 'currentColor',
54
+ strokeDasharray: '2,3',
55
+ strokeOpacity: 0.6,
56
+ resizeHandleSize: 10,
57
+ constrainToDomain: false,
58
+ ...getContext<PlotDefaults>('svelteplot/_defaults').brush
59
+ };
60
+
61
+ const {
62
+ data = [{}],
63
+ stroke,
53
64
  strokeWidth,
54
- strokeDasharray = '2,3',
55
- strokeOpacity = 0.6,
65
+ strokeDasharray,
66
+ strokeOpacity,
56
67
  strokeLinecap,
57
68
  strokeDashoffset,
58
69
  strokeLinejoin,
59
70
  strokeMiterlimit,
60
71
  cursor: forceCursor,
61
72
  limitDimension = false,
62
- constrainToDomain = false,
63
- resizeHandleSize = 10,
73
+ constrainToDomain,
74
+ resizeHandleSize,
64
75
  onbrushstart,
65
76
  onbrushend,
66
77
  onbrush
67
- }: BrushMarkProps = $props();
78
+ }: BrushMarkProps = $derived({
79
+ ...DEFAULTS,
80
+ ...markProps
81
+ });
68
82
 
69
83
  const { getPlotState } = getContext<PlotContext>('svelteplot');
70
84
  const plot = $derived(getPlotState());
@@ -361,4 +375,10 @@
361
375
  {strokeMiterlimit}
362
376
  {strokeWidth} />
363
377
  {/if}
364
- <Frame fill="transparent" inset={-20} {cursor} {onpointerdown} {onpointermove} />
378
+ <Frame
379
+ fill="transparent"
380
+ stroke="transparent"
381
+ inset={-20}
382
+ {cursor}
383
+ {onpointerdown}
384
+ {onpointermove} />
@@ -1,11 +1,17 @@
1
- <script module type="ts">
1
+ <script module lang="ts">
2
2
  export type BrushXMarkProps = Omit<BrushMarkProps, 'limitDimension'>;
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
6
  import Brush, { type BrushMarkProps } from './Brush.svelte';
7
+ import type { PlotDefaults } from '../types.js';
8
+ import { getContext } from 'svelte';
7
9
 
8
- let { brush, ...restProps }: BrushXMarkProps = $props();
10
+ let { brush = $bindable(), ...options }: BrushXMarkProps = $props();
11
+ const DEFAULTS = {
12
+ ...getContext<PlotDefaults>('svelteplot/_defaults').brush,
13
+ ...getContext<PlotDefaults>('svelteplot/_defaults').brushX
14
+ };
9
15
  </script>
10
16
 
11
- <Brush bind:brush limitDimension="x" {...restProps} />
17
+ <Brush bind:brush limitDimension="x" {...DEFAULTS} {...options} />
@@ -1,5 +1,5 @@
1
1
  export type BrushXMarkProps = Omit<BrushMarkProps, 'limitDimension'>;
2
2
  import { type BrushMarkProps } from './Brush.svelte';
3
- declare const BrushX: import("svelte").Component<BrushXMarkProps, {}, "">;
3
+ declare const BrushX: import("svelte").Component<BrushXMarkProps, {}, "brush">;
4
4
  type BrushX = ReturnType<typeof BrushX>;
5
5
  export default BrushX;
@@ -1,11 +1,17 @@
1
- <script module type="ts">
1
+ <script module lang="ts">
2
2
  export type BrushYMarkProps = Omit<BrushMarkProps, 'limitDimension'>;
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
6
  import Brush, { type BrushMarkProps } from './Brush.svelte';
7
+ import type { PlotDefaults } from '../types.js';
8
+ import { getContext } from 'svelte';
7
9
 
8
- let { brush, ...restProps }: BrushYMarkProps = $props();
10
+ let { brush = $bindable(), ...options }: BrushYMarkProps = $props();
11
+ const DEFAULTS = {
12
+ ...getContext<PlotDefaults>('svelteplot/_defaults').brush,
13
+ ...getContext<PlotDefaults>('svelteplot/_defaults').brushY
14
+ };
9
15
  </script>
10
16
 
11
- <Brush bind:brush limitDimension="y" {...restProps} />
17
+ <Brush bind:brush limitDimension="y" {...DEFAULTS} {...options} />
@@ -1,5 +1,5 @@
1
1
  export type BrushYMarkProps = Omit<BrushMarkProps, 'limitDimension'>;
2
2
  import { type BrushMarkProps } from './Brush.svelte';
3
- declare const BrushY: import("svelte").Component<BrushYMarkProps, {}, "">;
3
+ declare const BrushY: import("svelte").Component<BrushYMarkProps, {}, "brush">;
4
4
  type BrushY = ReturnType<typeof BrushY>;
5
5
  export default BrushY;
@@ -8,10 +8,12 @@
8
8
  DataRecord,
9
9
  BaseMarkProps,
10
10
  BaseRectMarkProps,
11
- ChannelAccessor
11
+ ChannelAccessor,
12
+ PlotDefaults
12
13
  } from '../types.js';
13
14
 
14
15
  export type CellMarkProps = BaseMarkProps &
16
+ LinkableMarkProps &
15
17
  BaseRectMarkProps & {
16
18
  data: DataRecord[];
17
19
  x?: ChannelAccessor;
@@ -28,7 +30,20 @@
28
30
  import { isValid } from '../helpers/isValid.js';
29
31
  import RectPath from './helpers/RectPath.svelte';
30
32
 
31
- let { data = [{}], class: className = null, ...options }: CellMarkProps = $props();
33
+ let markProps: CellMarkProps = $props();
34
+
35
+ const DEFAULTS = {
36
+ ...getContext<PlotDefaults>('svelteplot/_defaults').cell
37
+ };
38
+
39
+ const {
40
+ data = [{}],
41
+ class: className = '',
42
+ ...options
43
+ }: CellMarkProps = $derived({
44
+ ...DEFAULTS,
45
+ ...markProps
46
+ });
32
47
 
33
48
  const { getPlotState } = getContext<PlotContext>('svelteplot');
34
49
  const plot = $derived(getPlotState());
@@ -1,10 +1,10 @@
1
1
  import type { DataRecord, BaseMarkProps, BaseRectMarkProps, ChannelAccessor } from '../types.js';
2
- export type CellMarkProps = BaseMarkProps & BaseRectMarkProps & {
2
+ export type CellMarkProps = BaseMarkProps & LinkableMarkProps & BaseRectMarkProps & {
3
3
  data: DataRecord[];
4
4
  x?: ChannelAccessor;
5
5
  y?: ChannelAccessor;
6
6
  };
7
7
  /** For arbitrary rectangles, requires band x and y scales */
8
- declare const Cell: import("svelte").Component<CellMarkProps, {}, "">;
8
+ declare const Cell: import("svelte").Component<any, {}, "">;
9
9
  type Cell = ReturnType<typeof Cell>;
10
10
  export default Cell;
@@ -11,14 +11,14 @@
11
11
  import { range as d3Range, extent } from 'd3-array';
12
12
  import { maybeSymbol } from '../helpers/symbols.js';
13
13
 
14
- import type { DefaultOptions, PlotContext } from '../types.js';
14
+ import type { PlotDefaults, PlotContext } from '../types.js';
15
15
 
16
16
  let { class: className = null }: ColorLegendMarkProps = $props();
17
17
 
18
18
  const { getPlotState } = getContext<PlotContext>('svelteplot');
19
19
  const plot = $derived(getPlotState());
20
20
 
21
- const DEFAULTS = getContext<Partial<DefaultOptions>>('svelteplot/_defaults');
21
+ const DEFAULTS = getContext<Partial<PlotDefaults>>('svelteplot/_defaults');
22
22
 
23
23
  const legendTitle = $derived(plot.options.color.label);
24
24
  const scaleType = $derived(plot.scales.color.type);
@@ -167,6 +167,7 @@
167
167
  .swatch {
168
168
  display: inline-flex;
169
169
  align-items: center;
170
+ column-gap: 0.3rem;
170
171
  }
171
172
  .item-label {
172
173
  vertical-align: super;
@@ -10,7 +10,7 @@
10
10
  symbol?: ChannelAccessor | Snippet<[number, string]>;
11
11
  canvas?: boolean;
12
12
  dotClass?: ConstantAccessor<string>;
13
- };
13
+ } & LinkableMarkProps;
14
14
  </script>
15
15
 
16
16
  <script lang="ts">
@@ -21,8 +21,8 @@
21
21
  BaseMarkProps,
22
22
  ConstantAccessor,
23
23
  ChannelAccessor,
24
- FacetContext,
25
- PlotDefaults
24
+ PlotDefaults,
25
+ LinkableMarkProps
26
26
  } from '../types.js';
27
27
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
28
28
  import { maybeSymbol } from '../helpers/symbols.js';
@@ -33,14 +33,21 @@
33
33
  import { maybeData, isValid } from '../helpers/index.js';
34
34
  import { recordizeXY } from '../transforms/recordize.js';
35
35
  import { addEventHandlers } from './helpers/events.js';
36
+ import Anchor from './helpers/Anchor.svelte';
37
+
38
+ const DEFAULTS = {
39
+ ...getContext<PlotDefaults>('svelteplot/_defaults').dot
40
+ };
36
41
 
37
- let {
42
+ let markProps: DotMarkProps = $props();
43
+
44
+ const {
38
45
  data = [{}],
39
46
  canvas = false,
40
47
  class: className = '',
41
48
  dotClass = null,
42
49
  ...options
43
- }: DotMarkProps = $props();
50
+ }: DotMarkProps = $derived({ ...DEFAULTS, ...markProps });
44
51
 
45
52
  const { getPlotState } = getContext<PlotContext>('svelteplot');
46
53
  const plot = $derived(getPlotState());
@@ -49,10 +56,6 @@
49
56
  return d3Symbol(maybeSymbol(symbolType), size)();
50
57
  }
51
58
 
52
- const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
53
- const { dotRadius } = getContext<PlotDefaults>('svelteplot/_defaults');
54
- let testFacet = $derived(getTestFacet());
55
-
56
59
  const args = $derived(
57
60
  // todo: move sorting to Mark
58
61
  sort(
@@ -81,10 +84,10 @@
81
84
  'fillOpacity',
82
85
  'strokeOpacity'
83
86
  ]}
84
- defaults={{ r: dotRadius, symbol: 'circle' }}
87
+ defaults={{ r: 3, symbol: 'circle' }}
85
88
  {...args}>
86
89
  {#snippet children({ mark, usedScales, scaledData })}
87
- <g class="dots {className || ''}">
90
+ <g class="dot {className || ''}">
88
91
  {#if canvas}
89
92
  <DotCanvas data={scaledData} {mark} />
90
93
  {:else}
@@ -97,19 +100,21 @@
97
100
  'stroke',
98
101
  usedScales
99
102
  )}
100
- <path
101
- transform="translate({d.x}, {d.y})"
102
- d={getSymbolPath(d.symbol, d.r ** 2 * Math.PI)}
103
- class={[
104
- dotClass ? resolveProp(dotClass, d.datum, null) : null,
105
- styleClass
106
- ]}
107
- {style}
108
- use:addEventHandlers={{
109
- getPlotState,
110
- options: args,
111
- datum: d.datum
112
- }} />
103
+ <Anchor {options} datum={d.datum}>
104
+ <path
105
+ transform="translate({d.x}, {d.y})"
106
+ d={getSymbolPath(d.symbol, d.r ** 2 * Math.PI)}
107
+ class={[
108
+ dotClass ? resolveProp(dotClass, d.datum, null) : null,
109
+ styleClass
110
+ ]}
111
+ {style}
112
+ use:addEventHandlers={{
113
+ getPlotState,
114
+ options: args,
115
+ datum: d.datum
116
+ }} />
117
+ </Anchor>
113
118
  {/if}
114
119
  {/each}
115
120
  {/if}