layerchart 0.54.0 → 0.54.1
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/Arc.svelte +170 -144
- package/dist/components/Area.svelte +96 -67
- package/dist/components/Area.svelte.d.ts +1 -0
- package/dist/components/Axis.svelte +205 -155
- package/dist/components/Bar.svelte +72 -45
- package/dist/components/Bars.svelte +45 -34
- package/dist/components/Blur.svelte +5 -3
- package/dist/components/Bounds.svelte +37 -21
- package/dist/components/Brush.svelte +181 -110
- package/dist/components/Calendar.svelte +51 -38
- package/dist/components/Chart.svelte +295 -74
- package/dist/components/Chart.svelte.d.ts +17 -17
- package/dist/components/ChartClipPath.svelte +8 -5
- package/dist/components/ChartContext.svelte +243 -93
- package/dist/components/ChartContext.svelte.d.ts +15 -23
- package/dist/components/Circle.svelte +25 -16
- package/dist/components/CircleClipPath.svelte +16 -10
- package/dist/components/ClipPath.svelte +11 -7
- package/dist/components/ColorRamp.svelte +12 -10
- package/dist/components/ForceSimulation.svelte +185 -116
- package/dist/components/Frame.svelte +10 -6
- package/dist/components/GeoCircle.svelte +15 -9
- package/dist/components/GeoContext.svelte +109 -62
- package/dist/components/GeoEdgeFade.svelte +20 -14
- package/dist/components/GeoPath.svelte +107 -69
- package/dist/components/GeoPoint.svelte +32 -18
- package/dist/components/GeoSpline.svelte +30 -22
- package/dist/components/GeoTile.svelte +40 -30
- package/dist/components/GeoVisible.svelte +10 -7
- package/dist/components/Graticule.svelte +14 -8
- package/dist/components/Grid.svelte +75 -48
- package/dist/components/Group.svelte +43 -31
- package/dist/components/Highlight.svelte +284 -243
- package/dist/components/HitCanvas.svelte +75 -42
- package/dist/components/Hull.svelte +40 -20
- package/dist/components/Labels.svelte +81 -70
- package/dist/components/Legend.svelte +105 -74
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/Line.svelte +29 -19
- package/dist/components/LinearGradient.svelte +21 -15
- package/dist/components/Link.svelte +44 -22
- package/dist/components/MonthPath.svelte +23 -16
- package/dist/components/MotionPath.svelte +34 -25
- package/dist/components/Pack.svelte +21 -14
- package/dist/components/Partition.svelte +35 -20
- package/dist/components/Pattern.svelte +8 -6
- package/dist/components/Pie.svelte +76 -57
- package/dist/components/Point.svelte +11 -7
- package/dist/components/Points.svelte +178 -143
- package/dist/components/RadialGradient.svelte +25 -18
- package/dist/components/Rect.svelte +33 -19
- package/dist/components/RectClipPath.svelte +16 -11
- package/dist/components/Rule.svelte +50 -42
- package/dist/components/Sankey.svelte +55 -30
- package/dist/components/Spline.svelte +118 -96
- package/dist/components/Text.svelte +137 -104
- package/dist/components/Threshold.svelte +18 -7
- package/dist/components/TileImage.svelte +56 -50
- package/dist/components/TransformContext.svelte +235 -135
- package/dist/components/TransformControls.svelte +57 -29
- package/dist/components/TransformControls.svelte.d.ts +1 -1
- package/dist/components/Tree.svelte +33 -23
- package/dist/components/Treemap.svelte +69 -41
- package/dist/components/Voronoi.svelte +55 -28
- package/dist/components/charts/AreaChart.svelte +128 -77
- package/dist/components/charts/AreaChart.svelte.d.ts +1 -1
- package/dist/components/charts/BarChart.svelte +169 -104
- package/dist/components/charts/BarChart.svelte.d.ts +1 -1
- package/dist/components/charts/LineChart.svelte +87 -43
- package/dist/components/charts/LineChart.svelte.d.ts +1 -1
- package/dist/components/charts/PieChart.svelte +102 -52
- package/dist/components/charts/PieChart.svelte.d.ts +1 -1
- package/dist/components/charts/ScatterChart.svelte +73 -38
- package/dist/components/charts/ScatterChart.svelte.d.ts +1 -1
- package/dist/components/layout/Canvas.svelte +63 -43
- package/dist/components/layout/Html.svelte +28 -18
- package/dist/components/layout/Svg.svelte +47 -32
- package/dist/components/tooltip/Tooltip.svelte +137 -91
- package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContext.svelte +315 -249
- package/dist/components/tooltip/TooltipHeader.svelte +9 -3
- package/dist/components/tooltip/TooltipItem.svelte +17 -9
- package/dist/components/tooltip/TooltipList.svelte +2 -1
- package/dist/components/tooltip/TooltipSeparator.svelte +3 -2
- package/dist/docs/Blockquote.svelte +4 -3
- package/dist/docs/Code.svelte +15 -8
- package/dist/docs/CurveMenuField.svelte +17 -12
- package/dist/docs/GeoDebug.svelte +13 -9
- package/dist/docs/Header1.svelte +2 -1
- package/dist/docs/Json.svelte +6 -4
- package/dist/docs/Layout.svelte +6 -6
- package/dist/docs/PathDataMenuField.svelte +52 -44
- package/dist/docs/Preview.svelte +39 -33
- package/dist/docs/TilesetField.svelte +80 -62
- package/dist/docs/TransformDebug.svelte +8 -5
- package/dist/docs/ViewSourceButton.svelte +13 -9
- package/dist/stores/motionStore.d.ts +1 -1
- package/dist/utils/scales.d.ts +3 -3
- package/package.json +29 -30
|
@@ -1,171 +1,206 @@
|
|
|
1
|
-
<script context="module">
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
export type Point = { x: number; y: number; r: number; xValue: any; yValue: any; data: any };
|
|
2
3
|
</script>
|
|
3
4
|
|
|
4
|
-
<script>
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { getContext, type ComponentProps } from 'svelte';
|
|
7
|
+
import type { Readable } from 'svelte/store';
|
|
8
|
+
import { extent } from 'd3-array';
|
|
9
|
+
import { pointRadial } from 'd3-shape';
|
|
10
|
+
import { notNull } from '@layerstack/utils/typeGuards';
|
|
11
|
+
|
|
12
|
+
import { chartContext } from './ChartContext.svelte';
|
|
13
|
+
import Circle from './Circle.svelte';
|
|
14
|
+
import Link from './Link.svelte';
|
|
15
|
+
import { isScaleBand, type AnyScale } from '../utils/scales.js';
|
|
16
|
+
|
|
17
|
+
const context = chartContext() as any;
|
|
18
|
+
const {
|
|
19
|
+
data: contextData,
|
|
20
|
+
x,
|
|
21
|
+
xScale,
|
|
22
|
+
xGet,
|
|
23
|
+
y,
|
|
24
|
+
yScale,
|
|
25
|
+
yGet,
|
|
26
|
+
cGet,
|
|
27
|
+
rGet,
|
|
28
|
+
padding,
|
|
29
|
+
containerWidth,
|
|
30
|
+
containerHeight,
|
|
31
|
+
config,
|
|
32
|
+
radial,
|
|
33
|
+
} = context;
|
|
34
|
+
|
|
35
|
+
type Offset = number | ((value: number, context: any) => number) | undefined;
|
|
36
|
+
|
|
37
|
+
/** Override data instead of using context */
|
|
38
|
+
export let data: any = undefined;
|
|
39
|
+
|
|
40
|
+
export let r = 5;
|
|
41
|
+
export let offsetX: Offset = undefined;
|
|
42
|
+
export let offsetY: Offset = undefined;
|
|
43
|
+
|
|
44
|
+
/** Enable showing links between related points (array x/y accessors) */
|
|
45
|
+
export let links: boolean | Partial<ComponentProps<Link>> = false;
|
|
46
|
+
|
|
47
|
+
export let fill: string | undefined = undefined;
|
|
48
|
+
export let stroke: string | undefined = undefined;
|
|
49
|
+
export let strokeWidth: number | string | undefined = undefined;
|
|
50
|
+
|
|
51
|
+
/** Render to canvas */
|
|
52
|
+
export let render: ((ctx: CanvasRenderingContext2D, points: Point[]) => any) | undefined =
|
|
53
|
+
undefined;
|
|
54
|
+
|
|
55
|
+
let className: string | undefined = undefined;
|
|
56
|
+
export { className as class };
|
|
57
|
+
|
|
58
|
+
const canvas = getContext<{ ctx: Readable<CanvasRenderingContext2D> }>('canvas');
|
|
59
|
+
const DEFAULT_FILL = 'rgb(0, 0, 0)';
|
|
60
|
+
|
|
61
|
+
function getOffset(value: any, offset: Offset, scale: AnyScale) {
|
|
31
62
|
if (typeof offset === 'function') {
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
else
|
|
38
|
-
|
|
63
|
+
return offset(value, context);
|
|
64
|
+
} else if (offset != null) {
|
|
65
|
+
return offset;
|
|
66
|
+
} else if (isScaleBand(scale) && !$radial) {
|
|
67
|
+
return scale.bandwidth() / 2;
|
|
68
|
+
} else {
|
|
69
|
+
return 0;
|
|
39
70
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
$:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/*
|
|
51
|
-
x={["prop1" ,"prop2"]}
|
|
52
|
-
y="prop3"
|
|
53
|
-
*/
|
|
54
|
-
return xValue.filter(notNull).map((xValue) => {
|
|
55
|
-
return {
|
|
56
|
-
x: $xScale(xValue) + getOffset($xScale(xValue), offsetX, $xScale),
|
|
57
|
-
y: $yScale(yValue) + getOffset($yScale(yValue), offsetY, $yScale),
|
|
58
|
-
r: $config.r ? $rGet(d) : r,
|
|
59
|
-
xValue,
|
|
60
|
-
yValue,
|
|
61
|
-
data: d,
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else if (Array.isArray(yValue)) {
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
$: pointsData = data ?? $contextData;
|
|
74
|
+
|
|
75
|
+
$: points = pointsData
|
|
76
|
+
.flatMap((d: any) => {
|
|
77
|
+
const xValue = $x(d);
|
|
78
|
+
const yValue = $y(d);
|
|
79
|
+
|
|
80
|
+
if (Array.isArray(xValue)) {
|
|
66
81
|
/*
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
x={["prop1" ,"prop2"]}
|
|
83
|
+
y="prop3"
|
|
84
|
+
*/
|
|
85
|
+
return xValue.filter(notNull).map((xValue: number) => {
|
|
86
|
+
return {
|
|
87
|
+
x: $xScale(xValue) + getOffset($xScale(xValue), offsetX, $xScale),
|
|
88
|
+
y: $yScale(yValue) + getOffset($yScale(yValue), offsetY, $yScale),
|
|
89
|
+
r: $config.r ? $rGet(d) : r,
|
|
90
|
+
xValue,
|
|
91
|
+
yValue,
|
|
92
|
+
data: d,
|
|
93
|
+
};
|
|
79
94
|
});
|
|
80
|
-
|
|
81
|
-
else if (xValue != null && yValue != null) {
|
|
95
|
+
} else if (Array.isArray(yValue)) {
|
|
82
96
|
/*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return {
|
|
97
|
+
x="prop1"
|
|
98
|
+
y={["prop2" ,"prop3"]}
|
|
99
|
+
*/
|
|
100
|
+
return yValue.filter(notNull).map((yValue: number) => {
|
|
101
|
+
return {
|
|
87
102
|
x: $xScale(xValue) + getOffset($xScale(xValue), offsetX, $xScale),
|
|
88
103
|
y: $yScale(yValue) + getOffset($yScale(yValue), offsetY, $yScale),
|
|
89
104
|
r: $config.r ? $rGet(d) : r,
|
|
90
105
|
xValue,
|
|
91
106
|
yValue,
|
|
92
107
|
data: d,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
} else if (xValue != null && yValue != null) {
|
|
111
|
+
/*
|
|
112
|
+
x="prop1"
|
|
113
|
+
y="prop2"
|
|
114
|
+
*/
|
|
115
|
+
return {
|
|
116
|
+
x: $xScale(xValue) + getOffset($xScale(xValue), offsetX, $xScale),
|
|
117
|
+
y: $yScale(yValue) + getOffset($yScale(yValue), offsetY, $yScale),
|
|
118
|
+
r: $config.r ? $rGet(d) : r,
|
|
119
|
+
xValue,
|
|
120
|
+
yValue,
|
|
121
|
+
data: d,
|
|
93
122
|
};
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
.filter((p) => p);
|
|
97
|
-
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
.filter((p: Point) => p) as Point[];
|
|
126
|
+
|
|
127
|
+
$: _links = pointsData.flatMap((d: any) => {
|
|
98
128
|
const xValue = $x(d);
|
|
99
129
|
const yValue = $y(d);
|
|
130
|
+
|
|
100
131
|
if (Array.isArray(xValue)) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
132
|
+
/*
|
|
133
|
+
x={["prop1" ,"prop2"]}
|
|
134
|
+
y="prop3"
|
|
135
|
+
*/
|
|
136
|
+
const [xMin, xMax] = extent($xGet(d)) as unknown as [number, number];
|
|
137
|
+
const y = $yGet(d) + getOffset($yGet(d), offsetY, $yScale);
|
|
138
|
+
return {
|
|
139
|
+
source: {
|
|
140
|
+
x: xMin + getOffset(xMin, offsetX, $xScale) + ($config.r ? $rGet(d) : r),
|
|
141
|
+
y,
|
|
142
|
+
},
|
|
143
|
+
target: {
|
|
144
|
+
x: xMax + getOffset(xMax, offsetX, $xScale) - ($config.r ? $rGet(d) : r),
|
|
145
|
+
y: y,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
} else if (Array.isArray(yValue)) {
|
|
149
|
+
/*
|
|
150
|
+
x="prop1"
|
|
151
|
+
y={["prop2" ,"prop3"]}
|
|
152
|
+
*/
|
|
153
|
+
const x = $xGet(d) + getOffset($xGet(d), offsetX, $xScale);
|
|
154
|
+
const [yMin, yMax] = extent($yGet(d)) as unknown as [number, number];
|
|
155
|
+
return {
|
|
156
|
+
source: {
|
|
157
|
+
x: x,
|
|
158
|
+
y: yMin + getOffset(yMin, offsetY, $yScale),
|
|
159
|
+
},
|
|
160
|
+
target: {
|
|
161
|
+
x: x,
|
|
162
|
+
y: yMax + getOffset(yMax, offsetY, $yScale),
|
|
163
|
+
},
|
|
164
|
+
};
|
|
117
165
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
source: {
|
|
127
|
-
x: x,
|
|
128
|
-
y: yMin + getOffset(yMin, offsetY, $yScale),
|
|
129
|
-
},
|
|
130
|
-
target: {
|
|
131
|
-
x: x,
|
|
132
|
-
y: yMax + getOffset(yMax, offsetY, $yScale),
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
138
|
-
$: ctx = canvas?.ctx;
|
|
139
|
-
$: if (renderContext === 'canvas' && $ctx) {
|
|
140
|
-
let computedStyles = {};
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
169
|
+
$: ctx = canvas?.ctx;
|
|
170
|
+
$: if (renderContext === 'canvas' && $ctx) {
|
|
171
|
+
let computedStyles: Partial<CSSStyleDeclaration> = {};
|
|
172
|
+
|
|
141
173
|
// Transfer classes defined on <GeoPath> to <canvas> to enable window.getComputedStyle() retrieval (Tailwind classes, etc)
|
|
142
174
|
if (className) {
|
|
143
|
-
|
|
144
|
-
|
|
175
|
+
$ctx.canvas.classList.add(...className.split(' '));
|
|
176
|
+
computedStyles = window.getComputedStyle($ctx.canvas);
|
|
145
177
|
}
|
|
178
|
+
|
|
146
179
|
// Clear with negative offset due to Canvas `context.translate(...)`
|
|
147
180
|
$ctx.clearRect(-$padding.left, -$padding.top, $containerWidth, $containerHeight);
|
|
181
|
+
|
|
148
182
|
if (render) {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
render($ctx, points);
|
|
184
|
+
} else {
|
|
185
|
+
points.forEach((point) => {
|
|
186
|
+
$ctx.beginPath();
|
|
187
|
+
$ctx.arc(point.x, point.y, point.r, 0, 2 * Math.PI, false);
|
|
188
|
+
|
|
189
|
+
$ctx.lineWidth = Number(strokeWidth ?? 0);
|
|
190
|
+
$ctx.strokeStyle =
|
|
191
|
+
(stroke ?? computedStyles.stroke === 'none')
|
|
192
|
+
? 'transparent'
|
|
193
|
+
: (computedStyles.stroke ?? '');
|
|
194
|
+
$ctx.stroke();
|
|
195
|
+
|
|
196
|
+
$ctx.fillStyle =
|
|
197
|
+
fill ??
|
|
198
|
+
(computedStyles.fill !== DEFAULT_FILL ? computedStyles.fill : undefined) ??
|
|
199
|
+
'transparent';
|
|
200
|
+
$ctx.fill();
|
|
201
|
+
});
|
|
167
202
|
}
|
|
168
|
-
}
|
|
203
|
+
}
|
|
169
204
|
</script>
|
|
170
205
|
|
|
171
206
|
<slot {points}>
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
export let
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { uniqueId } from '@layerstack/utils';
|
|
3
|
+
|
|
4
|
+
/** Unique id for linearGradient */
|
|
5
|
+
export let id: string = uniqueId('radialGradient-');
|
|
6
|
+
|
|
7
|
+
/** Array array of strings (colors), will equally distributed from 0-100%. If array of tuples, will use first value as the offset, and second as color */
|
|
8
|
+
export let stops: string[] | [string | number, string][] = [
|
|
6
9
|
'var(--tw-gradient-from)',
|
|
7
10
|
'var(--tw-gradient-to)',
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export let cx = '50%';
|
|
14
|
+
export let cy = '50%';
|
|
15
|
+
export let fx = cx;
|
|
16
|
+
export let fy = cy;
|
|
17
|
+
export let r = '50%';
|
|
18
|
+
// TODO: Svelte / Typescript does not know `<radialRadiant fr="...">`
|
|
19
|
+
// export let fr = '0%';
|
|
20
|
+
|
|
21
|
+
/** Indicates how the gradient behaves if it starts or ends inside the bounds of the shape containing the gradient */
|
|
22
|
+
export let spreadMethod: 'pad' | 'reflect' | 'repeat' = 'pad';
|
|
23
|
+
|
|
24
|
+
export let transform: string | null | undefined = undefined;
|
|
25
|
+
|
|
26
|
+
/** Define the coordinate system for attributes (i.e. gradientUnits) */
|
|
27
|
+
export let units: 'objectBoundingBox' | 'userSpaceOnUse' = 'objectBoundingBox';
|
|
21
28
|
</script>
|
|
22
29
|
|
|
23
30
|
<defs>
|
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tick } from 'svelte';
|
|
3
|
+
import { cls } from '@layerstack/tailwind';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
motionStore,
|
|
7
|
+
resolveOptions,
|
|
8
|
+
type SpringOptions,
|
|
9
|
+
type TweenedOptions,
|
|
10
|
+
} from '../stores/motionStore.js';
|
|
11
|
+
|
|
12
|
+
export let x = 0;
|
|
13
|
+
export let initialX = x;
|
|
14
|
+
|
|
15
|
+
export let y = 0;
|
|
16
|
+
export let initialY = y;
|
|
17
|
+
|
|
18
|
+
export let width: number;
|
|
19
|
+
export let initialWidth = width;
|
|
20
|
+
|
|
21
|
+
export let height: number;
|
|
22
|
+
export let initialHeight = height;
|
|
23
|
+
|
|
24
|
+
export let spring: boolean | SpringOptions | { [prop: string]: SpringOptions } = undefined;
|
|
25
|
+
export let tweened: boolean | TweenedOptions | { [prop: string]: TweenedOptions } = undefined;
|
|
26
|
+
|
|
27
|
+
let tweened_x = motionStore(initialX, resolveOptions('x', { spring, tweened }));
|
|
28
|
+
let tweened_y = motionStore(initialY, resolveOptions('y', { spring, tweened }));
|
|
29
|
+
let tweened_width = motionStore(initialWidth, resolveOptions('width', { spring, tweened }));
|
|
30
|
+
let tweened_height = motionStore(initialHeight, resolveOptions('height', { spring, tweened }));
|
|
31
|
+
|
|
32
|
+
$: tick().then(() => {
|
|
19
33
|
tweened_x.set(x);
|
|
20
34
|
tweened_y.set(y);
|
|
21
35
|
tweened_width.set(width);
|
|
22
36
|
tweened_height.set(height);
|
|
23
|
-
});
|
|
37
|
+
});
|
|
24
38
|
</script>
|
|
25
39
|
|
|
26
40
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export let
|
|
10
|
-
|
|
11
|
-
export let
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import { uniqueId } from '@layerstack/utils';
|
|
4
|
+
|
|
5
|
+
import ClipPath from './ClipPath.svelte';
|
|
6
|
+
import Rect from './Rect.svelte';
|
|
7
|
+
|
|
8
|
+
/** Unique id for clipPath */
|
|
9
|
+
export let id: string = uniqueId('clipPath-');
|
|
10
|
+
|
|
11
|
+
export let x: number = 0;
|
|
12
|
+
export let y: number = 0;
|
|
13
|
+
export let width: number;
|
|
14
|
+
export let height: number;
|
|
15
|
+
export let spring: ComponentProps<Rect>['spring'] = undefined;
|
|
16
|
+
export let tweened: ComponentProps<Rect>['tweened'] = undefined;
|
|
12
17
|
</script>
|
|
13
18
|
|
|
14
19
|
<ClipPath {id} let:url>
|
|
@@ -1,47 +1,55 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { extent } from 'd3-array';
|
|
3
|
+
import { pointRadial } from 'd3-shape';
|
|
4
|
+
import { cls } from '@layerstack/tailwind';
|
|
5
|
+
|
|
6
|
+
import { chartContext } from './ChartContext.svelte';
|
|
7
|
+
import Circle from './Circle.svelte';
|
|
8
|
+
import Line from './Line.svelte';
|
|
9
|
+
|
|
10
|
+
const { xScale, yScale, xRange, yRange, radial } = chartContext();
|
|
11
|
+
|
|
12
|
+
$: [xRangeMin, xRangeMax] = extent<number | Date>($xRange);
|
|
13
|
+
$: [yRangeMin, yRangeMax] = extent<number | Date>($yRange);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create a vertical `x` line
|
|
17
|
+
* - If true or 'left', will draw at chart left (xRange[0])
|
|
18
|
+
* - If 'right', will draw at chart right (xRange[1])
|
|
19
|
+
* - Use `0` for baseline (yScale(0))
|
|
20
|
+
* - Use number | Date value for annotation (yScale(value))
|
|
21
|
+
*/
|
|
22
|
+
export let x: number | Date | boolean | 'left' | 'right' = false;
|
|
23
|
+
|
|
24
|
+
/** Pixel offset to apply to `x` coordinate */
|
|
25
|
+
export let xOffset = 0;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a horizontal `y` line
|
|
29
|
+
* - If true or 'bottom', will draw at chart bottom (yRange[0])
|
|
30
|
+
* - If 'top', will draw at chart top (yRange[1])
|
|
31
|
+
* - Use `0` for baseline (xScale(0))
|
|
32
|
+
* - Use number | Date value for annotation (xScale(value))
|
|
33
|
+
*/
|
|
34
|
+
export let y: number | Date | boolean | 'top' | 'bottom' = false;
|
|
35
|
+
|
|
36
|
+
/** Pixel offset to apply to `y` coordinate */
|
|
37
|
+
export let yOffset = 0;
|
|
38
|
+
|
|
39
|
+
$: showRule = (value: typeof x | typeof y, axis: 'x' | 'y') => {
|
|
31
40
|
switch (typeof value) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
41
|
+
case 'boolean':
|
|
42
|
+
return value;
|
|
43
|
+
case 'string':
|
|
44
|
+
return true;
|
|
45
|
+
default:
|
|
46
|
+
if (axis === 'x') {
|
|
47
|
+
return $xScale(value) >= xRangeMin! && $xScale(value) <= xRangeMax!;
|
|
48
|
+
} else {
|
|
49
|
+
return $yScale(value) >= yRangeMin! && $yScale(value) <= yRangeMax!;
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
|
-
}
|
|
52
|
+
};
|
|
45
53
|
</script>
|
|
46
54
|
|
|
47
55
|
<g class="rule">
|