svelteplot 0.2.10-pr-110.0 → 0.2.10-pr-110.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,9 +67,12 @@
67
67
 
68
68
  const {
69
69
  data = [{}],
70
- class: className = null,
70
+ class: className = '',
71
71
  ...options
72
- }: ArrowMarkProps = $derived({ ...DEFAULTS, ...markProps });
72
+ }: ArrowMarkProps = $derived({
73
+ ...DEFAULTS,
74
+ ...markProps
75
+ });
73
76
 
74
77
  const { getPlotState } = getContext<PlotContext>('svelteplot');
75
78
  const plot = $derived(getPlotState());
@@ -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} />
@@ -4,8 +4,14 @@
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;
@@ -4,8 +4,14 @@
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,7 +8,8 @@
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 &
@@ -29,7 +30,20 @@
29
30
  import { isValid } from '../helpers/isValid.js';
30
31
  import RectPath from './helpers/RectPath.svelte';
31
32
 
32
- 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
+ });
33
47
 
34
48
  const { getPlotState } = getContext<PlotContext>('svelteplot');
35
49
  const plot = $derived(getPlotState());
@@ -22,7 +22,8 @@
22
22
  PlotContext,
23
23
  BaseMarkProps,
24
24
  ConstantAccessor,
25
- LinkableMarkProps
25
+ LinkableMarkProps,
26
+ PlotDefaults
26
27
  } from '../types.js';
27
28
  import Mark from '../Mark.svelte';
28
29
  import { geoPath } from 'd3-geo';
@@ -38,14 +39,23 @@
38
39
  const { getPlotState } = getContext<PlotContext>('svelteplot');
39
40
  const plot = $derived(getPlotState());
40
41
 
41
- let {
42
+ let markProps: GeoMarkProps = $props();
43
+
44
+ const DEFAULTS = {
45
+ ...getContext<PlotDefaults>('svelteplot/_defaults').geo
46
+ };
47
+
48
+ const {
42
49
  data = [{}],
43
50
  canvas = false,
44
51
  geoType,
45
52
  dragRotate,
46
- class: className = null,
53
+ class: className = '',
47
54
  ...options
48
- }: GeoMarkProps = $props();
55
+ }: GeoMarkProps = $derived({
56
+ ...DEFAULTS,
57
+ ...markProps
58
+ });
49
59
 
50
60
  const path = $derived(
51
61
  callWithProps(geoPath, [plot.scales.projection], {
@@ -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<PlotDefaults>>('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
 
@@ -26,12 +26,26 @@
26
26
  DataRecord,
27
27
  BaseMarkProps,
28
28
  BaseRectMarkProps,
29
- ChannelAccessor
29
+ ChannelAccessor,
30
+ PlotDefaults
30
31
  } from '../types.js';
31
32
  import GroupMultiple from './helpers/GroupMultiple.svelte';
32
33
  import RectPath from './helpers/RectPath.svelte';
33
34
 
34
- 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
+ });
35
49
 
36
50
  const { getPlotState } = getContext<PlotContext>('svelteplot');
37
51
  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 { 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());
@@ -8,8 +8,21 @@
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" />
@@ -8,16 +8,26 @@
8
8
 
9
9
  <script lang="ts">
10
10
  import Vector, { type VectorMarkProps } from './Vector.svelte';
11
- let { data = [{}], ...options }: SpikeMarkProps = $props();
11
+ import type { PlotDefaults } from '../types.js';
12
+ import { getContext } from 'svelte';
13
+
14
+ let markProps: SpikeMarkProps = $props();
15
+
16
+ const DEFAULTS = {
17
+ fill: 'currentColor',
18
+ fillOpacity: 0.3,
19
+ strokeWidth: 1,
20
+ anchor: 'start' as const,
21
+ stroke: 'currentColor',
22
+ sort: { channel: '-y' },
23
+ shape: 'spike' as const,
24
+ ...getContext<PlotDefaults>('svelteplot/_defaults').spike
25
+ };
26
+
27
+ const { data = [{}], ...options }: SpikeMarkProps = $derived({
28
+ ...DEFAULTS,
29
+ ...markProps
30
+ });
12
31
  </script>
13
32
 
14
- <Vector
15
- {data}
16
- fill={options.stroke || 'currentColor'}
17
- fillOpacity={0.3}
18
- strokeWidth={1}
19
- anchor="start"
20
- stroke="currentColor"
21
- sort={{ channel: '-y' }}
22
- {...options}
23
- shape="spike" />
33
+ <Vector {data} {...options} />
@@ -39,13 +39,30 @@
39
39
  DataRecord,
40
40
  BaseMarkProps,
41
41
  ConstantAccessor,
42
- ChannelAccessor
42
+ ChannelAccessor,
43
+ PlotDefaults
43
44
  } from '../types.js';
44
45
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
45
46
  import Mark from '../Mark.svelte';
46
47
  import { sort } from '../index.js';
47
48
 
48
- let { data = [{}], class: className = null, ...options }: TextMarkProps = $props();
49
+ const DEFAULTS = {
50
+ fontSize: 12,
51
+ fontWeight: 500,
52
+ strokeWidth: 1.6,
53
+ ...getContext<PlotDefaults>('svelteplot/_defaults').text
54
+ };
55
+
56
+ let markProps: TextMarkProps = $props();
57
+
58
+ const {
59
+ data = [{}],
60
+ class: className = '',
61
+ ...options
62
+ }: TextMarkProps = $derived({
63
+ ...DEFAULTS,
64
+ ...markProps
65
+ });
49
66
 
50
67
  const { getPlotState } = getContext<PlotContext>('svelteplot');
51
68
  let plot = $derived(getPlotState());
@@ -54,7 +71,7 @@
54
71
  bottom: 'auto',
55
72
  middle: 'central',
56
73
  top: 'hanging'
57
- };
74
+ } as const;
58
75
 
59
76
  const args = $derived(
60
77
  sort({
@@ -77,9 +94,10 @@
77
94
  'strokeOpacity',
78
95
  'fillOpacity'
79
96
  ]}
97
+ required={['x', 'y']}
80
98
  {...args}>
81
99
  {#snippet children({ mark, scaledData, usedScales })}
82
- <GroupMultiple class="text {className || null}" length={className ? 2 : args.data.length}>
100
+ <GroupMultiple class="text {className}" length={className ? 2 : args.data.length}>
83
101
  {#each scaledData as d, i (i)}
84
102
  {#if d.valid}
85
103
  {@const title = resolveProp(args.title, d.datum, '')}
@@ -31,7 +31,8 @@
31
31
  BaseMarkProps,
32
32
  ChannelAccessor,
33
33
  DataRow,
34
- FacetContext
34
+ FacetContext,
35
+ PlotDefaults
35
36
  } from '../types.js';
36
37
  import { recordizeX } from '../index.js';
37
38
  import { projectX, projectY } from '../helpers/scales.js';
@@ -41,7 +42,19 @@
41
42
  const { getPlotState } = getContext<PlotContext>('svelteplot');
42
43
  let plot = $derived(getPlotState());
43
44
 
44
- let { data = [{}], ...options }: TickXMarkProps = $props();
45
+ let markProps: TickXMarkProps = $props();
46
+ const DEFAULTS = {
47
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tick,
48
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tickX
49
+ };
50
+ const {
51
+ data = [{}],
52
+ class: className = '',
53
+ ...options
54
+ }: TickXMarkProps = $derived({
55
+ ...DEFAULTS,
56
+ ...markProps
57
+ });
45
58
 
46
59
  let args = $derived(recordizeX({ data, ...options }, { withIndex: false }));
47
60
 
@@ -32,7 +32,8 @@
32
32
  ChannelAccessor,
33
33
  DataRow,
34
34
  FacetContext,
35
- ConstantAccessor
35
+ ConstantAccessor,
36
+ PlotDefaults
36
37
  } from '../types.js';
37
38
  import { recordizeY } from '../index.js';
38
39
  import { projectX, projectY } from '../helpers/scales.js';
@@ -42,7 +43,19 @@
42
43
  const { getPlotState } = getContext<PlotContext>('svelteplot');
43
44
  let plot = $derived(getPlotState());
44
45
 
45
- let { data = [{}], ...options }: TickYMarkProps = $props();
46
+ let markProps: TickYMarkProps = $props();
47
+ const DEFAULTS = {
48
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tick,
49
+ ...getContext<PlotDefaults>('svelteplot/_defaults').tickY
50
+ };
51
+ const {
52
+ data = [{}],
53
+ class: className = '',
54
+ ...options
55
+ }: TickYMarkProps = $derived({
56
+ ...DEFAULTS,
57
+ ...markProps
58
+ });
46
59
 
47
60
  let args = $derived(recordizeY({ data, ...options }, { withIndex: false }));
48
61
 
@@ -9,7 +9,8 @@
9
9
  BaseMarkProps,
10
10
  ConstantAccessor,
11
11
  ChannelAccessor,
12
- FacetContext
12
+ FacetContext,
13
+ PlotDefaults
13
14
  } from '../types.js';
14
15
 
15
16
  type D3Path = ReturnType<typeof import('d3-path').path>;
@@ -53,19 +54,26 @@
53
54
  const defaultRadius = 3.5;
54
55
 
55
56
  // The size of the arrowhead is proportional to its length, but we still allow
56
- // the relative size of the head to be controlled via the marks width option;
57
+ // the relative size of the head to be controlled via the mark's width option;
57
58
  // doubling the default radius will produce an arrowhead that is twice as big.
58
- // That said, well probably want a arrow with a fixed head size, too.
59
+ // That said, we'll probably want a arrow with a fixed head size, too.
59
60
  const wingRatio = defaultRadius * 5;
60
61
 
61
- let {
62
+ let markProps: VectorMarkProps = $props();
63
+ const DEFAULTS = {
64
+ ...getContext<PlotDefaults>('svelteplot/_defaults').vector
65
+ };
66
+ const {
62
67
  data = [{}],
63
68
  canvas,
64
69
  shape = 'arrow',
65
70
  anchor = 'middle',
66
71
  r = defaultRadius,
67
72
  ...options
68
- }: VectorMarkProps = $props();
73
+ }: VectorMarkProps = $derived({
74
+ ...DEFAULTS,
75
+ ...markProps
76
+ });
69
77
 
70
78
  const { getPlotState } = getContext<PlotContext>('svelteplot');
71
79
  const plot = $derived(getPlotState());
package/dist/types.d.ts CHANGED
@@ -32,6 +32,9 @@ import type { RuleYMarkProps } from './marks/RuleY.svelte';
32
32
  import type { TickYMarkProps } from './marks/TickY.svelte';
33
33
  import type { GridYMarkProps } from './marks/GridY.svelte';
34
34
  import type { GridXMarkProps } from './marks/GridX.svelte';
35
+ import type { PointerMarkProps } from './marks/Pointer.svelte';
36
+ import type { BoxXMarkProps } from './marks/BoxX.svelte';
37
+ import type { BoxYMarkProps } from './marks/BoxY.svelte';
35
38
  export type MarkType = 'area' | 'arrow' | 'axisX' | 'axisY' | 'barX' | 'barY' | 'cell' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY';
36
39
  export type ScaleName = 'x' | 'y' | 'r' | 'color' | 'opacity' | 'length' | 'symbol' | 'fx' | 'fy' | 'projection';
37
40
  export type ScaleType = 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
@@ -601,7 +604,7 @@ export type AutoMarginStores = {
601
604
  autoMarginRight: Writable<Map<string, number>>;
602
605
  autoMarginBottom: Writable<Map<string, number>>;
603
606
  };
604
- type IgnoreDefaults = 'data' | 'facet' | ChannelName | 'title' | 'automatic';
607
+ type IgnoreDefaults = 'data' | 'facet' | ChannelName | 'title' | 'automatic' | 'children';
605
608
  /**
606
609
  * these are the default options for the plot marks that can be set using
607
610
  * the 'svelteplot/defaults' context.
@@ -700,6 +703,18 @@ export type PlotDefaults = {
700
703
  * default props for barY marks
701
704
  */
702
705
  barY: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
706
+ /**
707
+ * default props for box marks, applied to boxX and boxY marks
708
+ */
709
+ box: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
710
+ /**
711
+ * default props for boxX marks
712
+ */
713
+ boxX: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
714
+ /**
715
+ * default props for boxY marks
716
+ */
717
+ boxY: Partial<Omit<BoxYMarkProps, IgnoreDefaults>>;
703
718
  /**
704
719
  * default props for brush marks, applied to brush, brushX and brushY marks
705
720
  */
@@ -760,6 +775,10 @@ export type PlotDefaults = {
760
775
  * default props for link marks
761
776
  */
762
777
  link: Partial<Omit<LinkMarkProps, IgnoreDefaults>>;
778
+ /**
779
+ * default props for pointer marks
780
+ */
781
+ pointer: Partial<Omit<PointerMarkProps, IgnoreDefaults>>;
763
782
  /**
764
783
  * default props for rect marks, applied to rect and rectX marks
765
784
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.2.10-pr-110.0",
3
+ "version": "0.2.10-pr-110.2",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",