layerchart 0.41.1 → 0.41.3
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 ??
|
|
@@ -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,6 +13,7 @@ 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;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { tile as d3Tile } from 'd3-tile';
|
|
3
3
|
import { geoContext } from './GeoContext.svelte';
|
|
4
|
+
import Group from './Group.svelte';
|
|
4
5
|
import TileImage from './TileImage.svelte';
|
|
5
6
|
export let url;
|
|
6
7
|
export let zoomDelta = 0;
|
|
7
8
|
export let tileSize = 256;
|
|
8
9
|
export let disableCache = false;
|
|
9
10
|
export let debug = false;
|
|
10
|
-
const {
|
|
11
|
+
const { containerWidth, containerHeight, padding } = getContext('LayerCake');
|
|
11
12
|
const canvas = getContext('canvas');
|
|
12
13
|
const geo = geoContext();
|
|
14
|
+
$: center = $geo([0, 0]) ?? [0, 0];
|
|
13
15
|
$: tile = d3Tile()
|
|
14
|
-
.size([$
|
|
16
|
+
.size([$containerWidth, $containerHeight])
|
|
17
|
+
.translate([center[0] + $padding.left, center[1] + $padding.top])
|
|
15
18
|
.scale($geo.scale() * 2 * Math.PI)
|
|
16
|
-
.translate($geo([0, 0]) ?? [0, 0]) // TODO: Only works with Mercator
|
|
17
19
|
.tileSize(tileSize)
|
|
18
20
|
.zoomDelta(zoomDelta);
|
|
19
21
|
$: tiles = tile();
|
|
@@ -38,8 +40,10 @@ $: if (renderContext === 'canvas' && $ctx && url) {
|
|
|
38
40
|
|
|
39
41
|
{#if renderContext === 'svg' && url}
|
|
40
42
|
<slot {tiles}>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
<Group x={-$padding.left} y={-$padding.top}>
|
|
44
|
+
{#each tiles as [x, y, z] (url(x, y, z))}
|
|
45
|
+
<TileImage {url} {x} {y} {z} {tx} {ty} {k} {disableCache} {debug} />
|
|
46
|
+
{/each}
|
|
47
|
+
</Group>
|
|
44
48
|
</slot>
|
|
45
49
|
{/if}
|
|
@@ -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';
|
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.3",
|
|
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": {
|