layerchart 0.41.6 → 0.43.0
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 +27 -20
- package/dist/components/Arc.svelte.d.ts +2 -2
- package/dist/components/Area.svelte +11 -7
- package/dist/components/Area.svelte.d.ts +3 -3
- package/dist/components/AreaStack.svelte +3 -2
- package/dist/components/Axis.svelte +38 -41
- package/dist/components/Axis.svelte.d.ts +5 -4
- package/dist/components/Bar.svelte +6 -5
- package/dist/components/Bar.svelte.d.ts +3 -2
- package/dist/components/Bars.svelte +5 -4
- package/dist/components/Bars.svelte.d.ts +3 -2
- package/dist/components/Bounds.svelte +7 -5
- package/dist/components/Bounds.svelte.d.ts +8 -8
- package/dist/components/Brush.svelte +8 -6
- package/dist/components/Brush.svelte.d.ts +2 -2
- package/dist/components/Calendar.svelte +4 -3
- package/dist/components/Chart.svelte +72 -86
- package/dist/components/Chart.svelte.d.ts +216 -24
- package/dist/components/ChartClipPath.svelte +6 -6
- package/dist/components/ChartContext.svelte +19 -0
- package/dist/components/ChartContext.svelte.d.ts +89 -0
- package/dist/components/Circle.svelte +1 -0
- package/dist/components/ClipPath.svelte +1 -0
- package/dist/components/ForceSimulation.svelte +182 -25
- package/dist/components/ForceSimulation.svelte.d.ts +11 -1
- package/dist/components/Frame.svelte +8 -7
- package/dist/components/Frame.svelte.d.ts +1 -1
- package/dist/components/GeoCircle.svelte.d.ts +1 -2
- package/dist/components/GeoContext.svelte +2 -1
- package/dist/components/GeoContext.svelte.d.ts +5 -5
- package/dist/components/GeoEdgeFade.svelte +2 -5
- package/dist/components/GeoPath.svelte +9 -5
- package/dist/components/GeoPath.svelte.d.ts +7 -4
- package/dist/components/GeoPoint.svelte +0 -1
- package/dist/components/GeoSpline.svelte +2 -11
- package/dist/components/GeoTile.svelte +3 -1
- package/dist/components/Group.svelte +4 -2
- package/dist/components/Highlight.svelte +16 -10
- package/dist/components/Highlight.svelte.d.ts +16 -15
- package/dist/components/HitCanvas.svelte +5 -2
- package/dist/components/HitCanvas.svelte.d.ts +1 -1
- package/dist/components/Hull.svelte +6 -3
- package/dist/components/Labels.svelte +5 -4
- package/dist/components/Labels.svelte.d.ts +0 -1
- package/dist/components/Legend.svelte +4 -4
- package/dist/components/Legend.svelte.d.ts +2 -2
- package/dist/components/Line.svelte +1 -0
- package/dist/components/Link.svelte +3 -1
- package/dist/components/Pack.svelte +4 -3
- package/dist/components/Partition.svelte +3 -3
- package/dist/components/Partition.svelte.d.ts +2 -1
- package/dist/components/Pie.svelte +7 -6
- package/dist/components/Pie.svelte.d.ts +2 -4
- package/dist/components/Point.svelte +2 -2
- package/dist/components/Points.svelte +4 -3
- package/dist/components/RadialGradient.svelte +2 -2
- package/dist/components/RadialGradient.svelte.d.ts +0 -1
- package/dist/components/Rect.svelte +1 -0
- package/dist/components/Rule.svelte +3 -3
- package/dist/components/Sankey.svelte +9 -3
- package/dist/components/Sankey.svelte.d.ts +2 -2
- package/dist/components/Spline.svelte +9 -6
- package/dist/components/Spline.svelte.d.ts +2 -2
- package/dist/components/Text.svelte +1 -2
- package/dist/components/Threshold.svelte +2 -2
- package/dist/components/Threshold.svelte.d.ts +2 -2
- package/dist/components/TileImage.svelte +4 -1
- package/dist/components/Tooltip.svelte +3 -3
- package/dist/components/TooltipContext.svelte +46 -15
- package/dist/components/TooltipContext.svelte.d.ts +1 -1
- package/dist/components/TooltipItem.svelte.d.ts +1 -1
- package/dist/components/TransformContext.svelte +17 -6
- package/dist/components/TransformControls.svelte +1 -0
- package/dist/components/Tree.svelte +4 -3
- package/dist/components/Tree.svelte.d.ts +3 -3
- package/dist/components/Treemap.svelte +11 -12
- package/dist/components/Treemap.svelte.d.ts +6 -6
- package/dist/components/Voronoi.svelte +8 -3
- package/dist/components/layout/Canvas.svelte +5 -3
- package/dist/components/layout/Html.svelte +3 -3
- package/dist/components/layout/Svg.svelte +6 -3
- package/dist/docs/Code.svelte +2 -3
- package/dist/docs/GeoDebug.svelte +4 -4
- package/dist/docs/Link.svelte +2 -4
- package/dist/docs/Link.svelte.d.ts +14 -5
- package/dist/docs/Preview.svelte +1 -1
- package/dist/docs/TilesetField.svelte +1 -1
- package/dist/docs/TilesetField.svelte.d.ts +1 -1
- package/dist/docs/ViewSourceButton.svelte +4 -4
- package/dist/docs/ViewSourceButton.svelte.d.ts +5 -3
- package/dist/stores/motionStore.d.ts +2 -2
- package/dist/stores/motionStore.js +4 -2
- package/dist/utils/array.d.ts +5 -0
- package/dist/utils/array.js +7 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.js +18 -0
- package/dist/utils/genData.d.ts +23 -23
- package/dist/utils/genData.js +3 -2
- package/dist/utils/geo.d.ts +3 -3
- package/dist/utils/geo.js +2 -0
- package/dist/utils/graph.d.ts +1 -1
- package/dist/utils/graph.js +3 -3
- package/dist/utils/hierarchy.d.ts +1 -1
- package/dist/utils/hierarchy.js +1 -0
- package/dist/utils/rect.d.ts +5 -3
- package/dist/utils/rect.js +7 -11
- package/dist/utils/scales.d.ts +21 -12
- package/dist/utils/scales.js +3 -1
- package/dist/utils/stack.d.ts +5 -2
- package/dist/utils/stack.js +20 -7
- package/dist/utils/threshold.js +1 -0
- package/dist/utils/treemap.d.ts +5 -2
- package/dist/utils/treemap.js +1 -1
- package/package.json +6 -3
|
@@ -21,12 +21,13 @@ import { bisector, max, min } from 'd3-array';
|
|
|
21
21
|
import { quadtree as d3Quadtree } from 'd3-quadtree';
|
|
22
22
|
import { cls, sortFunc } from 'svelte-ux';
|
|
23
23
|
import { Svg } from './Chart.svelte';
|
|
24
|
+
import { chartContext } from './ChartContext.svelte';
|
|
24
25
|
import ChartClipPath from './ChartClipPath.svelte';
|
|
25
26
|
import Voronoi from './Voronoi.svelte';
|
|
26
27
|
import { localPoint } from '../utils/event.js';
|
|
27
28
|
import { isScaleBand, scaleInvert } from '../utils/scales.js';
|
|
28
29
|
import { quadtreeRects } from '../utils/quadtree.js';
|
|
29
|
-
const { flatData, x, xScale, xGet, xRange, y, yScale, yGet, yRange, width, height, containerWidth, containerHeight, padding, } =
|
|
30
|
+
const { flatData, x, xScale, xGet, xRange, y, yScale, yGet, yRange, width, height, containerWidth, containerHeight, padding, } = chartContext();
|
|
30
31
|
/*
|
|
31
32
|
TODO: Defaults to consider (if possible to detect scale type, which might not be possible)
|
|
32
33
|
- scaleTime / scaleLinear: bisect
|
|
@@ -54,7 +55,13 @@ export let radius = Infinity;
|
|
|
54
55
|
/** Enable debug view (show hit targets, etc) */
|
|
55
56
|
export let debug = false;
|
|
56
57
|
export let onClick = () => { };
|
|
57
|
-
const tooltip = writable({
|
|
58
|
+
const tooltip = writable({
|
|
59
|
+
y: 0,
|
|
60
|
+
x: 0,
|
|
61
|
+
data: null,
|
|
62
|
+
show: showTooltip,
|
|
63
|
+
hide: hideTooltip,
|
|
64
|
+
});
|
|
58
65
|
setTooltipContext(tooltip);
|
|
59
66
|
let hideTimeoutId;
|
|
60
67
|
$: bisectX = bisector((d) => {
|
|
@@ -112,10 +119,15 @@ function showTooltip(e, tooltipData) {
|
|
|
112
119
|
const point = localPoint(referenceNode, e);
|
|
113
120
|
const localX = point?.x ?? 0;
|
|
114
121
|
const localY = point?.y ?? 0;
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
if (
|
|
123
|
+
// @ts-expect-error
|
|
124
|
+
e.offsetX < e.currentTarget?.offsetLeft ||
|
|
125
|
+
// @ts-expect-error
|
|
126
|
+
e.offsetX > e.currentTarget?.offsetLeft + e.currentTarget?.offsetWidth ||
|
|
127
|
+
// @ts-expect-error
|
|
128
|
+
e.offsetY < e.currentTarget?.offsetTop ||
|
|
129
|
+
// @ts-expect-error
|
|
130
|
+
e.offsetY > e.currentTarget?.offsetTop + e.currentTarget?.offsetHeight) {
|
|
119
131
|
// Ignore if within padding of chart
|
|
120
132
|
hideTooltip();
|
|
121
133
|
return;
|
|
@@ -148,7 +160,9 @@ function showTooltip(e, tooltipData) {
|
|
|
148
160
|
const yValueAtPoint = scaleInvert($yScale, localY);
|
|
149
161
|
if (isScaleBand($xScale)) {
|
|
150
162
|
// Find point closest to pointer within the x band
|
|
151
|
-
const bandData = $flatData
|
|
163
|
+
const bandData = $flatData
|
|
164
|
+
.filter((d) => $x(d) === xValueAtPoint)
|
|
165
|
+
.sort(sortFunc($y)); // sort for bisect
|
|
152
166
|
const index = bisectY(bandData, yValueAtPoint, 1);
|
|
153
167
|
const previousValue = bandData[index - 1];
|
|
154
168
|
const currentValue = bandData[index];
|
|
@@ -156,7 +170,9 @@ function showTooltip(e, tooltipData) {
|
|
|
156
170
|
}
|
|
157
171
|
else if (isScaleBand($yScale)) {
|
|
158
172
|
// Find point closest to pointer within the y band
|
|
159
|
-
const bandData = $flatData
|
|
173
|
+
const bandData = $flatData
|
|
174
|
+
.filter((d) => $y(d) === yValueAtPoint)
|
|
175
|
+
.sort(sortFunc($x)); // sort for bisect
|
|
160
176
|
const index = bisectX(bandData, xValueAtPoint, 1);
|
|
161
177
|
const previousValue = bandData[index - 1];
|
|
162
178
|
const currentValue = bandData[index];
|
|
@@ -232,6 +248,7 @@ $: if (mode === 'quadtree') {
|
|
|
232
248
|
}
|
|
233
249
|
let rects = [];
|
|
234
250
|
$: if (mode === 'bounds' || mode === 'band') {
|
|
251
|
+
// @ts-expect-error
|
|
235
252
|
rects = $flatData
|
|
236
253
|
.map((d) => {
|
|
237
254
|
const xValue = $xGet(d);
|
|
@@ -240,7 +257,9 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
240
257
|
const y = Array.isArray(yValue) ? yValue[0] : yValue;
|
|
241
258
|
const xOffset = isScaleBand($xScale) ? ($xScale.padding() * $xScale.step()) / 2 : 0;
|
|
242
259
|
const yOffset = isScaleBand($yScale) ? ($yScale.padding() * $yScale.step()) / 2 : 0;
|
|
260
|
+
// @ts-expect-error
|
|
243
261
|
const fullWidth = max($xRange) - min($xRange);
|
|
262
|
+
// @ts-expect-error
|
|
244
263
|
const fullHeight = max($yRange) - min($yRange);
|
|
245
264
|
if (mode === 'band') {
|
|
246
265
|
// full band width/height regardless of value
|
|
@@ -266,7 +285,8 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
266
285
|
? yValue[1] - yValue[0]
|
|
267
286
|
: isScaleBand($yScale)
|
|
268
287
|
? $yScale.step()
|
|
269
|
-
:
|
|
288
|
+
: // @ts-expect-error
|
|
289
|
+
max($yRange) - y,
|
|
270
290
|
data: d,
|
|
271
291
|
};
|
|
272
292
|
}
|
|
@@ -276,6 +296,8 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
276
296
|
$: triggerPointEvents = ['bisect-x', 'bisect-y', 'bisect-band', 'quadtree'].includes(mode);
|
|
277
297
|
</script>
|
|
278
298
|
|
|
299
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
300
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
279
301
|
<div
|
|
280
302
|
style:width="{$width}px"
|
|
281
303
|
style:height="{$height}px"
|
|
@@ -299,19 +321,26 @@ $: triggerPointEvents = ['bisect-x', 'bisect-y', 'bisect-band', 'quadtree'].incl
|
|
|
299
321
|
class="absolute"
|
|
300
322
|
style:width="{$containerWidth}px"
|
|
301
323
|
style:height="{$containerHeight}px"
|
|
302
|
-
style:top="{
|
|
303
|
-
style:left="{
|
|
324
|
+
style:top="-{$padding.top ?? 0}px"
|
|
325
|
+
style:left="-{$padding.left ?? 0}px"
|
|
304
326
|
>
|
|
305
327
|
<slot tooltip={$tooltip} />
|
|
306
328
|
|
|
307
329
|
{#if mode === 'voronoi'}
|
|
308
330
|
<Svg>
|
|
309
331
|
<Voronoi
|
|
310
|
-
on:pointerenter={(e) =>
|
|
311
|
-
|
|
332
|
+
on:pointerenter={(e) => {
|
|
333
|
+
// @ts-expect-error
|
|
334
|
+
showTooltip(e.detail.event, e.detail.data);
|
|
335
|
+
}}
|
|
336
|
+
on:pointermove={(e) => {
|
|
337
|
+
showTooltip(e.detail.event, e.detail.data);
|
|
338
|
+
}}
|
|
312
339
|
on:pointerleave={hideTooltip}
|
|
313
340
|
on:pointerdown={(e) => {
|
|
314
|
-
|
|
341
|
+
// @ts-expect-error
|
|
342
|
+
if (e.target?.hasPointerCapture(e.pointerId)) {
|
|
343
|
+
// @ts-expect-error
|
|
315
344
|
e.target.releasePointerCapture(e.pointerId);
|
|
316
345
|
}
|
|
317
346
|
}}
|
|
@@ -335,7 +364,9 @@ $: triggerPointEvents = ['bisect-x', 'bisect-y', 'bisect-band', 'quadtree'].incl
|
|
|
335
364
|
on:pointermove={(e) => showTooltip(e, rect.data)}
|
|
336
365
|
on:pointerleave={hideTooltip}
|
|
337
366
|
on:pointerdown={(e) => {
|
|
338
|
-
|
|
367
|
+
// @ts-expect-error
|
|
368
|
+
if (e.target?.hasPointerCapture(e.pointerId)) {
|
|
369
|
+
// @ts-expect-error
|
|
339
370
|
e.target.releasePointerCapture(e.pointerId);
|
|
340
371
|
}
|
|
341
372
|
}}
|
|
@@ -28,8 +28,9 @@ function setTransformContext(transform) {
|
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
30
|
<script>import { createEventDispatcher } from 'svelte';
|
|
31
|
+
import { chartContext } from './ChartContext.svelte';
|
|
31
32
|
import { motionStore, motionFinishHandler } from '../stores/motionStore.js';
|
|
32
|
-
const { width, height } =
|
|
33
|
+
const { width, height } = chartContext();
|
|
33
34
|
export let mode = 'none';
|
|
34
35
|
/** Translate towards point (ex. mouse cursor/center) while zooming in/out */
|
|
35
36
|
export let translateOnScale = false;
|
|
@@ -111,8 +112,11 @@ function onPointerMove(e) {
|
|
|
111
112
|
}
|
|
112
113
|
if ($dragging) {
|
|
113
114
|
e.stopPropagation(); // Stop tooltip from trigging (along with `capture: true`)
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
// @ts-expect-error
|
|
116
|
+
e.currentTarget?.setPointerCapture(e.pointerId);
|
|
117
|
+
setTranslate(processTranslate(startTranslate.x, startTranslate.y, deltaX, deltaY, $scale),
|
|
118
|
+
// @ts-expect-error
|
|
119
|
+
spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
function onPointerUp(e) {
|
|
@@ -142,10 +146,14 @@ function onWheel(e) {
|
|
|
142
146
|
if ($scrollMode === 'scale' || pinchToZoom) {
|
|
143
147
|
// https://github.com/d3/d3-zoom#zoom_wheelDelta
|
|
144
148
|
const scaleBy = -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 0.002) * (e.ctrlKey ? 10 : 1);
|
|
145
|
-
scaleTo(Math.pow(2, scaleBy), point,
|
|
149
|
+
scaleTo(Math.pow(2, scaleBy), point,
|
|
150
|
+
// @ts-expect-error
|
|
151
|
+
spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
146
152
|
}
|
|
147
153
|
else if ($scrollMode === 'translate') {
|
|
148
|
-
translate.update((startTranslate) => processTranslate(startTranslate.x, startTranslate.y, -e.deltaX, -e.deltaY, $scale),
|
|
154
|
+
translate.update((startTranslate) => processTranslate(startTranslate.x, startTranslate.y, -e.deltaX, -e.deltaY, $scale),
|
|
155
|
+
// @ts-expect-error
|
|
156
|
+
spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
159
|
/**
|
|
@@ -172,9 +180,11 @@ const translating = motionFinishHandler();
|
|
|
172
180
|
const scaling = motionFinishHandler();
|
|
173
181
|
const moving = derived([dragging, translating, scaling], ([dragging, translating, scaling]) => dragging || translating || scaling);
|
|
174
182
|
export function setTranslate(point, options) {
|
|
183
|
+
// @ts-expect-error
|
|
175
184
|
translating.handle(translate.set(point, options));
|
|
176
185
|
}
|
|
177
186
|
export function setScale(value, options) {
|
|
187
|
+
// @ts-expect-error
|
|
178
188
|
scaling.handle(scale.set(value, options));
|
|
179
189
|
}
|
|
180
190
|
function localPoint(e) {
|
|
@@ -207,8 +217,9 @@ setTransformContext({
|
|
|
207
217
|
});
|
|
208
218
|
</script>
|
|
209
219
|
|
|
220
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
210
221
|
<div
|
|
211
|
-
on:
|
|
222
|
+
on:wheel={onWheel}
|
|
212
223
|
on:pointerdown={onPointerDown}
|
|
213
224
|
on:pointermove={onPointerMove}
|
|
214
225
|
on:touchmove={(e) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
3
|
-
const { data, width, height
|
|
1
|
+
<script>import { tree as d3Tree } from 'd3-hierarchy';
|
|
2
|
+
import { chartContext } from './ChartContext.svelte';
|
|
3
|
+
const { data, width, height } = chartContext();
|
|
4
4
|
/**
|
|
5
5
|
* Sets this tree layout’s node size to the specified two-element array of numbers `[width, height]`.
|
|
6
6
|
* If unset, layout size is used instead. When a node size is specified, the root node is always
|
|
@@ -24,6 +24,7 @@ $: {
|
|
|
24
24
|
tree.separation(separation);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
// @ts-expect-error
|
|
27
28
|
$: treeData = tree($data);
|
|
28
29
|
</script>
|
|
29
30
|
|
|
@@ -11,7 +11,7 @@ declare const __propDef: {
|
|
|
11
11
|
*/ nodeSize?: [number, number] | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* see: https://github.com/d3/d3-hierarchy#tree_separation
|
|
14
|
-
*/ separation?: (a: HierarchyPointNode<any>, b: HierarchyPointNode<any>) => number;
|
|
14
|
+
*/ separation?: ((a: HierarchyPointNode<any>, b: HierarchyPointNode<any>) => number) | undefined;
|
|
15
15
|
orientation?: "vertical" | "horizontal";
|
|
16
16
|
};
|
|
17
17
|
events: {
|
|
@@ -19,8 +19,8 @@ declare const __propDef: {
|
|
|
19
19
|
};
|
|
20
20
|
slots: {
|
|
21
21
|
default: {
|
|
22
|
-
nodes: any;
|
|
23
|
-
links: any;
|
|
22
|
+
nodes: HierarchyPointNode<any>[];
|
|
23
|
+
links: import("d3-hierarchy").HierarchyPointLink<any>[];
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import
|
|
1
|
+
<script>import { treemap as d3treemap, treemapBinary, treemapDice, treemapResquarify, treemapSlice, treemapSliceDice, treemapSquarify, } from 'd3-hierarchy';
|
|
2
|
+
import { chartContext } from './ChartContext.svelte';
|
|
3
3
|
import { aspectTile } from '../utils/treemap.js';
|
|
4
|
-
const { data, width, height } =
|
|
5
|
-
export let tile =
|
|
4
|
+
const { data, width, height } = chartContext();
|
|
5
|
+
export let tile = treemapSquarify;
|
|
6
6
|
export let padding = 0;
|
|
7
7
|
export let paddingInner = 0;
|
|
8
8
|
export let paddingOuter = 0;
|
|
@@ -13,22 +13,21 @@ export let paddingRight = undefined;
|
|
|
13
13
|
export let selected = null;
|
|
14
14
|
$: tileFunc =
|
|
15
15
|
tile === 'squarify'
|
|
16
|
-
?
|
|
16
|
+
? treemapSquarify
|
|
17
17
|
: tile === 'resquarify'
|
|
18
|
-
?
|
|
18
|
+
? treemapResquarify
|
|
19
19
|
: tile === 'binary'
|
|
20
|
-
?
|
|
20
|
+
? treemapBinary
|
|
21
21
|
: tile === 'dice'
|
|
22
|
-
?
|
|
22
|
+
? treemapDice
|
|
23
23
|
: tile === 'slice'
|
|
24
|
-
?
|
|
24
|
+
? treemapSlice
|
|
25
25
|
: tile === 'sliceDice'
|
|
26
|
-
?
|
|
26
|
+
? treemapSliceDice
|
|
27
27
|
: tile;
|
|
28
28
|
let treemap;
|
|
29
29
|
$: {
|
|
30
|
-
treemap =
|
|
31
|
-
.treemap()
|
|
30
|
+
treemap = d3treemap()
|
|
32
31
|
.size([$width, $height])
|
|
33
32
|
.tile(aspectTile(tileFunc, $width, $height));
|
|
34
33
|
if (padding) {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import
|
|
2
|
+
import { treemapSquarify, type HierarchyRectangularNode } from 'd3-hierarchy';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
tile?: typeof
|
|
5
|
+
tile?: typeof treemapSquarify | "binary" | "squarify" | "resquarify" | "dice" | "slice" | "sliceDice";
|
|
6
6
|
padding?: number;
|
|
7
7
|
paddingInner?: number;
|
|
8
8
|
paddingOuter?: number;
|
|
9
9
|
paddingTop?: number;
|
|
10
10
|
paddingBottom?: number;
|
|
11
|
-
paddingLeft?: undefined;
|
|
12
|
-
paddingRight?: undefined;
|
|
13
|
-
selected?: any;
|
|
11
|
+
paddingLeft?: number | undefined;
|
|
12
|
+
paddingRight?: number | undefined;
|
|
13
|
+
selected?: HierarchyRectangularNode<any> | null | undefined;
|
|
14
14
|
};
|
|
15
15
|
events: {
|
|
16
16
|
[evt: string]: CustomEvent<any>;
|
|
17
17
|
};
|
|
18
18
|
slots: {
|
|
19
19
|
default: {
|
|
20
|
-
nodes: any;
|
|
20
|
+
nodes: HierarchyRectangularNode<any>[];
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
<script>import { createEventDispatcher
|
|
2
|
-
import { cls } from 'svelte-ux';
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
3
2
|
import { min } from 'd3-array';
|
|
4
3
|
import { Delaunay } from 'd3-delaunay';
|
|
4
|
+
// @ts-expect-error
|
|
5
5
|
import { geoVoronoi } from 'd3-geo-voronoi';
|
|
6
|
+
import { cls } from 'svelte-ux';
|
|
7
|
+
import { chartContext } from './ChartContext.svelte';
|
|
6
8
|
import GeoPath from './GeoPath.svelte';
|
|
7
9
|
import { geoContext } from './GeoContext.svelte';
|
|
8
|
-
const { flatData, xGet, yGet, x: xContext, y: yContext, width, height } =
|
|
10
|
+
const { flatData, xGet, yGet, x: xContext, y: yContext, width, height } = chartContext();
|
|
9
11
|
const geo = geoContext();
|
|
10
12
|
/** Override data instead of using context */
|
|
11
13
|
export let data = undefined;
|
|
@@ -18,6 +20,7 @@ $: points = (data ?? $flatData).map((d) => {
|
|
|
18
20
|
const x = Array.isArray(xValue) ? min(xValue) : xValue;
|
|
19
21
|
const y = Array.isArray(yValue) ? min(yValue) : yValue;
|
|
20
22
|
const point = [x, y];
|
|
23
|
+
// @ts-expect-error
|
|
21
24
|
point.data = d;
|
|
22
25
|
return point;
|
|
23
26
|
});
|
|
@@ -48,6 +51,8 @@ $: boundHeight = Math.max($height, 0);
|
|
|
48
51
|
{:else}
|
|
49
52
|
{@const voronoi = Delaunay.from(points).voronoi([0, 0, boundWidth, boundHeight])}
|
|
50
53
|
{#each points as point, i}
|
|
54
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
55
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
51
56
|
<path
|
|
52
57
|
d={voronoi.renderCell(i)}
|
|
53
58
|
class={cls('fill-transparent', classes.path)}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { onMount, setContext } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
import { scaleCanvas } from 'layercake';
|
|
4
4
|
import { cls } from 'svelte-ux';
|
|
5
|
+
import { chartContext } from '../ChartContext.svelte';
|
|
5
6
|
import { transformContext } from '../TransformContext.svelte';
|
|
6
|
-
const { width, height, containerWidth, containerHeight, padding } =
|
|
7
|
+
const { width, height, containerWidth, containerHeight, padding } = chartContext();
|
|
7
8
|
/** The `<canvas>` tag. Useful for bindings. */
|
|
8
9
|
export let element = undefined;
|
|
9
10
|
/** The `<canvas>`'s 2d context. Useful for bindings. */
|
|
11
|
+
// @ts-expect-error: set during onMount()
|
|
10
12
|
export let context = undefined;
|
|
11
13
|
/** Force the use of a software (instead of hardware accelerated) 2D canvas and can save memory when calling getImageData() frequently.
|
|
12
14
|
* see: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#willreadfrequently */
|
|
@@ -31,7 +33,7 @@ const { mode, scale, translate } = transformContext();
|
|
|
31
33
|
$: if (context) {
|
|
32
34
|
scaleCanvas(context, $containerWidth, $containerHeight);
|
|
33
35
|
context.clearRect(0, 0, $containerWidth, $containerHeight);
|
|
34
|
-
context.translate($padding.left, $padding.top);
|
|
36
|
+
context.translate($padding.left ?? 0, $padding.top ?? 0);
|
|
35
37
|
if (mode === 'canvas') {
|
|
36
38
|
const center = { x: $width / 2, y: $height / 2 };
|
|
37
39
|
const newTranslate = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script>import { cls } from 'svelte-ux';
|
|
2
|
+
import { chartContext } from '../ChartContext.svelte';
|
|
3
3
|
/** The layer's outermost `<div>` tag. Useful for bindings. */
|
|
4
4
|
export let element = undefined;
|
|
5
5
|
/** The layer's z-index. */
|
|
@@ -14,7 +14,7 @@ export let label = undefined;
|
|
|
14
14
|
export let labelledBy = undefined;
|
|
15
15
|
/** A string passed to the `aria-describedby` property on the `<div>` tag. */
|
|
16
16
|
export let describedBy = undefined;
|
|
17
|
-
const { padding } =
|
|
17
|
+
const { padding } = chartContext();
|
|
18
18
|
$: roleVal = role || (label || labelledBy || describedBy ? 'figure' : undefined);
|
|
19
19
|
</script>
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script>import { cls } from 'svelte-ux';
|
|
2
|
+
import { chartContext } from '../ChartContext.svelte';
|
|
3
3
|
import { transformContext } from '../TransformContext.svelte';
|
|
4
4
|
/** The layer's `<svg>` tag. Useful for bindings. */
|
|
5
5
|
export let element = undefined;
|
|
@@ -19,7 +19,7 @@ export let labelledBy = undefined;
|
|
|
19
19
|
export let describedBy = undefined;
|
|
20
20
|
/** Shorthand to set the contents of `<title></title>` for accessibility. You can also set arbitrary HTML via the "title" slot but this is a convenient shorthand. If you use the "title" slot, this prop is ignored. */
|
|
21
21
|
export let title = undefined;
|
|
22
|
-
const { containerWidth, containerHeight, width, height, padding } =
|
|
22
|
+
const { containerWidth, containerHeight, width, height, padding } = chartContext();
|
|
23
23
|
const { mode, scale, translate } = transformContext();
|
|
24
24
|
let transform = '';
|
|
25
25
|
$: if (mode === 'canvas') {
|
|
@@ -32,6 +32,8 @@ $: if (mode === 'canvas') {
|
|
|
32
32
|
}
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
36
|
+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
35
37
|
<svg
|
|
36
38
|
bind:this={element}
|
|
37
39
|
{viewBox}
|
|
@@ -48,6 +50,7 @@ $: if (mode === 'canvas') {
|
|
|
48
50
|
aria-labelledby={labelledBy}
|
|
49
51
|
aria-describedby={describedBy}
|
|
50
52
|
on:click
|
|
53
|
+
role="figure"
|
|
51
54
|
>
|
|
52
55
|
<slot name="title">
|
|
53
56
|
{#if title}<title>{title}</title>{/if}
|
package/dist/docs/Code.svelte
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
<script>import Prism from 'prismjs';
|
|
2
2
|
import 'prism-svelte';
|
|
3
|
-
import { CopyButton, cls
|
|
3
|
+
import { CopyButton, cls } from 'svelte-ux';
|
|
4
4
|
export let source = null;
|
|
5
5
|
export let language = 'svelte';
|
|
6
6
|
export let highlightedSource = source
|
|
7
7
|
? Prism.highlight(source, Prism.languages[language] ?? Prism.languages.text, language)
|
|
8
8
|
: '';
|
|
9
9
|
export let classes = {};
|
|
10
|
-
const settingsClasses = getComponentClasses('Code');
|
|
11
10
|
</script>
|
|
12
11
|
|
|
13
|
-
<div class={cls('Code', 'rounded',
|
|
12
|
+
<div class={cls('Code', 'rounded', classes.root, $$props.class)}>
|
|
14
13
|
{#if source}
|
|
15
14
|
<div class="relative">
|
|
16
15
|
<pre
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script>import { format, Checkbox, cls } from 'svelte-ux';
|
|
2
|
+
import { chartContext } from '../components/ChartContext.svelte';
|
|
3
3
|
import { geoContext } from '../components/GeoContext.svelte';
|
|
4
|
-
const { width, height } =
|
|
4
|
+
const { width, height } = chartContext();
|
|
5
5
|
const geo = geoContext();
|
|
6
6
|
let showCenter = false;
|
|
7
7
|
</script>
|
|
@@ -33,7 +33,7 @@ let showCenter = false;
|
|
|
33
33
|
|
|
34
34
|
<div>
|
|
35
35
|
<span class="opacity-50">long/lat: <Checkbox bind:checked={showCenter} size="xs" /></span>
|
|
36
|
-
{#each $geo.invert?.([$width / 2, $height / 2]) as coord}
|
|
36
|
+
{#each $geo.invert?.([$width / 2, $height / 2]) ?? [] as coord}
|
|
37
37
|
<div class="text-right">{format(coord, 'decimal')}</div>
|
|
38
38
|
{/each}
|
|
39
39
|
</div>
|
package/dist/docs/Link.svelte
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} LinkProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} LinkEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} LinkSlots */
|
|
4
|
+
export default class Link extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {
|
|
9
|
+
default: {};
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
export type LinkProps = typeof __propDef.props;
|
|
13
|
+
export type LinkEvents = typeof __propDef.events;
|
|
14
|
+
export type LinkSlots = typeof __propDef.slots;
|
|
1
15
|
import { SvelteComponentTyped } from "svelte";
|
|
2
16
|
declare const __propDef: {
|
|
3
17
|
props: {
|
|
@@ -10,9 +24,4 @@ declare const __propDef: {
|
|
|
10
24
|
default: {};
|
|
11
25
|
};
|
|
12
26
|
};
|
|
13
|
-
export type LinkProps = typeof __propDef.props;
|
|
14
|
-
export type LinkEvents = typeof __propDef.events;
|
|
15
|
-
export type LinkSlots = typeof __propDef.slots;
|
|
16
|
-
export default class Link extends SvelteComponentTyped<LinkProps, LinkEvents, LinkSlots> {
|
|
17
|
-
}
|
|
18
27
|
export {};
|
package/dist/docs/Preview.svelte
CHANGED
|
@@ -9,7 +9,7 @@ import Json from './Json.svelte';
|
|
|
9
9
|
export let code = undefined;
|
|
10
10
|
export let data = undefined;
|
|
11
11
|
export let language = 'svelte';
|
|
12
|
-
export let highlightedCode = Prism.highlight(code, Prism.languages.svelte, language);
|
|
12
|
+
export let highlightedCode = code ? Prism.highlight(code, Prism.languages.svelte, language) : '';
|
|
13
13
|
export let showCode = false;
|
|
14
14
|
let copyValue = null;
|
|
15
15
|
try {
|
|
@@ -89,7 +89,7 @@ $: serviceUrl = getServiceUrl(selected);
|
|
|
89
89
|
toggleIcon={null}
|
|
90
90
|
stepper
|
|
91
91
|
>
|
|
92
|
-
<div slot="append" on:click|stopPropagation>
|
|
92
|
+
<div slot="append" on:click|stopPropagation role="none">
|
|
93
93
|
<div class="text-[10px] text-surface-content/50 text-center">2x</div>
|
|
94
94
|
<Switch bind:checked={doubleScale} size="md" />
|
|
95
95
|
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script>import { Button, Dialog, Toggle, Tooltip } from 'svelte-ux';
|
|
2
|
+
import { mdiGithub } from '@mdi/js';
|
|
3
3
|
import Code from './Code.svelte';
|
|
4
4
|
export let label;
|
|
5
|
-
export let source;
|
|
6
|
-
export let href;
|
|
5
|
+
export let source = undefined;
|
|
6
|
+
export let href = undefined;
|
|
7
7
|
export let icon;
|
|
8
8
|
</script>
|
|
9
9
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import { Button } from 'svelte-ux';
|
|
2
4
|
declare const __propDef: {
|
|
3
5
|
props: {
|
|
4
6
|
label: string;
|
|
5
|
-
source
|
|
6
|
-
href
|
|
7
|
-
icon:
|
|
7
|
+
source?: string | undefined;
|
|
8
|
+
href?: string | undefined;
|
|
9
|
+
icon: ComponentProps<Button>["icon"];
|
|
8
10
|
};
|
|
9
11
|
events: {
|
|
10
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spring, tweened } from 'svelte/motion';
|
|
2
|
-
export type SpringOptions = Parameters<typeof spring
|
|
3
|
-
export type TweenedOptions = Parameters<typeof tweened
|
|
2
|
+
export type SpringOptions = Parameters<typeof spring<any>>[1];
|
|
3
|
+
export type TweenedOptions = Parameters<typeof tweened<any>>[1];
|
|
4
4
|
export type MotionOptions = {
|
|
5
5
|
spring?: boolean | SpringOptions;
|
|
6
6
|
tweened?: boolean | TweenedOptions;
|
|
@@ -22,14 +22,16 @@ export function resolveOptions(prop, options) {
|
|
|
22
22
|
spring: typeof options.spring === 'boolean' || options.spring == null
|
|
23
23
|
? options.spring
|
|
24
24
|
: prop in options.spring
|
|
25
|
-
?
|
|
25
|
+
? //@ts-expect-error
|
|
26
|
+
options.spring[prop]
|
|
26
27
|
: Object.keys(options.spring).some((key) => ['precision', 'damping', 'stiffness'].includes(key))
|
|
27
28
|
? options.tweened
|
|
28
29
|
: false,
|
|
29
30
|
tweened: typeof options.tweened === 'boolean' || options.tweened == null
|
|
30
31
|
? options.tweened
|
|
31
32
|
: prop in options.tweened
|
|
32
|
-
?
|
|
33
|
+
? //@ts-expect-error
|
|
34
|
+
options.tweened[prop]
|
|
33
35
|
: Object.keys(options.tweened).some((key) => ['delay', 'duration', 'easing'].includes(key))
|
|
34
36
|
? options.tweened
|
|
35
37
|
: false,
|