layerchart 2.0.0-next.57 → 2.0.0-next.59
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.
- package/dist/components/AnnotationLine.svelte +112 -66
- package/dist/components/AnnotationLine.svelte.d.ts +10 -2
- package/dist/components/AnnotationPoint.svelte +97 -23
- package/dist/components/AnnotationPoint.svelte.d.ts +8 -1
- package/dist/components/GeoPath.svelte +4 -4
- package/dist/components/Legend.svelte +1 -0
- package/dist/components/Link.svelte +261 -75
- package/dist/components/Link.svelte.d.ts +69 -26
- package/dist/components/Text.svelte +1 -1
- package/dist/components/Voronoi.svelte +35 -6
- package/dist/components/Voronoi.svelte.d.ts +9 -0
- package/dist/components/charts/__screenshots__/BarChart.svelte.test.ts/BarChart-separate-data-per-series-should-render-stacked-series-with-separate-data-arrays-1.png +0 -0
- package/dist/components/charts/__screenshots__/BarChart.svelte.test.ts/BarChart-separate-data-per-series-should-render-stacked-series-with-separate-data-arrays-2.png +0 -0
- package/dist/components/charts/__screenshots__/DefaultTooltip.svelte.test.ts/DefaultTooltip-ScatterChart--single-point--quadtree-mode--should-show-series-header-for-multi-series-1.png +0 -0
- package/dist/components/charts/__screenshots__/DefaultTooltip.svelte.test.ts/DefaultTooltip-ScatterChart--single-point--quadtree-mode--should-show-series-header-for-multi-series-2.png +0 -0
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -2
- package/dist/components/tooltip/TooltipContext.svelte +39 -10
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +14 -0
- package/dist/states/brush.svelte.d.ts +1 -1
- package/dist/states/chart.svelte.js +24 -8
- package/dist/states/chart.svelte.test.js +181 -0
- package/dist/utils/linkUtils.d.ts +42 -0
- package/dist/utils/{connectorUtils.js → linkUtils.js} +56 -6
- package/package.json +1 -1
- package/dist/components/Connector.svelte +0 -167
- package/dist/components/Connector.svelte.d.ts +0 -56
- package/dist/utils/connectorUtils.d.ts +0 -34
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
export type ConnectorPropsWithoutHTML = {
|
|
3
|
-
/**
|
|
4
|
-
* The coordinates of the start point of the connector.
|
|
5
|
-
* @default { x: 0, y: 0 }
|
|
6
|
-
*/
|
|
7
|
-
source: ConnectorCoords;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The coordinates of the end point of the connector.
|
|
11
|
-
*
|
|
12
|
-
* @default { x: 100, y: 100 }
|
|
13
|
-
*/
|
|
14
|
-
target: ConnectorCoords;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The sweep direction of the connector.
|
|
18
|
-
*
|
|
19
|
-
* @default 'horizontal-vertical'
|
|
20
|
-
*/
|
|
21
|
-
sweep?: ConnectorSweep;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The type of the connector.
|
|
25
|
-
*
|
|
26
|
-
* Set to `'d3'` to use a D3 curve function via the `curve` prop.
|
|
27
|
-
*
|
|
28
|
-
* @default 'rounded'
|
|
29
|
-
*/
|
|
30
|
-
type?: ConnectorType;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The radius of the connector.
|
|
34
|
-
*
|
|
35
|
-
* Only used when type is `'beveled'` or `'rounded'`
|
|
36
|
-
*
|
|
37
|
-
* @default 20
|
|
38
|
-
*/
|
|
39
|
-
radius?: number;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The D3 curve function to use for the connector.
|
|
43
|
-
*
|
|
44
|
-
* Only used when type is `'d3'`
|
|
45
|
-
*
|
|
46
|
-
* @default `d3.curveLinear`
|
|
47
|
-
*/
|
|
48
|
-
curve?: CurveFactory;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Interpret `source`/`target` as polar coordinates (`x` = angle, `y` = radius)
|
|
52
|
-
* and render the path in radial space. Defaults to `ctx.radial` when unset.
|
|
53
|
-
*/
|
|
54
|
-
radial?: boolean;
|
|
55
|
-
} & PathPropsWithoutHTML;
|
|
56
|
-
|
|
57
|
-
export type ConnectorProps = ConnectorPropsWithoutHTML &
|
|
58
|
-
Without<PathProps, ConnectorPropsWithoutHTML>;
|
|
59
|
-
</script>
|
|
60
|
-
|
|
61
|
-
<script lang="ts">
|
|
62
|
-
import { type CurveFactory, curveLinear } from 'd3-shape';
|
|
63
|
-
import {
|
|
64
|
-
getConnectorD3Path,
|
|
65
|
-
getConnectorPresetPath,
|
|
66
|
-
getConnectorRadialD3Path,
|
|
67
|
-
getConnectorRadialPresetPath,
|
|
68
|
-
type ConnectorCoords,
|
|
69
|
-
type ConnectorSweep,
|
|
70
|
-
type ConnectorType,
|
|
71
|
-
} from '../utils/connectorUtils.js';
|
|
72
|
-
import { getChartContext } from '../contexts/chart.js';
|
|
73
|
-
import Path, { type PathProps, type PathPropsWithoutHTML } from './Path.svelte';
|
|
74
|
-
import type { Without } from '../utils/types.js';
|
|
75
|
-
import { createId } from '../utils/createId.js';
|
|
76
|
-
import { extractLayerProps } from '../utils/attributes.js';
|
|
77
|
-
import MarkerWrapper from './MarkerWrapper.svelte';
|
|
78
|
-
import {
|
|
79
|
-
createMotion,
|
|
80
|
-
extractTweenConfig,
|
|
81
|
-
type ResolvedMotion,
|
|
82
|
-
} from '../utils/motion.svelte.js';
|
|
83
|
-
import { interpolatePath } from 'd3-interpolate-path';
|
|
84
|
-
|
|
85
|
-
const uid = $props.id();
|
|
86
|
-
|
|
87
|
-
let {
|
|
88
|
-
source = { x: 0, y: 0 },
|
|
89
|
-
target = { x: 100, y: 100 },
|
|
90
|
-
sweep: sweepProp,
|
|
91
|
-
type = 'rounded',
|
|
92
|
-
radius = 20,
|
|
93
|
-
curve = curveLinear,
|
|
94
|
-
radial: radialProp,
|
|
95
|
-
pathRef = $bindable(),
|
|
96
|
-
pathData: pathDataProp,
|
|
97
|
-
marker,
|
|
98
|
-
markerStart,
|
|
99
|
-
markerMid,
|
|
100
|
-
markerEnd,
|
|
101
|
-
motion,
|
|
102
|
-
...restProps
|
|
103
|
-
}: ConnectorProps = $props();
|
|
104
|
-
|
|
105
|
-
const ctx = getChartContext();
|
|
106
|
-
const radial = $derived(radialProp ?? ctx.radial ?? false);
|
|
107
|
-
|
|
108
|
-
const sweep = $derived.by(() => {
|
|
109
|
-
if (sweepProp) return sweepProp;
|
|
110
|
-
if (type === 'd3') return 'none';
|
|
111
|
-
return 'horizontal-vertical';
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const markerStartId = $derived(markerStart || marker ? createId('marker-start', uid) : '');
|
|
115
|
-
const markerMidId = $derived(markerMid || marker ? createId('marker-mid', uid) : '');
|
|
116
|
-
const markerEndId = $derived(markerEnd || marker ? createId('marker-end', uid) : '');
|
|
117
|
-
|
|
118
|
-
const extractedTween = extractTweenConfig(motion);
|
|
119
|
-
|
|
120
|
-
const tweenOptions: ResolvedMotion | undefined = extractedTween
|
|
121
|
-
? {
|
|
122
|
-
type: extractedTween.type,
|
|
123
|
-
options: {
|
|
124
|
-
interpolate: interpolatePath,
|
|
125
|
-
...extractedTween.options,
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
: undefined;
|
|
129
|
-
|
|
130
|
-
const pathData = $derived.by(() => {
|
|
131
|
-
if (pathDataProp) return pathDataProp;
|
|
132
|
-
if (radial) {
|
|
133
|
-
return type === 'd3'
|
|
134
|
-
? getConnectorRadialD3Path({ source, target, curve })
|
|
135
|
-
: getConnectorRadialPresetPath({ source, target, type, radius });
|
|
136
|
-
}
|
|
137
|
-
if (type === 'd3') {
|
|
138
|
-
return getConnectorD3Path({
|
|
139
|
-
source,
|
|
140
|
-
target,
|
|
141
|
-
sweep,
|
|
142
|
-
curve,
|
|
143
|
-
});
|
|
144
|
-
} else {
|
|
145
|
-
return getConnectorPresetPath({ source, target, sweep, type, radius });
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const motionPath = createMotion(
|
|
150
|
-
'',
|
|
151
|
-
() => pathData,
|
|
152
|
-
tweenOptions ? tweenOptions : { type: 'none' }
|
|
153
|
-
);
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<Path
|
|
157
|
-
pathData={motionPath.current}
|
|
158
|
-
bind:pathRef
|
|
159
|
-
marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
|
|
160
|
-
marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
|
|
161
|
-
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
162
|
-
{...extractLayerProps(restProps, 'lc-connector')}
|
|
163
|
-
{...restProps}
|
|
164
|
-
/>
|
|
165
|
-
<MarkerWrapper id={markerStartId} marker={markerStart} />
|
|
166
|
-
<MarkerWrapper id={markerMidId} marker={markerMid} />
|
|
167
|
-
<MarkerWrapper id={markerEndId} marker={markerEnd} />
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export type ConnectorPropsWithoutHTML = {
|
|
2
|
-
/**
|
|
3
|
-
* The coordinates of the start point of the connector.
|
|
4
|
-
* @default { x: 0, y: 0 }
|
|
5
|
-
*/
|
|
6
|
-
source: ConnectorCoords;
|
|
7
|
-
/**
|
|
8
|
-
* The coordinates of the end point of the connector.
|
|
9
|
-
*
|
|
10
|
-
* @default { x: 100, y: 100 }
|
|
11
|
-
*/
|
|
12
|
-
target: ConnectorCoords;
|
|
13
|
-
/**
|
|
14
|
-
* The sweep direction of the connector.
|
|
15
|
-
*
|
|
16
|
-
* @default 'horizontal-vertical'
|
|
17
|
-
*/
|
|
18
|
-
sweep?: ConnectorSweep;
|
|
19
|
-
/**
|
|
20
|
-
* The type of the connector.
|
|
21
|
-
*
|
|
22
|
-
* Set to `'d3'` to use a D3 curve function via the `curve` prop.
|
|
23
|
-
*
|
|
24
|
-
* @default 'rounded'
|
|
25
|
-
*/
|
|
26
|
-
type?: ConnectorType;
|
|
27
|
-
/**
|
|
28
|
-
* The radius of the connector.
|
|
29
|
-
*
|
|
30
|
-
* Only used when type is `'beveled'` or `'rounded'`
|
|
31
|
-
*
|
|
32
|
-
* @default 20
|
|
33
|
-
*/
|
|
34
|
-
radius?: number;
|
|
35
|
-
/**
|
|
36
|
-
* The D3 curve function to use for the connector.
|
|
37
|
-
*
|
|
38
|
-
* Only used when type is `'d3'`
|
|
39
|
-
*
|
|
40
|
-
* @default `d3.curveLinear`
|
|
41
|
-
*/
|
|
42
|
-
curve?: CurveFactory;
|
|
43
|
-
/**
|
|
44
|
-
* Interpret `source`/`target` as polar coordinates (`x` = angle, `y` = radius)
|
|
45
|
-
* and render the path in radial space. Defaults to `ctx.radial` when unset.
|
|
46
|
-
*/
|
|
47
|
-
radial?: boolean;
|
|
48
|
-
} & PathPropsWithoutHTML;
|
|
49
|
-
export type ConnectorProps = ConnectorPropsWithoutHTML & Without<PathProps, ConnectorPropsWithoutHTML>;
|
|
50
|
-
import { type CurveFactory } from 'd3-shape';
|
|
51
|
-
import { type ConnectorCoords, type ConnectorSweep, type ConnectorType } from '../utils/connectorUtils.js';
|
|
52
|
-
import { type PathProps, type PathPropsWithoutHTML } from './Path.svelte';
|
|
53
|
-
import type { Without } from '../utils/types.js';
|
|
54
|
-
declare const Connector: import("svelte").Component<ConnectorProps, {}, "pathRef">;
|
|
55
|
-
type Connector = ReturnType<typeof Connector>;
|
|
56
|
-
export default Connector;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type CurveFactory } from 'd3-shape';
|
|
2
|
-
export type ConnectorCoords = {
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
};
|
|
6
|
-
export type PresetConnectorType = 'straight' | 'square' | 'beveled' | 'rounded';
|
|
7
|
-
export type ConnectorType = PresetConnectorType | 'd3';
|
|
8
|
-
export type ConnectorSweep = 'horizontal-vertical' | 'vertical-horizontal' | 'none';
|
|
9
|
-
type GetConnectorPresetPathProps = {
|
|
10
|
-
source: ConnectorCoords;
|
|
11
|
-
target: ConnectorCoords;
|
|
12
|
-
radius: number;
|
|
13
|
-
type: PresetConnectorType;
|
|
14
|
-
sweep: ConnectorSweep;
|
|
15
|
-
};
|
|
16
|
-
export declare function getConnectorPresetPath(opts: GetConnectorPresetPathProps): string;
|
|
17
|
-
type GetConnectorD3PathProps = Omit<GetConnectorPresetPathProps, 'radius' | 'type'> & {
|
|
18
|
-
curve: CurveFactory;
|
|
19
|
-
};
|
|
20
|
-
export declare function getConnectorD3Path({ source, target, sweep, curve }: GetConnectorD3PathProps): string;
|
|
21
|
-
type GetConnectorRadialPresetPathProps = {
|
|
22
|
-
source: ConnectorCoords;
|
|
23
|
-
target: ConnectorCoords;
|
|
24
|
-
type: PresetConnectorType;
|
|
25
|
-
radius: number;
|
|
26
|
-
};
|
|
27
|
-
export declare function getConnectorRadialPresetPath({ source, target, type, radius, }: GetConnectorRadialPresetPathProps): string;
|
|
28
|
-
type GetConnectorRadialD3PathProps = {
|
|
29
|
-
source: ConnectorCoords;
|
|
30
|
-
target: ConnectorCoords;
|
|
31
|
-
curve?: CurveFactory;
|
|
32
|
-
};
|
|
33
|
-
export declare function getConnectorRadialD3Path({ source, target, curve, }: GetConnectorRadialD3PathProps): string;
|
|
34
|
-
export {};
|