File tree Expand file tree Collapse file tree 3 files changed +34
-34
lines changed Expand file tree Collapse file tree 3 files changed +34
-34
lines changed Original file line number Diff line number Diff line change 2
2
@component
3
3
For arbitrary rectangles, requires quantitative x and y scales
4
4
-->
5
- <script module lang =" ts" >
6
- export type RectMarkProps = {
7
- data: DataRecord [];
8
- x? : ChannelAccessor ;
9
- x1? : ChannelAccessor ;
10
- x2? : ChannelAccessor ;
11
- y? : ChannelAccessor ;
12
- y1? : ChannelAccessor ;
13
- y2? : ChannelAccessor ;
5
+ <script lang =" ts" generics =" Datum extends DataRecord" >
6
+ interface RectMarkProps
7
+ extends BaseMarkProps <Datum >,
8
+ LinkableMarkProps <Datum >,
9
+ BaseRectMarkProps <Datum > {
10
+ data: Datum [];
11
+ x? : ChannelAccessor <Datum >;
12
+ x1? : ChannelAccessor <Datum >;
13
+ x2? : ChannelAccessor <Datum >;
14
+ y? : ChannelAccessor <Datum >;
15
+ y1? : ChannelAccessor <Datum >;
16
+ y2? : ChannelAccessor <Datum >;
14
17
interval? : number | string ;
15
- } & BaseMarkProps &
16
- LinkableMarkProps &
17
- BaseRectMarkProps ;
18
- </script >
19
-
20
- <script lang =" ts" >
18
+ className? : string ;
19
+ }
21
20
import Mark from ' ../Mark.svelte' ;
22
21
import { getContext } from ' svelte' ;
23
22
import { intervalX , intervalY } from ' $lib/index.js' ;
27
26
BaseMarkProps ,
28
27
BaseRectMarkProps ,
29
28
ChannelAccessor ,
30
- PlotDefaults
29
+ PlotDefaults ,
30
+ LinkableMarkProps
31
31
} from ' ../types.js' ;
32
32
import GroupMultiple from ' ./helpers/GroupMultiple.svelte' ;
33
33
import RectPath from ' ./helpers/RectPath.svelte' ;
39
39
};
40
40
41
41
const {
42
- data = [{}],
42
+ data = [{} as Datum ],
43
43
class : className = ' ' ,
44
44
... options
45
45
}: RectMarkProps = $derived ({
Original file line number Diff line number Diff line change 1
1
<!-- @component
2
2
Convenience wrapper for rectangles oriented along the x axis
3
3
-->
4
- <script module lang =" ts" >
5
- export type RectXMarkProps = Omit <RectMarkProps , ' y' > & { stack? : Partial <StackOptions > };
6
- </script >
7
4
8
- <script lang =" ts" >
9
- import Rect , { type RectMarkProps } from ' ./Rect.svelte' ;
5
+ <script lang =" ts" generics =" Datum extends DataRecord" >
6
+ interface RectXMarkProps extends Omit <ComponentProps <typeof Rect >, ' y' > {
7
+ stack? : Partial <StackOptions >;
8
+ }
9
+
10
+ import Rect from ' ./Rect.svelte' ;
10
11
import { intervalY , stackX , recordizeX } from ' $lib/index.js' ;
11
- import type { PlotContext , PlotDefaults } from ' ../types.js' ;
12
- import { getContext } from ' svelte' ;
12
+ import type { DataRecord , PlotContext , PlotDefaults } from ' ../types.js' ;
13
+ import { getContext , type ComponentProps } from ' svelte' ;
13
14
import type { StackOptions } from ' $lib/transforms/stack' ;
14
15
15
16
let markProps: RectXMarkProps = $props ();
20
21
};
21
22
22
23
const {
23
- data = [{}],
24
+ data = [{} as Datum ],
24
25
stack,
25
26
... options
26
27
}: RectXMarkProps = $derived ({
Original file line number Diff line number Diff line change 1
1
<!-- @component
2
2
Convenience wrapper for rectangles oriented along the x axis
3
3
-->
4
- <script module lang =" ts" >
5
- export type RectYMarkProps = Omit <RectMarkProps , ' x' > & { stack? : Partial <StackOptions > };
6
- </script >
7
-
8
- <script lang =" ts" >
9
- import Rect , { type RectMarkProps } from ' ./Rect.svelte' ;
4
+ <script lang =" ts" generics =" Datum extends DataRecord" >
5
+ interface RectYMarkProps extends Omit <ComponentProps <typeof Rect >, ' y' > {
6
+ stack? : Partial <StackOptions >;
7
+ }
8
+ import Rect from ' ./Rect.svelte' ;
10
9
import { intervalX , stackY , recordizeY } from ' $lib/index.js' ;
11
- import type { PlotContext , PlotDefaults } from ' ../types.js' ;
12
- import { getContext } from ' svelte' ;
10
+ import type { DataRecord , PlotContext , PlotDefaults } from ' ../types.js' ;
11
+ import { getContext , type ComponentProps } from ' svelte' ;
13
12
import type { StackOptions } from ' $lib/transforms/stack' ;
14
13
15
14
let markProps: RectYMarkProps = $props ();
20
19
};
21
20
22
21
const {
23
- data = [{}],
22
+ data = [{} as Datum ],
24
23
stack,
25
24
... options
26
25
}: RectYMarkProps = $derived ({
You can’t perform that action at this time.
0 commit comments