layerchart 2.0.0-next.54 → 2.0.0-next.56
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/bench/ComposableLineChart.svelte +1 -1
- package/dist/bench/GeoBench.svelte +1 -8
- package/dist/components/AnnotationRange.svelte +3 -1
- package/dist/components/Arc.svelte +1 -3
- package/dist/components/ArcLabel.svelte.test.js +7 -7
- package/dist/components/Axis.svelte +10 -2
- package/dist/components/Axis.svelte.d.ts +8 -2
- package/dist/components/Bar.svelte +14 -40
- package/dist/components/BoxPlot.svelte +4 -12
- package/dist/components/Cell.svelte +13 -8
- package/dist/components/Chart.svelte +69 -26
- package/dist/components/ChartChildren.svelte +22 -4
- package/dist/components/Circle.svelte +51 -9
- package/dist/components/Circle.svelte.d.ts +6 -0
- package/dist/components/CircleClipPath.svelte +13 -31
- package/dist/components/CircleClipPath.svelte.d.ts +7 -1
- package/dist/components/ClipPath.svelte +58 -21
- package/dist/components/ClipPath.svelte.d.ts +21 -12
- package/dist/components/Connector.svelte +18 -0
- package/dist/components/Connector.svelte.d.ts +5 -0
- package/dist/components/Ellipse.svelte +27 -6
- package/dist/components/GeoClipPath.svelte +14 -17
- package/dist/components/GeoClipPath.svelte.d.ts +6 -0
- package/dist/components/GeoLegend.svelte +1 -3
- package/dist/components/GeoPoint.svelte +25 -3
- package/dist/components/GeoSpline.svelte +1 -4
- package/dist/components/GeoTile.svelte +8 -4
- package/dist/components/Grid.svelte +15 -4
- package/dist/components/Grid.svelte.d.ts +14 -4
- package/dist/components/Group.svelte +11 -5
- package/dist/components/Highlight.svelte +4 -3
- package/dist/components/Image.svelte +42 -30
- package/dist/components/Labels.svelte +2 -4
- package/dist/components/Line.svelte +31 -3
- package/dist/components/Line.svelte.d.ts +7 -0
- package/dist/components/LinearGradient.svelte +8 -4
- package/dist/components/Link.svelte +8 -0
- package/dist/components/Marker.svelte +9 -1
- package/dist/components/Path.svelte +43 -23
- package/dist/components/Pattern.svelte +101 -5
- package/dist/components/Pattern.svelte.d.ts +3 -1
- package/dist/components/Pie.svelte +2 -6
- package/dist/components/RadialGradient.svelte +8 -4
- package/dist/components/Rect.svelte +117 -9
- package/dist/components/Rect.svelte.d.ts +13 -1
- package/dist/components/RectClipPath.svelte +11 -15
- package/dist/components/RectClipPath.svelte.d.ts +6 -0
- package/dist/components/Spline.svelte +22 -4
- package/dist/components/Text.svelte +16 -5
- package/dist/components/Trail.svelte +19 -7
- package/dist/components/Tree.svelte +7 -3
- package/dist/components/Vector.svelte +37 -14
- package/dist/components/Violin.svelte +1 -2
- package/dist/components/charts/ArcChart.svelte +8 -5
- package/dist/components/charts/AreaChart.svelte +6 -1
- package/dist/components/charts/BarChart.svelte +3 -1
- package/dist/components/charts/LineChart.svelte +6 -1
- package/dist/components/charts/PieChart.svelte +10 -3
- package/dist/components/tooltip/Tooltip.svelte +2 -8
- package/dist/contexts/chart.d.ts +1 -1
- package/dist/contexts/chart.js +3 -1
- package/dist/server/TestBarChart.svelte +28 -28
- package/dist/server/TestLineChart.svelte +28 -28
- package/dist/server/index.js +1 -1
- package/dist/states/brush.svelte.js +16 -13
- package/dist/states/chart.svelte.test.js +24 -19
- package/dist/states/geo.svelte.js +1 -4
- package/dist/states/series.svelte.js +1 -1
- package/dist/utils/__screenshots__/canvas.svelte.test.ts/renderPathData-composes-element-opacity-with-inherited-globalAlpha--Group-opacity--1.png +0 -0
- package/dist/utils/__screenshots__/canvas.svelte.test.ts/renderPathData-composes-element-opacity-with-inherited-globalAlpha--Group-opacity--2.png +0 -0
- package/dist/utils/canvas.d.ts +2 -0
- package/dist/utils/canvas.js +20 -11
- package/dist/utils/canvas.svelte.test.js +55 -0
- package/dist/utils/connectorUtils.d.ts +13 -0
- package/dist/utils/connectorUtils.js +120 -1
- package/dist/utils/path.d.ts +19 -0
- package/dist/utils/path.js +72 -0
- package/dist/utils/rect.svelte.d.ts +18 -0
- package/dist/utils/rect.svelte.js +33 -0
- package/dist/utils/trail.js +3 -4
- package/package.json +1 -1
|
@@ -63,11 +63,25 @@
|
|
|
63
63
|
|
|
64
64
|
{#if layerCtx === 'svg'}
|
|
65
65
|
{#if children}
|
|
66
|
-
<Group
|
|
66
|
+
<Group
|
|
67
|
+
{x}
|
|
68
|
+
{y}
|
|
69
|
+
opacity={opacity as number}
|
|
70
|
+
class={className as string}
|
|
71
|
+
{...extractLayerProps(restProps, 'lc-geo-point-group')}
|
|
72
|
+
>
|
|
67
73
|
{@render children({ x, y })}
|
|
68
74
|
</Group>
|
|
69
75
|
{:else}
|
|
70
|
-
<Circle
|
|
76
|
+
<Circle
|
|
77
|
+
cx={x}
|
|
78
|
+
cy={y}
|
|
79
|
+
{opacity}
|
|
80
|
+
{fillOpacity}
|
|
81
|
+
{strokeWidth}
|
|
82
|
+
class={className}
|
|
83
|
+
{...extractLayerProps(restProps, 'lc-geo-point')}
|
|
84
|
+
/>
|
|
71
85
|
{/if}
|
|
72
86
|
{/if}
|
|
73
87
|
|
|
@@ -78,6 +92,14 @@
|
|
|
78
92
|
{@render children({ x, y })}
|
|
79
93
|
<!-- </Group> -->
|
|
80
94
|
{:else}
|
|
81
|
-
<Circle
|
|
95
|
+
<Circle
|
|
96
|
+
cx={x}
|
|
97
|
+
cy={y}
|
|
98
|
+
{opacity}
|
|
99
|
+
{fillOpacity}
|
|
100
|
+
{strokeWidth}
|
|
101
|
+
class={className}
|
|
102
|
+
{...extractLayerProps(restProps, 'lc-geo-point')}
|
|
103
|
+
/>
|
|
82
104
|
{/if}
|
|
83
105
|
{/if}
|
|
@@ -91,10 +91,14 @@
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (layerCtx === 'canvas') {
|
|
94
|
-
ctx.registerComponent({
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
ctx.registerComponent({
|
|
95
|
+
name: 'GeoTile',
|
|
96
|
+
kind: 'mark',
|
|
97
|
+
canvasRender: {
|
|
98
|
+
render,
|
|
99
|
+
deps: () => [tiles],
|
|
100
|
+
},
|
|
101
|
+
});
|
|
98
102
|
}
|
|
99
103
|
</script>
|
|
100
104
|
|
|
@@ -3,20 +3,31 @@
|
|
|
3
3
|
import { extractTweenConfig, type MotionProp } from '../utils/motion.svelte.js';
|
|
4
4
|
import type { SVGAttributes } from 'svelte/elements';
|
|
5
5
|
|
|
6
|
+
/** Props forwarded onto the underlying grid line (`<Line>`, `<Circle>`, or `<Spline>`). */
|
|
7
|
+
type GridLineProps = Pick<SVGAttributes<SVGElement>, 'class' | 'style'> & {
|
|
8
|
+
stroke?: string;
|
|
9
|
+
strokeWidth?: number;
|
|
10
|
+
opacity?: number;
|
|
11
|
+
/** Dashed-line pattern. See `Line.dashArray`. */
|
|
12
|
+
dashArray?: number | number[] | string;
|
|
13
|
+
};
|
|
14
|
+
|
|
6
15
|
export type GridPropsWithoutHTML<In extends Transition = Transition> = {
|
|
7
16
|
/**
|
|
8
|
-
* Draw a x-axis lines
|
|
17
|
+
* Draw a x-axis lines. Pass props (class, style, stroke, strokeWidth,
|
|
18
|
+
* opacity, dashArray) to forward onto the underlying line.
|
|
9
19
|
*
|
|
10
20
|
* @default false
|
|
11
21
|
*/
|
|
12
|
-
x?: boolean |
|
|
22
|
+
x?: boolean | GridLineProps;
|
|
13
23
|
|
|
14
24
|
/**
|
|
15
|
-
* Draw a y-axis lines
|
|
25
|
+
* Draw a y-axis lines. Pass props (class, style, stroke, strokeWidth,
|
|
26
|
+
* opacity, dashArray) to forward onto the underlying line.
|
|
16
27
|
*
|
|
17
28
|
* @default false
|
|
18
29
|
*/
|
|
19
|
-
y?: boolean |
|
|
30
|
+
y?: boolean | GridLineProps;
|
|
20
31
|
|
|
21
32
|
/**
|
|
22
33
|
* Control the number of x-axis ticks
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import type { Transition, TransitionParams, Without } from '../utils/types.js';
|
|
2
2
|
import { type MotionProp } from '../utils/motion.svelte.js';
|
|
3
3
|
import type { SVGAttributes } from 'svelte/elements';
|
|
4
|
+
/** Props forwarded onto the underlying grid line (`<Line>`, `<Circle>`, or `<Spline>`). */
|
|
5
|
+
type GridLineProps = Pick<SVGAttributes<SVGElement>, 'class' | 'style'> & {
|
|
6
|
+
stroke?: string;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
opacity?: number;
|
|
9
|
+
/** Dashed-line pattern. See `Line.dashArray`. */
|
|
10
|
+
dashArray?: number | number[] | string;
|
|
11
|
+
};
|
|
4
12
|
export type GridPropsWithoutHTML<In extends Transition = Transition> = {
|
|
5
13
|
/**
|
|
6
|
-
* Draw a x-axis lines
|
|
14
|
+
* Draw a x-axis lines. Pass props (class, style, stroke, strokeWidth,
|
|
15
|
+
* opacity, dashArray) to forward onto the underlying line.
|
|
7
16
|
*
|
|
8
17
|
* @default false
|
|
9
18
|
*/
|
|
10
|
-
x?: boolean |
|
|
19
|
+
x?: boolean | GridLineProps;
|
|
11
20
|
/**
|
|
12
|
-
* Draw a y-axis lines
|
|
21
|
+
* Draw a y-axis lines. Pass props (class, style, stroke, strokeWidth,
|
|
22
|
+
* opacity, dashArray) to forward onto the underlying line.
|
|
13
23
|
*
|
|
14
24
|
* @default false
|
|
15
25
|
*/
|
|
16
|
-
y?: boolean |
|
|
26
|
+
y?: boolean | GridLineProps;
|
|
17
27
|
/**
|
|
18
28
|
* Control the number of x-axis ticks
|
|
19
29
|
*/
|
|
@@ -137,9 +137,7 @@
|
|
|
137
137
|
const dataMode = $derived(hasAnyDataProp(x, y));
|
|
138
138
|
|
|
139
139
|
// Data to iterate over in data mode
|
|
140
|
-
const resolvedData: any[] = $derived(
|
|
141
|
-
dataMode ? (dataProp ?? chartDataArray(chartCtx.data)) : []
|
|
142
|
-
);
|
|
140
|
+
const resolvedData: any[] = $derived(dataMode ? (dataProp ?? chartDataArray(chartCtx.data)) : []);
|
|
143
141
|
|
|
144
142
|
// Resolve a single data item to pixel coordinates
|
|
145
143
|
function resolveGroup(d: any) {
|
|
@@ -198,10 +196,18 @@
|
|
|
198
196
|
const initialY = initialYProp ?? (typeof y === 'number' ? y : undefined);
|
|
199
197
|
|
|
200
198
|
const trueX = $derived(
|
|
201
|
-
typeof x === 'number'
|
|
199
|
+
typeof x === 'number'
|
|
200
|
+
? x
|
|
201
|
+
: x == null && (center === 'x' || center === true)
|
|
202
|
+
? chartCtx.width / 2
|
|
203
|
+
: 0
|
|
202
204
|
);
|
|
203
205
|
const trueY = $derived(
|
|
204
|
-
typeof y === 'number'
|
|
206
|
+
typeof y === 'number'
|
|
207
|
+
? y
|
|
208
|
+
: y == null && (center === 'y' || center === true)
|
|
209
|
+
? chartCtx.height / 2
|
|
210
|
+
: 0
|
|
205
211
|
);
|
|
206
212
|
const motionX = createMotion(initialX, () => trueX, motion);
|
|
207
213
|
const motionY = createMotion(initialY, () => trueY, motion);
|
|
@@ -389,9 +389,9 @@
|
|
|
389
389
|
: null;
|
|
390
390
|
// For diverging stacks, use the outer edge (y0 for below-baseline, y1 for above)
|
|
391
391
|
const stackedY1 = stackValue
|
|
392
|
-
?
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
? ctx.series.stackLayout === 'stackDiverging' && stackValue[1] <= 0
|
|
393
|
+
? stackValue[0]
|
|
394
|
+
: stackValue[1]
|
|
395
395
|
: 0;
|
|
396
396
|
|
|
397
397
|
if (ctx.valueAxis === 'x') {
|
|
@@ -681,6 +681,7 @@
|
|
|
681
681
|
y1={line.y1}
|
|
682
682
|
x2={line.x2}
|
|
683
683
|
y2={line.y2}
|
|
684
|
+
dashArray={[2, 2]}
|
|
684
685
|
{opacity}
|
|
685
686
|
{...extractLayerProps(linesProp, 'lc-highlight-line')}
|
|
686
687
|
/>
|
|
@@ -195,16 +195,16 @@
|
|
|
195
195
|
const geo = getGeoContext();
|
|
196
196
|
|
|
197
197
|
// Data to iterate over in data mode
|
|
198
|
-
const resolvedData: any[] = $derived(
|
|
199
|
-
dataMode ? (dataProp ?? chartDataArray(chartCtx.data)) : []
|
|
200
|
-
);
|
|
198
|
+
const resolvedData: any[] = $derived(dataMode ? (dataProp ?? chartDataArray(chartCtx.data)) : []);
|
|
201
199
|
|
|
202
200
|
// Resolve a single data item to pixel coordinates and dimensions
|
|
203
201
|
function resolveImage(d: any) {
|
|
204
202
|
const resolvedR = r !== undefined ? resolveDataProp(r, d, null, 0) : undefined;
|
|
205
203
|
const defaultSize = resolvedR !== undefined ? resolvedR * 2 : 16;
|
|
206
|
-
const resolvedWidth =
|
|
207
|
-
|
|
204
|
+
const resolvedWidth =
|
|
205
|
+
width !== undefined ? resolveDataProp(width, d, null, defaultSize) : defaultSize;
|
|
206
|
+
const resolvedHeight =
|
|
207
|
+
height !== undefined ? resolveDataProp(height, d, null, defaultSize) : defaultSize;
|
|
208
208
|
|
|
209
209
|
let resolvedX: number, resolvedY: number;
|
|
210
210
|
if (geo.projection) {
|
|
@@ -247,7 +247,14 @@
|
|
|
247
247
|
const key = keyFn(d, i);
|
|
248
248
|
activeKeys.add(key);
|
|
249
249
|
const resolved = resolveImage(d);
|
|
250
|
-
untrack(() =>
|
|
250
|
+
untrack(() =>
|
|
251
|
+
dataMotionMap.update(key, {
|
|
252
|
+
x: resolved.x,
|
|
253
|
+
y: resolved.y,
|
|
254
|
+
width: resolved.width,
|
|
255
|
+
height: resolved.height,
|
|
256
|
+
})
|
|
257
|
+
);
|
|
251
258
|
}
|
|
252
259
|
untrack(() => dataMotionMap.cleanup(activeKeys));
|
|
253
260
|
});
|
|
@@ -416,29 +423,32 @@
|
|
|
416
423
|
y: typeof y === 'string' ? y : undefined,
|
|
417
424
|
};
|
|
418
425
|
},
|
|
419
|
-
canvasRender:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
426
|
+
canvasRender:
|
|
427
|
+
layerCtx === 'canvas'
|
|
428
|
+
? {
|
|
429
|
+
render: canvasRender,
|
|
430
|
+
events: {
|
|
431
|
+
click: restProps.onclick,
|
|
432
|
+
pointerdown: restProps.onpointerdown,
|
|
433
|
+
pointerenter: restProps.onpointerenter,
|
|
434
|
+
pointermove: restProps.onpointermove,
|
|
435
|
+
pointerleave: restProps.onpointerleave,
|
|
436
|
+
},
|
|
437
|
+
deps: () => [
|
|
438
|
+
dataMode,
|
|
439
|
+
dataMode ? resolvedItems : null,
|
|
440
|
+
motionX.current,
|
|
441
|
+
motionY.current,
|
|
442
|
+
motionWidth.current,
|
|
443
|
+
motionHeight.current,
|
|
444
|
+
href,
|
|
445
|
+
opacity,
|
|
446
|
+
className,
|
|
447
|
+
restProps.style,
|
|
448
|
+
loadedImageCount,
|
|
449
|
+
],
|
|
450
|
+
}
|
|
451
|
+
: undefined,
|
|
442
452
|
});
|
|
443
453
|
</script>
|
|
444
454
|
|
|
@@ -487,7 +497,9 @@
|
|
|
487
497
|
width={motionWidth.current}
|
|
488
498
|
height={motionHeight.current}
|
|
489
499
|
clip-path={pixelR !== undefined ? `url(#${clipId})` : undefined}
|
|
490
|
-
transform={pixelRotate
|
|
500
|
+
transform={pixelRotate
|
|
501
|
+
? `rotate(${pixelRotate}, ${motionX.current}, ${motionY.current})`
|
|
502
|
+
: undefined}
|
|
491
503
|
{preserveAspectRatio}
|
|
492
504
|
crossorigin={crossOrigin}
|
|
493
505
|
image-rendering={imageRendering}
|
|
@@ -173,8 +173,7 @@
|
|
|
173
173
|
fill: fillValue,
|
|
174
174
|
x: point.x + (placement === 'outside' ? -offset : offset),
|
|
175
175
|
y: point.y,
|
|
176
|
-
textAnchor:
|
|
177
|
-
placement === 'middle' ? 'middle' : placement === 'outside' ? 'end' : 'start',
|
|
176
|
+
textAnchor: placement === 'middle' ? 'middle' : placement === 'outside' ? 'end' : 'start',
|
|
178
177
|
verticalAnchor: 'middle',
|
|
179
178
|
capHeight: '.6rem',
|
|
180
179
|
};
|
|
@@ -185,8 +184,7 @@
|
|
|
185
184
|
fill: fillValue,
|
|
186
185
|
x: point.x + (placement === 'outside' ? offset : -offset),
|
|
187
186
|
y: point.y,
|
|
188
|
-
textAnchor:
|
|
189
|
-
placement === 'middle' ? 'middle' : placement === 'outside' ? 'start' : 'end',
|
|
187
|
+
textAnchor: placement === 'middle' ? 'middle' : placement === 'outside' ? 'start' : 'end',
|
|
190
188
|
verticalAnchor: 'middle',
|
|
191
189
|
capHeight: '.6rem',
|
|
192
190
|
};
|
|
@@ -111,6 +111,14 @@
|
|
|
111
111
|
|
|
112
112
|
/** Motion configuration (pixel mode only). */
|
|
113
113
|
motion?: MotionProp;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Dashed-line pattern. Accepts a number (single dash length), a
|
|
117
|
+
* `[dash, gap, ...]` array, or a string (same syntax as SVG
|
|
118
|
+
* `stroke-dasharray`). Works across `<Svg>`, `<Canvas>`, and `<Html>`
|
|
119
|
+
* layers — HTML approximates the pattern via `repeating-linear-gradient`.
|
|
120
|
+
*/
|
|
121
|
+
dashArray?: number | number[] | string;
|
|
114
122
|
} & DataDrivenStyleProps;
|
|
115
123
|
|
|
116
124
|
export type LineProps = LinePropsWithoutHTML &
|
|
@@ -137,6 +145,7 @@
|
|
|
137
145
|
|
|
138
146
|
import { createKey } from '../utils/key.svelte.js';
|
|
139
147
|
import { createId } from '../utils/createId.js';
|
|
148
|
+
import { parseDashArray, dashArrayToGradient } from '../utils/path.js';
|
|
140
149
|
|
|
141
150
|
const uid = $props.id();
|
|
142
151
|
|
|
@@ -162,9 +171,13 @@
|
|
|
162
171
|
markerMid,
|
|
163
172
|
motion,
|
|
164
173
|
fillOpacity,
|
|
174
|
+
dashArray,
|
|
165
175
|
...restProps
|
|
166
176
|
}: LineProps = $props();
|
|
167
177
|
|
|
178
|
+
const dashArrayResolved = $derived(parseDashArray(dashArray));
|
|
179
|
+
const dashArrayAttr = $derived(dashArrayResolved ? dashArrayResolved.join(' ') : undefined);
|
|
180
|
+
|
|
168
181
|
// Data mode detection
|
|
169
182
|
const dataMode = $derived(hasAnyDataProp(x1, y1, x2, y2));
|
|
170
183
|
|
|
@@ -285,7 +298,13 @@
|
|
|
285
298
|
'lc-line',
|
|
286
299
|
itemClass ?? (typeof className === 'string' ? className : undefined)
|
|
287
300
|
),
|
|
288
|
-
style:
|
|
301
|
+
style:
|
|
302
|
+
[
|
|
303
|
+
restProps.style as string | undefined,
|
|
304
|
+
dashArrayAttr ? `stroke-dasharray: ${dashArrayAttr}` : undefined,
|
|
305
|
+
]
|
|
306
|
+
.filter(Boolean)
|
|
307
|
+
.join('; ') || undefined,
|
|
289
308
|
};
|
|
290
309
|
}
|
|
291
310
|
|
|
@@ -358,6 +377,7 @@
|
|
|
358
377
|
opacity,
|
|
359
378
|
className,
|
|
360
379
|
restProps.style,
|
|
380
|
+
dashArrayAttr,
|
|
361
381
|
],
|
|
362
382
|
}
|
|
363
383
|
: undefined,
|
|
@@ -390,6 +410,7 @@
|
|
|
390
410
|
marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
|
|
391
411
|
marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
|
|
392
412
|
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
413
|
+
stroke-dasharray={dashArrayAttr}
|
|
393
414
|
class={cls('lc-line', resolvedClass)}
|
|
394
415
|
{...restProps}
|
|
395
416
|
/>
|
|
@@ -408,6 +429,7 @@
|
|
|
408
429
|
marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
|
|
409
430
|
marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
|
|
410
431
|
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
432
|
+
stroke-dasharray={dashArrayAttr}
|
|
411
433
|
class={cls('lc-line', staticClassName)}
|
|
412
434
|
{...restProps}
|
|
413
435
|
/>
|
|
@@ -435,7 +457,10 @@
|
|
|
435
457
|
style:transform="translateY(-50%) rotate({angle}deg)"
|
|
436
458
|
style:transform-origin="0 50%"
|
|
437
459
|
style:opacity={resolvedOpacity}
|
|
438
|
-
style:background
|
|
460
|
+
style:background={dashArrayResolved
|
|
461
|
+
? dashArrayToGradient(dashArrayResolved, resolvedStroke ?? 'var(--stroke-color)')
|
|
462
|
+
: undefined}
|
|
463
|
+
style:background-color={dashArrayResolved ? undefined : resolvedStroke}
|
|
439
464
|
class={cls('lc-line', resolvedClass)}
|
|
440
465
|
style={restProps.style}
|
|
441
466
|
></div>
|
|
@@ -455,7 +480,10 @@
|
|
|
455
480
|
style:transform="translateY(-50%) rotate({angle}deg)"
|
|
456
481
|
style:transform-origin="0 50%"
|
|
457
482
|
style:opacity={staticOpacity}
|
|
458
|
-
style:background
|
|
483
|
+
style:background={dashArrayResolved
|
|
484
|
+
? dashArrayToGradient(dashArrayResolved, staticStroke ?? 'var(--stroke-color)')
|
|
485
|
+
: undefined}
|
|
486
|
+
style:background-color={dashArrayResolved ? undefined : staticStroke}
|
|
459
487
|
class={cls('lc-line', staticClassName)}
|
|
460
488
|
style={restProps.style}
|
|
461
489
|
></div>
|
|
@@ -93,6 +93,13 @@ export type LinePropsWithoutHTML = {
|
|
|
93
93
|
markerEnd?: MarkerOptions;
|
|
94
94
|
/** Motion configuration (pixel mode only). */
|
|
95
95
|
motion?: MotionProp;
|
|
96
|
+
/**
|
|
97
|
+
* Dashed-line pattern. Accepts a number (single dash length), a
|
|
98
|
+
* `[dash, gap, ...]` array, or a string (same syntax as SVG
|
|
99
|
+
* `stroke-dasharray`). Works across `<Svg>`, `<Canvas>`, and `<Html>`
|
|
100
|
+
* layers — HTML approximates the pattern via `repeating-linear-gradient`.
|
|
101
|
+
*/
|
|
102
|
+
dashArray?: number | number[] | string;
|
|
96
103
|
} & DataDrivenStyleProps;
|
|
97
104
|
export type LineProps = LinePropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, LinePropsWithoutHTML>;
|
|
98
105
|
declare const Line: import("svelte").Component<LineProps, {}, "">;
|
|
@@ -174,10 +174,14 @@
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
if (layerCtx === 'canvas') {
|
|
177
|
-
ctx.registerComponent({
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
ctx.registerComponent({
|
|
178
|
+
name: 'Gradient',
|
|
179
|
+
kind: 'group',
|
|
180
|
+
canvasRender: {
|
|
181
|
+
render,
|
|
182
|
+
deps: () => [x1, y1, x2, y2, stops, className],
|
|
183
|
+
},
|
|
184
|
+
});
|
|
181
185
|
}
|
|
182
186
|
</script>
|
|
183
187
|
|
|
@@ -82,6 +82,9 @@ TODO:
|
|
|
82
82
|
*/
|
|
83
83
|
import Connector, { type ConnectorProps } from './Connector.svelte';
|
|
84
84
|
import { extractLayerProps } from '../utils/attributes.js';
|
|
85
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
86
|
+
|
|
87
|
+
const ctx = getChartContext();
|
|
85
88
|
|
|
86
89
|
let {
|
|
87
90
|
data,
|
|
@@ -95,6 +98,7 @@ TODO:
|
|
|
95
98
|
explicitCoords,
|
|
96
99
|
type = 'd3',
|
|
97
100
|
sweep = 'none',
|
|
101
|
+
radius = 20,
|
|
98
102
|
...restProps
|
|
99
103
|
}: LinkProps = $props();
|
|
100
104
|
|
|
@@ -125,12 +129,14 @@ TODO:
|
|
|
125
129
|
const xAccessor = $derived.by(() => {
|
|
126
130
|
if (xProp) return xProp;
|
|
127
131
|
if (sankey) return (d: any) => (d.isSource ? d.node.x1 : d.node.x0);
|
|
132
|
+
if (ctx.radial) return (d: any) => d.x;
|
|
128
133
|
return (d: any) => (orientation === 'horizontal' ? d.y : d.x);
|
|
129
134
|
});
|
|
130
135
|
|
|
131
136
|
const yAccessor = $derived.by(() => {
|
|
132
137
|
if (yProp) return yProp;
|
|
133
138
|
if (sankey) return (d: any) => d.y;
|
|
139
|
+
if (ctx.radial) return (d: any) => d.y;
|
|
134
140
|
return (d: any) => (orientation === 'horizontal' ? d.x : d.y);
|
|
135
141
|
});
|
|
136
142
|
|
|
@@ -173,5 +179,7 @@ TODO:
|
|
|
173
179
|
{type}
|
|
174
180
|
{curve}
|
|
175
181
|
{sweep}
|
|
182
|
+
{radius}
|
|
183
|
+
radial={ctx.radial}
|
|
176
184
|
{...extractLayerProps(restProps, 'lc-link')}
|
|
177
185
|
/>
|
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Pass `children` to render a custom element/component inside the marker instead.
|
|
10
10
|
*/
|
|
11
|
-
type?:
|
|
11
|
+
type?:
|
|
12
|
+
| 'arrow'
|
|
13
|
+
| 'triangle'
|
|
14
|
+
| 'line'
|
|
15
|
+
| 'circle'
|
|
16
|
+
| 'circle-stroke'
|
|
17
|
+
| 'dot'
|
|
18
|
+
| 'square'
|
|
19
|
+
| 'square-stroke';
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
22
|
* Unique identifier for the marker
|
|
@@ -197,30 +197,50 @@
|
|
|
197
197
|
const strokeKey = layerCtx === 'canvas' ? createKey(() => stroke) : undefined;
|
|
198
198
|
|
|
199
199
|
if (layerCtx === 'canvas') {
|
|
200
|
-
ctx.registerComponent({
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
200
|
+
ctx.registerComponent({
|
|
201
|
+
name: 'Path',
|
|
202
|
+
kind: 'mark',
|
|
203
|
+
canvasRender: {
|
|
204
|
+
render,
|
|
205
|
+
events: {
|
|
206
|
+
get click() {
|
|
207
|
+
return onclick;
|
|
208
|
+
},
|
|
209
|
+
get pointerenter() {
|
|
210
|
+
return onpointerenter;
|
|
211
|
+
},
|
|
212
|
+
get pointermove() {
|
|
213
|
+
return onpointermove;
|
|
214
|
+
},
|
|
215
|
+
get pointerleave() {
|
|
216
|
+
return onpointerleave;
|
|
217
|
+
},
|
|
218
|
+
get pointerdown() {
|
|
219
|
+
return onpointerdown;
|
|
220
|
+
},
|
|
221
|
+
get pointerover() {
|
|
222
|
+
return onpointerover;
|
|
223
|
+
},
|
|
224
|
+
get pointerout() {
|
|
225
|
+
return onpointerout;
|
|
226
|
+
},
|
|
227
|
+
get touchmove() {
|
|
228
|
+
return ontouchmove;
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
deps: () => [
|
|
232
|
+
fillKey!.current,
|
|
233
|
+
fillOpacity,
|
|
234
|
+
strokeKey!.current,
|
|
235
|
+
strokeOpacity,
|
|
236
|
+
strokeWidth,
|
|
237
|
+
opacity,
|
|
238
|
+
className,
|
|
239
|
+
tweenedState.current,
|
|
240
|
+
restProps.style,
|
|
241
|
+
],
|
|
211
242
|
},
|
|
212
|
-
|
|
213
|
-
fillKey!.current,
|
|
214
|
-
fillOpacity,
|
|
215
|
-
strokeKey!.current,
|
|
216
|
-
strokeOpacity,
|
|
217
|
-
strokeWidth,
|
|
218
|
-
opacity,
|
|
219
|
-
className,
|
|
220
|
-
tweenedState.current,
|
|
221
|
-
restProps.style,
|
|
222
|
-
],
|
|
223
|
-
} });
|
|
243
|
+
});
|
|
224
244
|
}
|
|
225
245
|
|
|
226
246
|
let startPoint = $state<DOMPoint | undefined>();
|