layerchart 0.26.1 → 0.27.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.
|
@@ -88,7 +88,8 @@ export let geo = undefined;
|
|
|
88
88
|
>
|
|
89
89
|
<GeoContext {...geo} let:projection>
|
|
90
90
|
{#if tooltip}
|
|
91
|
-
|
|
91
|
+
{@const tooltipProps = typeof tooltip === 'object' ? tooltip : {}}
|
|
92
|
+
<TooltipContext {...tooltipProps} let:tooltip>
|
|
92
93
|
<slot
|
|
93
94
|
{aspectRatio}
|
|
94
95
|
{containerHeight}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script context="module">import { getContext, setContext } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
|
-
import { geoMercator } from 'd3-geo';
|
|
4
|
-
export const geoContextKey =
|
|
3
|
+
import { geoMercator, } from 'd3-geo';
|
|
4
|
+
export const geoContextKey = Symbol();
|
|
5
5
|
export function geoContext() {
|
|
6
6
|
return getContext(geoContextKey);
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import { type Writable } from 'svelte/store';
|
|
3
3
|
import { type GeoIdentityTransform, type GeoPermissibleObjects, type GeoProjection } from 'd3-geo';
|
|
4
|
-
export declare const geoContextKey:
|
|
4
|
+
export declare const geoContextKey: unique symbol;
|
|
5
5
|
export type GeoContext = Writable<GeoProjection | GeoIdentityTransform>;
|
|
6
6
|
export declare function geoContext(): GeoContext;
|
|
7
7
|
declare const __propDef: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script context="module">import { getContext, setContext } from 'svelte';
|
|
2
|
-
export const tooltipContextKey =
|
|
2
|
+
export const tooltipContextKey = Symbol();
|
|
3
3
|
const defaultContext = writable({
|
|
4
4
|
x: 0,
|
|
5
5
|
y: 0,
|
|
@@ -16,7 +16,6 @@ function setTooltipContext(tooltip) {
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<script>import { raise } from 'layercake';
|
|
19
|
-
import { createEventDispatcher } from 'svelte';
|
|
20
19
|
import { writable } from 'svelte/store';
|
|
21
20
|
import { bisector, max, min } from 'd3-array';
|
|
22
21
|
import { Delaunay } from 'd3-delaunay';
|
|
@@ -27,7 +26,6 @@ import ChartClipPath from './ChartClipPath.svelte';
|
|
|
27
26
|
import { localPoint } from '../utils/event';
|
|
28
27
|
import { isScaleBand, scaleInvert } from '../utils/scales';
|
|
29
28
|
import { quadtreeRects } from '../utils/quadtree';
|
|
30
|
-
const dispatch = createEventDispatcher();
|
|
31
29
|
const { flatData, x, xScale, xGet, xRange, y, yScale, yGet, yRange, width, height, padding } = getContext('LayerCake');
|
|
32
30
|
/*
|
|
33
31
|
TODO: Defaults to consider (if possible to detect scale type, which might not be possible)
|
|
@@ -55,6 +53,7 @@ export let raiseTarget = false;
|
|
|
55
53
|
export let radius = Infinity;
|
|
56
54
|
/** Enable debug view (show hit targets, etc) */
|
|
57
55
|
export let debug = false;
|
|
56
|
+
export let onClick = () => { };
|
|
58
57
|
const tooltip = writable({ y: 0, x: 0, data: null, show: showTooltip, hide: hideTooltip });
|
|
59
58
|
setTooltipContext(tooltip);
|
|
60
59
|
let hideTimeoutId;
|
|
@@ -297,7 +296,7 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
297
296
|
on:mousemove={showTooltip}
|
|
298
297
|
on:mouseleave={hideTooltip}
|
|
299
298
|
on:click={(e) => {
|
|
300
|
-
|
|
299
|
+
onClick({ data: $tooltip?.data });
|
|
301
300
|
}}
|
|
302
301
|
/>
|
|
303
302
|
</Html>
|
|
@@ -313,7 +312,7 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
313
312
|
on:mousemove={(e) => showTooltip(e, point.data)}
|
|
314
313
|
on:mouseleave={hideTooltip}
|
|
315
314
|
on:click={(e) => {
|
|
316
|
-
|
|
315
|
+
onClick({ data: point.data });
|
|
317
316
|
}}
|
|
318
317
|
/>
|
|
319
318
|
</g>
|
|
@@ -334,7 +333,7 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
334
333
|
on:mousemove={(e) => showTooltip(e, rect.data)}
|
|
335
334
|
on:mouseleave={hideTooltip}
|
|
336
335
|
on:click={(e) => {
|
|
337
|
-
|
|
336
|
+
onClick({ data: rect.data });
|
|
338
337
|
}}
|
|
339
338
|
/>
|
|
340
339
|
{/each}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { Readable } from 'svelte/store';
|
|
3
|
-
export declare const tooltipContextKey:
|
|
3
|
+
export declare const tooltipContextKey: unique symbol;
|
|
4
4
|
export type TooltipContextValue = {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -23,12 +23,11 @@ declare const __propDef: {
|
|
|
23
23
|
* @type {number}
|
|
24
24
|
*/ radius?: number | undefined;
|
|
25
25
|
/** Enable debug view (show hit targets, etc) */ debug?: boolean | undefined;
|
|
26
|
+
onClick?: (({ data }: {
|
|
27
|
+
data: any;
|
|
28
|
+
}) => any) | undefined;
|
|
26
29
|
};
|
|
27
30
|
events: {
|
|
28
|
-
click: CustomEvent<{
|
|
29
|
-
data: any;
|
|
30
|
-
}>;
|
|
31
|
-
} & {
|
|
32
31
|
[evt: string]: CustomEvent<any>;
|
|
33
32
|
};
|
|
34
33
|
slots: {
|