Skip to content

Commit 114cbab

Browse files
committed
ts: improve link mark props
1 parent de86fae commit 114cbab

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

src/lib/marks/Link.svelte

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
<!-- @component
22
Creates connections between pairs of points with optional curve styling and markers
33
-->
4-
<script lang="ts" module>
5-
export type LinkMarkProps = BaseMarkProps &
6-
MarkerOptions & {
7-
data: DataRecord[];
8-
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
9-
x1: ChannelAccessor;
10-
y1: ChannelAccessor;
11-
x2: ChannelAccessor;
12-
y2: ChannelAccessor;
13-
curve?: 'auto' | CurveName | CurveFactory;
14-
tension?: number;
15-
text: ConstantAccessor<string>;
16-
children?: Snippet;
17-
};
18-
</script>
194

20-
<script lang="ts">
5+
<script lang="ts" generics="Datum extends DataRecord">
6+
interface LinkMarkProps extends BaseMarkProps<Datum>, MarkerOptions {
7+
data: Datum[];
8+
sort?: ConstantAccessor<RawValue> | { channel: 'stroke' | 'fill' };
9+
/**
10+
* the x1 channel accessor for the start of the link
11+
*/
12+
x1: ChannelAccessor<Datum>;
13+
/**
14+
* the y1 channel accessor for the start of the link
15+
*/
16+
y1: ChannelAccessor<Datum>;
17+
/**
18+
* the x2 channel accessor for the end of the link
19+
*/
20+
x2: ChannelAccessor<Datum>;
21+
22+
y2: ChannelAccessor<Datum>;
23+
/**
24+
* the curve type, defaults to 'auto' which uses a linear curve for planar projections
25+
* and a spherical line for geographic projections
26+
*/
27+
curve?: 'auto' | CurveName | CurveFactory;
28+
/**
29+
* the tension of the curve, defaults to 0
30+
*/
31+
tension?: number;
32+
/**
33+
* the text label for the link, can be a constant or a function
34+
*/
35+
text?: ConstantAccessor<string, Datum>;
36+
}
2137
import { getContext, type Snippet } from 'svelte';
2238
import type {
2339
PlotContext,
@@ -47,7 +63,7 @@
4763
...getContext<PlotDefaults>('svelteplot/_defaults').link
4864
};
4965
const {
50-
data = [{}],
66+
data = [{} as Datum],
5167
curve = 'auto',
5268
tension = 0,
5369
text,

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