|
1 | 1 | <!-- @component
|
2 | 2 | Creates connections between pairs of points with optional curve styling and markers
|
3 | 3 | -->
|
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> |
19 | 4 |
|
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 | + } |
21 | 37 | import { getContext, type Snippet } from 'svelte';
|
22 | 38 | import type {
|
23 | 39 | PlotContext,
|
|
47 | 63 | ...getContext<PlotDefaults>('svelteplot/_defaults').link
|
48 | 64 | };
|
49 | 65 | const {
|
50 |
| - data = [{}], |
| 66 | + data = [{} as Datum], |
51 | 67 | curve = 'auto',
|
52 | 68 | tension = 0,
|
53 | 69 | text,
|
|
0 commit comments