layerchart 0.40.3 → 0.41.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/GeoPath.svelte +1 -0
- package/dist/components/GeoPath.svelte.d.ts +1 -0
- package/dist/components/Highlight.svelte +6 -4
- package/dist/components/Highlight.svelte.d.ts +1 -0
- package/dist/components/Tooltip.svelte +5 -5
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/TooltipContext.svelte +10 -0
- package/dist/components/Voronoi.svelte +4 -0
- package/dist/components/Voronoi.svelte.d.ts +2 -0
- package/package.json +1 -1
|
@@ -79,6 +79,7 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
79
79
|
on:pointermove
|
|
80
80
|
on:pointerleave={(e) => tooltip?.hide()}
|
|
81
81
|
on:pointerleave
|
|
82
|
+
on:pointerdown
|
|
82
83
|
on:click={(event) => dispatch('click', { geoPath, event })}
|
|
83
84
|
on:click
|
|
84
85
|
class={cls(fill == null && 'fill-transparent', className)}
|
|
@@ -20,6 +20,8 @@ export let lines = false;
|
|
|
20
20
|
export let area = false;
|
|
21
21
|
/** Show bar and pass props to Rect */
|
|
22
22
|
export let bar = false;
|
|
23
|
+
/** Set to false to disable spring transitions */
|
|
24
|
+
export let motion = true;
|
|
23
25
|
// TODO: Fix circle points being backwards for stack (see AreaStack)
|
|
24
26
|
let _points = [];
|
|
25
27
|
let _lines = [];
|
|
@@ -167,7 +169,7 @@ $: if (highlightData) {
|
|
|
167
169
|
{#if area}
|
|
168
170
|
<slot name="area" area={_area}>
|
|
169
171
|
<Rect
|
|
170
|
-
spring
|
|
172
|
+
spring={motion}
|
|
171
173
|
{..._area}
|
|
172
174
|
{...typeof area === 'object' ? area : null}
|
|
173
175
|
class={cls(
|
|
@@ -182,7 +184,7 @@ $: if (highlightData) {
|
|
|
182
184
|
{#if bar}
|
|
183
185
|
<slot name="bar" {bar}>
|
|
184
186
|
<Bar
|
|
185
|
-
spring
|
|
187
|
+
spring={motion}
|
|
186
188
|
x={typeof bar === 'object' ? bar.x : null}
|
|
187
189
|
y={typeof bar === 'object' ? bar.y : null}
|
|
188
190
|
inset={typeof bar === 'object' ? bar.inset : null}
|
|
@@ -200,7 +202,7 @@ $: if (highlightData) {
|
|
|
200
202
|
<slot name="lines" lines={_lines}>
|
|
201
203
|
{#each _lines as line}
|
|
202
204
|
<Line
|
|
203
|
-
spring
|
|
205
|
+
spring={motion}
|
|
204
206
|
x1={line.x1}
|
|
205
207
|
y1={line.y1}
|
|
206
208
|
x2={line.x2}
|
|
@@ -221,7 +223,7 @@ $: if (highlightData) {
|
|
|
221
223
|
<!-- TODO: Improve color with stacked data -->
|
|
222
224
|
{@const fill = $config.r ? $rGet(highlightData) : null}
|
|
223
225
|
<Circle
|
|
224
|
-
spring
|
|
226
|
+
spring={motion}
|
|
225
227
|
cx={point.x}
|
|
226
228
|
cy={point.y}
|
|
227
229
|
r={4}
|
|
@@ -61,6 +61,7 @@ declare const __propDef: {
|
|
|
61
61
|
[prop: string]: import("svelte/motion").TweenedOptions<unknown> | undefined;
|
|
62
62
|
} | undefined;
|
|
63
63
|
}> | undefined;
|
|
64
|
+
/** Set to false to disable spring transitions */ motion?: boolean | undefined;
|
|
64
65
|
};
|
|
65
66
|
events: {
|
|
66
67
|
click: MouseEvent;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { spring } from 'svelte/motion';
|
|
3
2
|
import { fade } from 'svelte/transition';
|
|
4
|
-
import { writable } from 'svelte/store';
|
|
5
3
|
import { cls } from 'svelte-ux';
|
|
6
4
|
import { tooltipContext } from './TooltipContext.svelte';
|
|
5
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
7
6
|
/** `x` position of tooltip. By default uses the pointer/mouse, can also snap to data or an explicit fixed position. */
|
|
8
7
|
export let x = 'pointer';
|
|
9
8
|
/** `y` position of tooltip. By default uses the pointer/mouse, can also snap to data or an explicit fixed position. */
|
|
@@ -14,16 +13,17 @@ export let xOffset = typeof x === 'number' || typeof y === 'number' ? 0 : 10;
|
|
|
14
13
|
export let yOffset = typeof x === 'number' || typeof y === 'number' ? 0 : 10;
|
|
15
14
|
export let anchor = 'top-left';
|
|
16
15
|
export let contained = 'container'; // TODO: Support 'window' using getBoundingClientRect()
|
|
17
|
-
export let animate = true;
|
|
18
16
|
export let variant = 'default';
|
|
17
|
+
/** Set to `false` to disable spring transitions */
|
|
18
|
+
export let motion = true;
|
|
19
19
|
export let header = undefined;
|
|
20
20
|
export let classes = {};
|
|
21
21
|
const { padding, xGet, yGet, containerWidth, containerHeight } = getContext('LayerCake');
|
|
22
22
|
const tooltip = tooltipContext();
|
|
23
23
|
let tooltipWidth = 0;
|
|
24
24
|
let tooltipHeight = 0;
|
|
25
|
-
const xPos =
|
|
26
|
-
const yPos =
|
|
25
|
+
const xPos = motionStore($tooltip.x, { spring: motion });
|
|
26
|
+
const yPos = motionStore($tooltip.y, { spring: motion });
|
|
27
27
|
function alignValue(value, align, addlOffset, tooltipSize) {
|
|
28
28
|
const alignOffset = align === 'center' ? tooltipSize / 2 : align === 'end' ? tooltipSize : 0;
|
|
29
29
|
return value + (align === 'end' ? -addlOffset : addlOffset) - alignOffset;
|
|
@@ -8,8 +8,8 @@ declare const __propDef: {
|
|
|
8
8
|
yOffset?: number | undefined;
|
|
9
9
|
anchor?: ("center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
10
10
|
contained?: false | "container" | undefined;
|
|
11
|
-
animate?: boolean | undefined;
|
|
12
11
|
variant?: "default" | "none" | "invert" | undefined;
|
|
12
|
+
motion?: boolean | undefined;
|
|
13
13
|
header?: ((data: any) => any) | undefined;
|
|
14
14
|
classes?: {
|
|
15
15
|
root?: string | undefined;
|
|
@@ -310,6 +310,11 @@ $: triggerPointEvents = ['bisect-x', 'bisect-y', 'bisect-band', 'quadtree'].incl
|
|
|
310
310
|
on:pointerenter={(e) => showTooltip(e.detail.event, e.detail.data)}
|
|
311
311
|
on:pointermove={(e) => showTooltip(e.detail.event, e.detail.data)}
|
|
312
312
|
on:pointerleave={hideTooltip}
|
|
313
|
+
on:pointerdown={(e) => {
|
|
314
|
+
if (e.target.hasPointerCapture(e.pointerId)) {
|
|
315
|
+
e.target.releasePointerCapture(e.pointerId);
|
|
316
|
+
}
|
|
317
|
+
}}
|
|
313
318
|
on:click={(e) => {
|
|
314
319
|
onClick({ data: e.detail.data });
|
|
315
320
|
}}
|
|
@@ -329,6 +334,11 @@ $: triggerPointEvents = ['bisect-x', 'bisect-y', 'bisect-band', 'quadtree'].incl
|
|
|
329
334
|
on:pointerenter={(e) => showTooltip(e, rect.data)}
|
|
330
335
|
on:pointermove={(e) => showTooltip(e, rect.data)}
|
|
331
336
|
on:pointerleave={hideTooltip}
|
|
337
|
+
on:pointerdown={(e) => {
|
|
338
|
+
if (e.target.hasPointerCapture(e.pointerId)) {
|
|
339
|
+
e.target.releasePointerCapture(e.pointerId);
|
|
340
|
+
}
|
|
341
|
+
}}
|
|
332
342
|
on:click={(e) => {
|
|
333
343
|
onClick({ data: rect.data });
|
|
334
344
|
}}
|
|
@@ -33,6 +33,7 @@ $: boundHeight = Math.max($height, 0);
|
|
|
33
33
|
<GeoPath
|
|
34
34
|
geojson={feature}
|
|
35
35
|
class={cls('fill-transparent', classes.path)}
|
|
36
|
+
on:pointerenter
|
|
36
37
|
on:pointermove={(e) =>
|
|
37
38
|
dispatch('pointermove', { event: e, data: feature.properties.site.data, feature })}
|
|
38
39
|
on:pointerleave
|
|
@@ -40,6 +41,7 @@ $: boundHeight = Math.max($height, 0);
|
|
|
40
41
|
// Prevent touch to not interfer with pointer
|
|
41
42
|
e.preventDefault();
|
|
42
43
|
}}
|
|
44
|
+
on:pointerdown
|
|
43
45
|
on:click={(e) => dispatch('click', { data: feature.properties.site.data, feature })}
|
|
44
46
|
/>
|
|
45
47
|
{/each}
|
|
@@ -49,12 +51,14 @@ $: boundHeight = Math.max($height, 0);
|
|
|
49
51
|
<path
|
|
50
52
|
d={voronoi.renderCell(i)}
|
|
51
53
|
class={cls('fill-transparent', classes.path)}
|
|
54
|
+
on:pointerenter
|
|
52
55
|
on:pointermove={(e) => dispatch('pointermove', { event: e, data: point.data, point })}
|
|
53
56
|
on:pointerleave
|
|
54
57
|
on:touchmove={(e) => {
|
|
55
58
|
// Prevent touch to not interfer with pointer
|
|
56
59
|
e.preventDefault();
|
|
57
60
|
}}
|
|
61
|
+
on:pointerdown
|
|
58
62
|
on:click={(e) => dispatch('click', { data: point.data, point })}
|
|
59
63
|
/>
|
|
60
64
|
{/each}
|