layerchart 0.41.3 → 0.41.5
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/GeoCircle.svelte.d.ts +4 -1
- package/dist/components/GeoPath.svelte +3 -3
- package/dist/components/GeoPath.svelte.d.ts +4 -1
- package/dist/components/GeoTile.svelte +3 -5
- package/dist/components/TileImage.svelte +16 -10
- package/dist/components/TileImage.svelte.d.ts +2 -2
- package/package.json +2 -2
|
@@ -9,7 +9,10 @@ declare const __propDef: {
|
|
|
9
9
|
events: {
|
|
10
10
|
pointermove: PointerEvent;
|
|
11
11
|
pointerleave: PointerEvent;
|
|
12
|
-
click: CustomEvent<
|
|
12
|
+
click: CustomEvent<{
|
|
13
|
+
geoPath: import("d3-geo").GeoPath<any, import("d3-geo").GeoPermissibleObjects>;
|
|
14
|
+
event: MouseEvent;
|
|
15
|
+
}>;
|
|
13
16
|
} & {
|
|
14
17
|
[evt: string]: CustomEvent<any>;
|
|
15
18
|
};
|
|
@@ -27,7 +27,7 @@ export let curve = curveLinearClosed;
|
|
|
27
27
|
let className = undefined;
|
|
28
28
|
export { className as class };
|
|
29
29
|
const dispatch = createEventDispatcher();
|
|
30
|
-
const {
|
|
30
|
+
const { containerWidth, containerHeight, padding } = getContext('LayerCake');
|
|
31
31
|
const canvas = getContext('canvas');
|
|
32
32
|
const geo = geoContext();
|
|
33
33
|
/**
|
|
@@ -48,7 +48,8 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
48
48
|
computedStyles = window.getComputedStyle($ctx.canvas);
|
|
49
49
|
}
|
|
50
50
|
// console.count('render');
|
|
51
|
-
|
|
51
|
+
// Clear with negative offset due to Canvas `context.translate(...)`
|
|
52
|
+
$ctx.clearRect(-$padding.left, -$padding.top, $containerWidth, $containerHeight);
|
|
52
53
|
if (render) {
|
|
53
54
|
geoPath = geoCurvePath(_projection, curve, $ctx);
|
|
54
55
|
render($ctx, { geoPath });
|
|
@@ -87,7 +88,6 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
87
88
|
on:pointerleave
|
|
88
89
|
on:pointerdown
|
|
89
90
|
on:click={(event) => dispatch('click', { geoPath, event })}
|
|
90
|
-
on:click
|
|
91
91
|
class={cls(fill == null && 'fill-transparent', className)}
|
|
92
92
|
/>
|
|
93
93
|
</slot>
|
|
@@ -20,7 +20,10 @@ declare const __propDef: {
|
|
|
20
20
|
pointermove: PointerEvent;
|
|
21
21
|
pointerleave: PointerEvent;
|
|
22
22
|
pointerdown: PointerEvent;
|
|
23
|
-
click: CustomEvent<
|
|
23
|
+
click: CustomEvent<{
|
|
24
|
+
geoPath: GeoPath;
|
|
25
|
+
event: MouseEvent;
|
|
26
|
+
}>;
|
|
24
27
|
} & {
|
|
25
28
|
[evt: string]: CustomEvent<any>;
|
|
26
29
|
};
|
|
@@ -21,17 +21,15 @@ $: tile = d3Tile()
|
|
|
21
21
|
$: tiles = tile();
|
|
22
22
|
$: ({
|
|
23
23
|
translate: [tx, ty],
|
|
24
|
-
scale
|
|
24
|
+
scale,
|
|
25
25
|
} = tiles);
|
|
26
26
|
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
27
27
|
$: ctx = canvas?.ctx;
|
|
28
28
|
$: if (renderContext === 'canvas' && $ctx && url) {
|
|
29
|
-
// console.count('render');
|
|
30
|
-
// $ctx.clearRect(0, 0, $width, $height);
|
|
31
29
|
tiles.forEach(([x, y, z]) => {
|
|
32
30
|
const image = new Image();
|
|
33
31
|
image.onload = () => {
|
|
34
|
-
$ctx.drawImage(image, (x + tx) *
|
|
32
|
+
$ctx.drawImage(image, (x + tx) * scale, (y + ty) * scale, scale, scale);
|
|
35
33
|
};
|
|
36
34
|
image.src = url(x, y, z);
|
|
37
35
|
});
|
|
@@ -42,7 +40,7 @@ $: if (renderContext === 'canvas' && $ctx && url) {
|
|
|
42
40
|
<slot {tiles}>
|
|
43
41
|
<Group x={-$padding.left} y={-$padding.top}>
|
|
44
42
|
{#each tiles as [x, y, z] (url(x, y, z))}
|
|
45
|
-
<TileImage {url} {x} {y} {z} {tx} {ty} {
|
|
43
|
+
<TileImage {url} {x} {y} {z} {tx} {ty} {scale} {disableCache} {debug} />
|
|
46
44
|
{/each}
|
|
47
45
|
</Group>
|
|
48
46
|
</slot>
|
|
@@ -8,9 +8,9 @@ export let y;
|
|
|
8
8
|
export let z;
|
|
9
9
|
/** translate x */
|
|
10
10
|
export let tx;
|
|
11
|
-
/**
|
|
11
|
+
/** translate y */
|
|
12
12
|
export let ty;
|
|
13
|
-
export let
|
|
13
|
+
export let scale;
|
|
14
14
|
export let disableCache = false;
|
|
15
15
|
export let debug = false;
|
|
16
16
|
export let url;
|
|
@@ -58,17 +58,23 @@ $: if (!disableCache) {
|
|
|
58
58
|
<!-- To avoid aliasing artifacts (thin white lines) between tiles, two layers of tiles are drawn, with the lower layer’s tiles enlarged by one pixel -->
|
|
59
59
|
<image
|
|
60
60
|
xlink:href={href}
|
|
61
|
-
x={(x + tx) *
|
|
62
|
-
y={(y + ty) *
|
|
63
|
-
width={
|
|
64
|
-
height={
|
|
61
|
+
x={(x + tx) * scale - 0.5}
|
|
62
|
+
y={(y + ty) * scale - 0.5}
|
|
63
|
+
width={scale + 1}
|
|
64
|
+
height={scale + 1}
|
|
65
65
|
/>
|
|
66
|
-
<image xlink:href={href} x={(x + tx) *
|
|
66
|
+
<image xlink:href={href} x={(x + tx) * scale} y={(y + ty) * scale} width={scale} height={scale} />
|
|
67
67
|
{#if debug}
|
|
68
|
-
<rect
|
|
68
|
+
<rect
|
|
69
|
+
x={(x + tx) * scale}
|
|
70
|
+
y={(y + ty) * scale}
|
|
71
|
+
width={scale}
|
|
72
|
+
height={scale}
|
|
73
|
+
class="stroke-danger/50 fill-none"
|
|
74
|
+
/>
|
|
69
75
|
<Text
|
|
70
|
-
x={(x + tx) *
|
|
71
|
-
y={(y + ty) *
|
|
76
|
+
x={(x + tx) * scale}
|
|
77
|
+
y={(y + ty) * scale}
|
|
72
78
|
verticalAnchor="start"
|
|
73
79
|
dx={2}
|
|
74
80
|
dy={-2}
|
|
@@ -5,8 +5,8 @@ declare const __propDef: {
|
|
|
5
5
|
y: number;
|
|
6
6
|
z: number;
|
|
7
7
|
/** translate x */ tx: number;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/** translate y */ ty: number;
|
|
9
|
+
scale: number;
|
|
10
10
|
disableCache?: boolean | undefined;
|
|
11
11
|
debug?: boolean | undefined;
|
|
12
12
|
url: (x: number, y: number, z: number) => string;
|
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.5",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@changesets/cli": "^2.27.5",
|
|
10
10
|
"@mdi/js": "^7.4.47",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@sveltejs/adapter-auto": "^3.2.1",
|
|
13
13
|
"@sveltejs/kit": "^2.5.10",
|
|
14
14
|
"@sveltejs/package": "^2.3.1",
|
|
15
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
15
16
|
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
|
16
17
|
"@tailwindcss/typography": "^0.5.13",
|
|
17
18
|
"@types/d3-array": "^3.2.1",
|
|
@@ -62,7 +63,6 @@
|
|
|
62
63
|
},
|
|
63
64
|
"type": "module",
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
66
66
|
"d3-array": "^3.2.4",
|
|
67
67
|
"d3-color": "^3.1.0",
|
|
68
68
|
"d3-delaunay": "^6.0.4",
|