Skip to content

Commit 3f7bf76

Browse files
committed
ts: rect mark props
1 parent bfad61c commit 3f7bf76

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

src/lib/marks/Rect.svelte

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
@component
33
For arbitrary rectangles, requires quantitative x and y scales
44
-->
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>;
1417
interval?: number | string;
15-
} & BaseMarkProps &
16-
LinkableMarkProps &
17-
BaseRectMarkProps;
18-
</script>
19-
20-
<script lang="ts">
18+
className?: string;
19+
}
2120
import Mark from '../Mark.svelte';
2221
import { getContext } from 'svelte';
2322
import { intervalX, intervalY } from '$lib/index.js';
@@ -27,7 +26,8 @@
2726
BaseMarkProps,
2827
BaseRectMarkProps,
2928
ChannelAccessor,
30-
PlotDefaults
29+
PlotDefaults,
30+
LinkableMarkProps
3131
} from '../types.js';
3232
import GroupMultiple from './helpers/GroupMultiple.svelte';
3333
import RectPath from './helpers/RectPath.svelte';
@@ -39,7 +39,7 @@
3939
};
4040
4141
const {
42-
data = [{}],
42+
data = [{} as Datum],
4343
class: className = '',
4444
...options
4545
}: RectMarkProps = $derived({

src/lib/marks/RectX.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<!-- @component
22
Convenience wrapper for rectangles oriented along the x axis
33
-->
4-
<script module lang="ts">
5-
export type RectXMarkProps = Omit<RectMarkProps, 'y'> & { stack?: Partial<StackOptions> };
6-
</script>
74

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';
1011
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';
1314
import type { StackOptions } from '$lib/transforms/stack';
1415
1516
let markProps: RectXMarkProps = $props();
@@ -20,7 +21,7 @@
2021
};
2122
2223
const {
23-
data = [{}],
24+
data = [{} as Datum],
2425
stack,
2526
...options
2627
}: RectXMarkProps = $derived({

src/lib/marks/RectY.svelte

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<!-- @component
22
Convenience wrapper for rectangles oriented along the x axis
33
-->
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';
109
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';
1312
import type { StackOptions } from '$lib/transforms/stack';
1413
1514
let markProps: RectYMarkProps = $props();
@@ -20,7 +19,7 @@
2019
};
2120
2221
const {
23-
data = [{}],
22+
data = [{} as Datum],
2423
stack,
2524
...options
2625
}: RectYMarkProps = $derived({

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy