layerchart 0.41.0 → 0.41.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { createEventDispatcher, getContext } from 'svelte';
|
|
2
|
-
import {} from 'd3-geo';
|
|
2
|
+
import { geoTransform as d3geoTransform, } from 'd3-geo';
|
|
3
3
|
import { cls } from 'svelte-ux';
|
|
4
4
|
import { geoContext } from './GeoContext.svelte';
|
|
5
5
|
import { curveLinearClosed } from 'd3-shape';
|
|
@@ -30,7 +30,13 @@ const dispatch = createEventDispatcher();
|
|
|
30
30
|
const { width, height } = getContext('LayerCake');
|
|
31
31
|
const canvas = getContext('canvas');
|
|
32
32
|
const geo = geoContext();
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Apply geo transform to projection. Useful to draw straight lines with `geoMercator` projection.
|
|
35
|
+
* See: https://d3js.org/d3-geo/projection#geoTransform and https://stackoverflow.com/a/56409480/191902
|
|
36
|
+
**/
|
|
37
|
+
export let geoTransform = undefined;
|
|
38
|
+
$: _projection = geoTransform ? d3geoTransform(geoTransform($geo)) : $geo;
|
|
39
|
+
$: geoPath = geoCurvePath(_projection, curve);
|
|
34
40
|
const DEFAULT_FILL = 'rgb(0, 0, 0)';
|
|
35
41
|
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
36
42
|
$: ctx = canvas?.ctx;
|
|
@@ -44,13 +50,13 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
44
50
|
// console.count('render');
|
|
45
51
|
$ctx.clearRect(0, 0, $width, $height);
|
|
46
52
|
if (render) {
|
|
47
|
-
geoPath = geoCurvePath(
|
|
53
|
+
geoPath = geoCurvePath(_projection, curve, $ctx);
|
|
48
54
|
render($ctx, { geoPath });
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
51
57
|
$ctx.beginPath();
|
|
52
58
|
// Set the context here since setting it in `$: geoPath` is a circular reference
|
|
53
|
-
geoPath = geoCurvePath(
|
|
59
|
+
geoPath = geoCurvePath(_projection, curve, $ctx);
|
|
54
60
|
geoPath(geojson);
|
|
55
61
|
$ctx.fillStyle =
|
|
56
62
|
fill ??
|
|
@@ -79,6 +85,7 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
79
85
|
on:pointermove
|
|
80
86
|
on:pointerleave={(e) => tooltip?.hide()}
|
|
81
87
|
on:pointerleave
|
|
88
|
+
on:pointerdown
|
|
82
89
|
on:click={(event) => dispatch('click', { geoPath, event })}
|
|
83
90
|
on:click
|
|
84
91
|
class={cls(fill == null && 'fill-transparent', className)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { type GeoPath, type GeoPermissibleObjects } from 'd3-geo';
|
|
2
|
+
import { type GeoIdentityTransform, type GeoPath, type GeoPermissibleObjects, type GeoProjection, type GeoTransformPrototype } from 'd3-geo';
|
|
3
3
|
import type { TooltipContextValue } from './TooltipContext.svelte';
|
|
4
4
|
import { type CurveFactory, type CurveFactoryLineOnly } from 'd3-shape';
|
|
5
5
|
declare const __propDef: {
|
|
@@ -13,11 +13,13 @@ declare const __propDef: {
|
|
|
13
13
|
tooltip?: TooltipContextValue | undefined;
|
|
14
14
|
curve?: CurveFactory | CurveFactoryLineOnly | undefined;
|
|
15
15
|
class?: string | undefined;
|
|
16
|
+
geoTransform?: ((projection: GeoProjection | GeoIdentityTransform) => GeoTransformPrototype) | undefined;
|
|
16
17
|
};
|
|
17
18
|
events: {
|
|
18
19
|
pointerenter: PointerEvent;
|
|
19
20
|
pointermove: PointerEvent;
|
|
20
21
|
pointerleave: PointerEvent;
|
|
22
|
+
pointerdown: PointerEvent;
|
|
21
23
|
click: CustomEvent<any>;
|
|
22
24
|
} & {
|
|
23
25
|
[evt: string]: CustomEvent<any>;
|
|
@@ -20,7 +20,7 @@ import { writable } from 'svelte/store';
|
|
|
20
20
|
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
|
-
import { Svg
|
|
23
|
+
import { Svg } from './Chart.svelte';
|
|
24
24
|
import ChartClipPath from './ChartClipPath.svelte';
|
|
25
25
|
import Voronoi from './Voronoi.svelte';
|
|
26
26
|
import { localPoint } from '../utils/event.js';
|
|
@@ -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}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "techniq/layerchart",
|
|
7
|
-
"version": "0.41.
|
|
7
|
+
"version": "0.41.2",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@changesets/cli": "^2.27.5",
|
|
10
10
|
"@mdi/js": "^7.4.47",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@types/topojson-client": "^3.1.4",
|
|
36
36
|
"@types/topojson-simplify": "^3.0.3",
|
|
37
37
|
"autoprefixer": "^10.4.19",
|
|
38
|
-
"marked": "^
|
|
38
|
+
"marked": "^13.0.0",
|
|
39
39
|
"mdsvex": "^0.11.2",
|
|
40
40
|
"posthog-js": "^1.95.1",
|
|
41
|
-
"prettier": "^3.3.
|
|
41
|
+
"prettier": "^3.3.2",
|
|
42
42
|
"prettier-plugin-svelte": "^3.2.4",
|
|
43
43
|
"prism-svelte": "^0.5.0",
|
|
44
44
|
"prism-themes": "^1.9.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"svelte": "^4.2.18",
|
|
50
50
|
"svelte-check": "^3.8.0",
|
|
51
51
|
"svelte-json-tree": "^2.2.0",
|
|
52
|
-
"svelte-preprocess": "^
|
|
52
|
+
"svelte-preprocess": "^6.0.0",
|
|
53
53
|
"svelte2tsx": "^0.7.9",
|
|
54
54
|
"tailwindcss": "^3.4.4",
|
|
55
55
|
"topojson-client": "^3.1.0",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"date-fns": "^3.6.0",
|
|
86
86
|
"layercake": "^8.3.0",
|
|
87
87
|
"lodash-es": "^4.17.21",
|
|
88
|
-
"posthog-js": "^1.
|
|
88
|
+
"posthog-js": "^1.139.1",
|
|
89
89
|
"shapefile": "^0.6.6",
|
|
90
|
-
"svelte-ux": "^0.66.
|
|
90
|
+
"svelte-ux": "^0.66.7",
|
|
91
91
|
"topojson-client": "^3.1.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|