svelteplot 0.10.3-pr-485.1 → 0.10.3-pr-488.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.
@@ -35,6 +35,7 @@
35
35
  BaseMarkProps,
36
36
  BaseRectMarkProps,
37
37
  ChannelAccessor,
38
+ DataRecord,
38
39
  LinkableMarkProps
39
40
  } from '../types/index.js';
40
41
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
@@ -50,7 +51,7 @@
50
51
 
51
52
  const {
52
53
  data = [{} as Datum],
53
- class: className = null,
54
+ class: className = '',
54
55
  stack,
55
56
  canvas = false,
56
57
  ...options
@@ -81,20 +82,20 @@
81
82
  {@const rectCanvasData = scaledData
82
83
  .filter((d) => d.valid)
83
84
  .map((d) => {
84
- const minx = Math.min(d.x1, d.x2);
85
- const maxx = Math.max(d.x1, d.x2);
85
+ const minx = Math.min(d.x1 as number, d.x2 as number);
86
+ const maxx = Math.max(d.x1 as number, d.x2 as number);
86
87
 
87
88
  return {
88
89
  ...d,
89
90
  x1: minx,
90
91
  x2: maxx,
91
- y1: d.y - bw * 0.5,
92
- y2: d.y + bw * 0.5
92
+ y1: (d.y as number) - bw * 0.5,
93
+ y2: (d.y as number) + bw * 0.5
93
94
  };
94
95
  })}
95
96
  <GroupMultiple class={barGroupClass} length={scaledData.length}>
96
97
  <RectCanvas
97
- {options}
98
+ options={options as BaseMarkProps<DataRecord> & BaseRectMarkProps<DataRecord>}
98
99
  data={rectCanvasData}
99
100
  {usedScales}
100
101
  useInsetAsFallbackHorizontally={false} />
@@ -102,17 +103,18 @@
102
103
  {:else}
103
104
  <GroupMultiple class="bar-x" length={scaledData.length}>
104
105
  {#each scaledData as d, i (i)}
105
- {@const minx = Math.min(d.x1, d.x2)}
106
- {@const maxx = Math.max(d.x1, d.x2)}
106
+ {@const minx = Math.min(d.x1 as number, d.x2 as number)}
107
+ {@const maxx = Math.max(d.x1 as number, d.x2 as number)}
107
108
  {#if d.valid}
108
109
  <RectPath
109
110
  {usedScales}
110
111
  class={className}
111
- {options}
112
+ options={options as BaseRectMarkProps<DataRecord> &
113
+ BaseMarkProps<DataRecord>}
112
114
  datum={d}
113
115
  x={minx}
114
116
  useInsetAsFallbackHorizontally={false}
115
- y={d.y - bw * 0.5}
117
+ y={(d.y as number) - bw * 0.5}
116
118
  width={maxx - minx}
117
119
  height={bw} />
118
120
  {/if}
@@ -34,6 +34,7 @@
34
34
  BaseMarkProps,
35
35
  BaseRectMarkProps,
36
36
  ChannelAccessor,
37
+ DataRecord,
37
38
  DataRow,
38
39
  LinkableMarkProps
39
40
  } from '../types/index.js';
@@ -50,8 +51,8 @@
50
51
  let markProps: BarYMarkProps = $props();
51
52
 
52
53
  const {
53
- data = [{}],
54
- class: className = null,
54
+ data = [{} as Datum],
55
+ class: className = '',
55
56
  stack,
56
57
  canvas = false,
57
58
  ...options
@@ -80,20 +81,20 @@
80
81
  {@const rectCanvasData = scaledData
81
82
  .filter((d) => d.valid)
82
83
  .map((d) => {
83
- const miny = Math.min(d.y1, d.y2);
84
- const maxy = Math.max(d.y1, d.y2);
84
+ const miny = Math.min(d.y1 as number, d.y2 as number);
85
+ const maxy = Math.max(d.y1 as number, d.y2 as number);
85
86
 
86
87
  return {
87
88
  ...d,
88
- x1: d.x - bw * 0.5,
89
- x2: d.x + bw * 0.5,
89
+ x1: (d.x as number) - bw * 0.5,
90
+ x2: (d.x as number) + bw * 0.5,
90
91
  y1: miny,
91
92
  y2: maxy
92
93
  };
93
94
  })}
94
95
  <GroupMultiple class={barGroupClass} length={scaledData.length}>
95
96
  <RectCanvas
96
- {options}
97
+ options={options as BaseMarkProps<DataRecord> & BaseRectMarkProps<DataRecord>}
97
98
  data={rectCanvasData}
98
99
  {usedScales}
99
100
  useInsetAsFallbackVertically={false} />
@@ -101,11 +102,11 @@
101
102
  {:else}
102
103
  <GroupMultiple class="bar-y" length={scaledData.length}>
103
104
  {#each scaledData as d, i (i)}
104
- {@const miny = Math.min(d.y1, d.y2)}
105
- {@const maxy = Math.max(d.y1, d.y2)}
105
+ {@const miny = Math.min(d.y1 as number, d.y2 as number)}
106
+ {@const maxy = Math.max(d.y1 as number, d.y2 as number)}
106
107
  {#if d.valid}
107
108
  <RectPath
108
- x={d.x - bw * 0.5}
109
+ x={(d.x as number) - bw * 0.5}
109
110
  y={miny}
110
111
  options={args}
111
112
  class={className}
@@ -27,6 +27,7 @@
27
27
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
28
28
  import type {
29
29
  DataRecord,
30
+ DataRow,
30
31
  BaseMarkProps,
31
32
  ConstantAccessor,
32
33
  ChannelAccessor,
@@ -51,19 +52,17 @@
51
52
  });
52
53
 
53
54
  const plot = usePlot();
54
- const args = $derived(recordizeX({ data, ...options }, { withIndex: false }));
55
+ const args = $derived(
56
+ recordizeX({ data: data as DataRow[], ...options }, { withIndex: false })
57
+ );
55
58
  </script>
56
59
 
57
- <Mark
58
- type="ruleX"
59
- channels={['x', 'y1', 'y2', 'stroke', 'opacity', 'strokeOpacity']}
60
- {...markProps}
61
- {...args}>
60
+ <Mark type="ruleX" channels={['x', 'y1', 'y2', 'stroke', 'opacity', 'strokeOpacity']} {...args}>
62
61
  {#snippet children({ mark, scaledData, usedScales })}
63
62
  {#if canvas}
64
63
  <RuleCanvas
65
64
  data={scaledData}
66
- options={args}
65
+ options={args as any}
67
66
  {usedScales}
68
67
  orientation="vertical"
69
68
  marginTop={plot.options.marginTop}
@@ -73,13 +72,13 @@
73
72
  class="rule-x {className || ''}"
74
73
  length={className ? 2 : scaledData.length}>
75
74
  {#each scaledData as d, i (i)}
76
- {@const inset = resolveProp(args.inset, d.datum, 0)}
77
- {@const insetTop = resolveProp(args.insetTop, d.datum, 0)}
78
- {@const insetBottom = resolveProp(args.insetBottom, d.datum, 0)}
75
+ {@const inset = resolveProp(args.inset, d.datum, 0) as number}
76
+ {@const insetTop = resolveProp(args.insetTop, d.datum, 0) as number}
77
+ {@const insetBottom = resolveProp(args.insetBottom, d.datum, 0) as number}
79
78
  {@const [style, styleClass] = resolveStyles(
80
79
  plot,
81
80
  d,
82
- args,
81
+ args as any,
83
82
  'stroke',
84
83
  usedScales
85
84
  )}
@@ -27,6 +27,7 @@
27
27
  import { resolveProp, resolveStyles } from '../helpers/resolve.js';
28
28
  import type {
29
29
  DataRecord,
30
+ DataRow,
30
31
  BaseMarkProps,
31
32
  ConstantAccessor,
32
33
  ChannelAccessor
@@ -51,19 +52,17 @@
51
52
  });
52
53
 
53
54
  const plot = usePlot();
54
- const args = $derived(recordizeY({ data, ...options }, { withIndex: false }));
55
+ const args = $derived(
56
+ recordizeY({ data: data as DataRow[], ...options }, { withIndex: false })
57
+ );
55
58
  </script>
56
59
 
57
- <Mark
58
- type="ruleY"
59
- channels={['y', 'x1', 'x2', 'stroke', 'opacity', 'strokeOpacity']}
60
- {...markProps}
61
- {...args}>
60
+ <Mark type="ruleY" channels={['y', 'x1', 'x2', 'stroke', 'opacity', 'strokeOpacity']} {...args}>
62
61
  {#snippet children({ scaledData, usedScales })}
63
62
  {#if canvas}
64
63
  <RuleCanvas
65
64
  data={scaledData}
66
- options={args}
65
+ options={args as any}
67
66
  {usedScales}
68
67
  orientation="horizontal"
69
68
  marginLeft={plot.options.marginLeft}
@@ -73,13 +72,13 @@
73
72
  class="rule-y {className || ''}"
74
73
  length={className ? 2 : args.data.length}>
75
74
  {#each scaledData as d, i (i)}
76
- {@const inset = resolveProp(args.inset, d.datum, 0)}
77
- {@const insetLeft = resolveProp(args.insetLeft, d.datum, 0)}
78
- {@const insetRight = resolveProp(args.insetRight, d.datum, 0)}
75
+ {@const inset = resolveProp(args.inset, d.datum, 0) as number}
76
+ {@const insetLeft = resolveProp(args.insetLeft, d.datum, 0) as number}
77
+ {@const insetRight = resolveProp(args.insetRight, d.datum, 0) as number}
79
78
  {@const [style, styleClass] = resolveStyles(
80
79
  plot,
81
80
  d,
82
- args,
81
+ args as any,
83
82
  'stroke',
84
83
  usedScales
85
84
  )}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.10.3-pr-485.1",
3
+ "version": "0.10.3-pr-488.1",
4
4
  "description": "A Svelte-native data visualization framework based on the layered grammar of graphics principles.",
5
5
  "keywords": [
6
6
  "svelte",