layerchart 0.32.1 → 0.32.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.
- package/dist/components/Axis.svelte.d.ts +2 -2
- package/dist/components/GeoContext.svelte +4 -4
- package/dist/components/GeoPath.svelte +10 -6
- package/dist/components/GeoPath.svelte.d.ts +3 -5
- package/dist/components/GeoSpline.svelte +1 -1
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/Legend.svelte.d.ts +2 -1
- package/dist/components/TooltipContext.svelte +2 -2
- package/dist/components/TooltipItem.svelte.d.ts +2 -1
- package/dist/components/Treemap.svelte.d.ts +1 -1
- package/dist/components/Voronoi.svelte +37 -15
- package/dist/components/Voronoi.svelte.d.ts +7 -6
- package/dist/components/Zoom.svelte.d.ts +1 -1
- package/package.json +15 -15
|
@@ -3,7 +3,7 @@ import { type ComponentProps } from 'svelte';
|
|
|
3
3
|
import { fade } from 'svelte/transition';
|
|
4
4
|
import type { SVGAttributes } from 'svelte/elements';
|
|
5
5
|
import type { spring as springStore, tweened as tweenedStore } from 'svelte/motion';
|
|
6
|
-
import { type TransitionParams } from 'svelte-ux';
|
|
6
|
+
import { type FormatType, type TransitionParams } from 'svelte-ux';
|
|
7
7
|
import Text from './Text.svelte';
|
|
8
8
|
declare const __propDef: {
|
|
9
9
|
props: {
|
|
@@ -12,7 +12,7 @@ declare const __propDef: {
|
|
|
12
12
|
/** Draw a grid lines */ grid?: boolean | SVGAttributes<SVGLineElement> | undefined;
|
|
13
13
|
/** Control the number of ticks*/ ticks?: number | any[] | Function | undefined;
|
|
14
14
|
/** Length of the tick line */ tickSize?: number | undefined;
|
|
15
|
-
format?:
|
|
15
|
+
format?: FormatType | undefined;
|
|
16
16
|
labelProps?: Partial<ComponentProps<Text>> | undefined;
|
|
17
17
|
spring?: boolean | Parameters<typeof springStore>[1];
|
|
18
18
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script context="module">import { getContext, setContext } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
|
-
import {
|
|
3
|
+
import {} from 'd3-geo';
|
|
4
4
|
export const geoContextKey = Symbol();
|
|
5
5
|
export function geoContext() {
|
|
6
6
|
return getContext(geoContextKey);
|
|
@@ -12,7 +12,7 @@ function setGeoContext(geo) {
|
|
|
12
12
|
|
|
13
13
|
<script>const { width, height } = getContext('LayerCake');
|
|
14
14
|
/** @type {Function} projection - A d3 projection function. Pass this in as an uncalled function, e.g. `projection={geoAlbersUsa}`. */
|
|
15
|
-
export let projection =
|
|
15
|
+
export let projection = undefined;
|
|
16
16
|
export let fitGeojson;
|
|
17
17
|
/** By default, the map fills to fit the $width and $height. If instead you want a fixed-aspect ratio, like for a server-side rendered map, set that here. */
|
|
18
18
|
export let fixedAspectRatio = undefined;
|
|
@@ -22,10 +22,10 @@ export let rotate = undefined;
|
|
|
22
22
|
export let scale = undefined;
|
|
23
23
|
export let translate = undefined;
|
|
24
24
|
export let center = undefined;
|
|
25
|
-
const geo = writable(projection());
|
|
25
|
+
const geo = writable(projection?.());
|
|
26
26
|
setGeoContext(geo);
|
|
27
27
|
$: fitSizeRange = (fixedAspectRatio ? [100, 100 / fixedAspectRatio] : [$width, $height]);
|
|
28
|
-
$: {
|
|
28
|
+
$: if (projection) {
|
|
29
29
|
const _projection = projection();
|
|
30
30
|
if (fitGeojson && 'fitSize' in _projection) {
|
|
31
31
|
_projection.fitSize(fitSizeRange, fitGeojson);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script>import { createEventDispatcher, getContext } from 'svelte';
|
|
2
2
|
import { geoPath as d3geoPath } from 'd3-geo';
|
|
3
|
-
import { geoContext } from './GeoContext.svelte';
|
|
4
3
|
import { scaleCanvas } from 'layercake';
|
|
4
|
+
import { cls } from 'svelte-ux';
|
|
5
|
+
import { geoContext } from './GeoContext.svelte';
|
|
5
6
|
export let geojson;
|
|
6
7
|
export let fill = undefined;
|
|
7
|
-
export let fillScale = undefined;
|
|
8
8
|
export let stroke = undefined;
|
|
9
9
|
export let strokeWidth = undefined;
|
|
10
10
|
/** Render to canvas */
|
|
@@ -32,7 +32,7 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
32
32
|
// Set the context here since setting it in `$: geoPath` is a circular reference
|
|
33
33
|
geoPath.context($ctx);
|
|
34
34
|
geoPath(geojson);
|
|
35
|
-
$ctx.fillStyle = fill ||
|
|
35
|
+
$ctx.fillStyle = fill || 'transparent';
|
|
36
36
|
$ctx.fill();
|
|
37
37
|
$ctx.lineWidth = strokeWidth;
|
|
38
38
|
$ctx.strokeStyle = stroke;
|
|
@@ -44,13 +44,17 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
44
44
|
{#if renderContext === 'svg'}
|
|
45
45
|
<slot {geoPath}>
|
|
46
46
|
<path
|
|
47
|
+
{...$$restProps}
|
|
47
48
|
d={geoPath(geojson)}
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
{fill}
|
|
50
|
+
{stroke}
|
|
50
51
|
on:mousemove={(e) => tooltip?.show(e, geojson)}
|
|
52
|
+
on:mousemove
|
|
51
53
|
on:mouseleave={(e) => tooltip?.hide()}
|
|
54
|
+
on:mouseleave
|
|
52
55
|
on:click={(event) => dispatch('click', { geoPath, event })}
|
|
53
|
-
|
|
56
|
+
on:click
|
|
57
|
+
class={cls($$props.fill == null && 'fill-transparent', $$props.class)}
|
|
54
58
|
/>
|
|
55
59
|
</slot>
|
|
56
60
|
{/if}
|
|
@@ -6,7 +6,6 @@ declare const __propDef: {
|
|
|
6
6
|
[x: string]: any;
|
|
7
7
|
geojson: GeoPermissibleObjects;
|
|
8
8
|
fill?: string | undefined;
|
|
9
|
-
fillScale?: Object | undefined;
|
|
10
9
|
stroke?: string | undefined;
|
|
11
10
|
strokeWidth?: number | string | undefined;
|
|
12
11
|
render?: ((ctx: CanvasRenderingContext2D, { geoPath: GeoPath }: {
|
|
@@ -15,10 +14,9 @@ declare const __propDef: {
|
|
|
15
14
|
tooltip?: TooltipContextValue | undefined;
|
|
16
15
|
};
|
|
17
16
|
events: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}>;
|
|
17
|
+
mousemove: MouseEvent;
|
|
18
|
+
mouseleave: MouseEvent;
|
|
19
|
+
click: CustomEvent<any>;
|
|
22
20
|
} & {
|
|
23
21
|
[evt: string]: CustomEvent<any>;
|
|
24
22
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { geoOrthographic, geoInterpolate } from 'd3-geo';
|
|
3
2
|
import { curveNatural } from 'd3-shape';
|
|
3
|
+
import { geoOrthographic, geoInterpolate } from 'd3-geo';
|
|
4
4
|
import { geoContext } from './GeoContext.svelte';
|
|
5
5
|
import Spline from './Spline.svelte';
|
|
6
6
|
export let link;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type FormatType } from 'svelte-ux';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
@@ -7,7 +8,7 @@ declare const __propDef: {
|
|
|
7
8
|
width?: number | undefined;
|
|
8
9
|
height?: number | undefined;
|
|
9
10
|
ticks?: number | undefined;
|
|
10
|
-
tickFormat?:
|
|
11
|
+
tickFormat?: FormatType | undefined;
|
|
11
12
|
tickValues?: any[] | undefined;
|
|
12
13
|
tickFontSize?: number | undefined;
|
|
13
14
|
tickSize?: number | undefined;
|
|
@@ -288,10 +288,10 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
288
288
|
{:else if mode === 'voronoi'}
|
|
289
289
|
<Svg>
|
|
290
290
|
<Voronoi
|
|
291
|
-
on:mousemove={(e) => showTooltip(e.detail.event, e.detail.
|
|
291
|
+
on:mousemove={(e) => showTooltip(e.detail.event, e.detail.data)}
|
|
292
292
|
on:mouseleave={hideTooltip}
|
|
293
293
|
on:click={(e) => {
|
|
294
|
-
onClick({ data: e.detail.
|
|
294
|
+
onClick({ data: e.detail.data });
|
|
295
295
|
}}
|
|
296
296
|
classes={{ path: cls(debug && 'fill-danger/10 stroke-danger') }}
|
|
297
297
|
/>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type FormatType } from 'svelte-ux';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
5
6
|
label: any;
|
|
6
7
|
value?: any;
|
|
7
|
-
format?:
|
|
8
|
+
format?: FormatType | undefined;
|
|
8
9
|
valueAlign?: "center" | "left" | "right" | undefined;
|
|
9
10
|
classes?: {
|
|
10
11
|
label?: string | undefined;
|
|
@@ -2,7 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
import * as d3 from 'd3-hierarchy';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
tile?: "slice" |
|
|
5
|
+
tile?: "slice" | "binary" | "dice" | d3.RatioSquarifyTilingFactory | "squarify" | "resquarify" | "sliceDice" | undefined;
|
|
6
6
|
padding?: number | undefined;
|
|
7
7
|
paddingInner?: number | undefined;
|
|
8
8
|
paddingOuter?: number | undefined;
|
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
<script>import { createEventDispatcher, getContext } from 'svelte';
|
|
2
2
|
import { draw as _drawTransition } from 'svelte/transition';
|
|
3
|
-
import { Delaunay } from 'd3-delaunay';
|
|
4
|
-
import { min } from 'd3-array';
|
|
5
3
|
import { cls } from 'svelte-ux';
|
|
6
|
-
|
|
4
|
+
import { min } from 'd3-array';
|
|
5
|
+
import { Delaunay } from 'd3-delaunay';
|
|
6
|
+
import { geoVoronoi } from 'd3-geo-voronoi';
|
|
7
|
+
import GeoPath from './GeoPath.svelte';
|
|
8
|
+
import { geoContext } from './GeoContext.svelte';
|
|
9
|
+
const { flatData, xGet, yGet, x: xContext, y: yContext, width, height } = getContext('LayerCake');
|
|
10
|
+
const geo = geoContext();
|
|
7
11
|
/** Override data instead of using context */
|
|
8
12
|
export let data = undefined;
|
|
9
13
|
export let classes = {};
|
|
10
14
|
const dispatch = createEventDispatcher();
|
|
11
15
|
$: points = (data ?? $flatData).map((d) => {
|
|
12
|
-
|
|
13
|
-
const
|
|
16
|
+
// geo voronoi needs raw latitude/longtude, not mapped to range (chart dimensions)
|
|
17
|
+
const xValue = $geo ? $xContext(d) : $xGet(d);
|
|
18
|
+
const yValue = $geo ? $yContext(d) : $yGet(d);
|
|
14
19
|
const x = Array.isArray(xValue) ? min(xValue) : xValue;
|
|
15
20
|
const y = Array.isArray(yValue) ? min(yValue) : yValue;
|
|
16
21
|
const point = [x, y];
|
|
17
22
|
point.data = d;
|
|
18
23
|
return point;
|
|
19
24
|
});
|
|
20
|
-
|
|
25
|
+
// Width and/or height can sometimes be negative (when loading data remotely and updately)
|
|
26
|
+
$: boundWidth = Math.max($width, 0);
|
|
27
|
+
$: boundHeight = Math.max($height, 0);
|
|
21
28
|
</script>
|
|
22
29
|
|
|
23
30
|
<g {...$$restProps} class={cls(classes.root, $$props.class)}>
|
|
24
|
-
{#
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
{#if $geo}
|
|
32
|
+
{@const polygons = geoVoronoi().polygons(points)}
|
|
33
|
+
{#each polygons.features as feature}
|
|
34
|
+
<GeoPath
|
|
35
|
+
geojson={feature}
|
|
36
|
+
class={cls('fill-transparent', classes.path)}
|
|
37
|
+
on:mousemove={(e) =>
|
|
38
|
+
dispatch('mousemove', { event: e, data: feature.properties.site.data, feature })}
|
|
39
|
+
on:mouseleave
|
|
40
|
+
on:click={(e) => dispatch('click', { data: feature.properties.site.data, feature })}
|
|
41
|
+
/>
|
|
42
|
+
{/each}
|
|
43
|
+
{:else}
|
|
44
|
+
{@const voronoi = Delaunay.from(points).voronoi([0, 0, boundWidth, boundHeight])}
|
|
45
|
+
{#each points as point, i}
|
|
46
|
+
<path
|
|
47
|
+
d={voronoi.renderCell(i)}
|
|
48
|
+
class={cls('fill-transparent', classes.path)}
|
|
49
|
+
on:mousemove={(e) => dispatch('mousemove', { event: e, data: point.data, point })}
|
|
50
|
+
on:mouseleave
|
|
51
|
+
on:click={(e) => dispatch('click', { data: point.data, point })}
|
|
52
|
+
/>
|
|
53
|
+
{/each}
|
|
54
|
+
{/if}
|
|
33
55
|
</g>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { GeoPermissibleObjects } from 'd3-geo';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
@@ -11,15 +12,15 @@ declare const __propDef: {
|
|
|
11
12
|
events: {
|
|
12
13
|
mouseleave: MouseEvent;
|
|
13
14
|
click: CustomEvent<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
data: any;
|
|
16
|
+
point?: [number, number] | undefined;
|
|
17
|
+
feature?: GeoPermissibleObjects | undefined;
|
|
17
18
|
}>;
|
|
18
19
|
mousemove: CustomEvent<{
|
|
19
|
-
point: {
|
|
20
|
-
data: any;
|
|
21
|
-
};
|
|
22
20
|
event: MouseEvent;
|
|
21
|
+
data: any;
|
|
22
|
+
point?: [number, number] | undefined;
|
|
23
|
+
feature?: GeoPermissibleObjects | undefined;
|
|
23
24
|
}>;
|
|
24
25
|
} & {
|
|
25
26
|
[evt: string]: CustomEvent<any>;
|
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
spring?: boolean | Parameters<typeof motionStore>[1]['spring'];
|
|
8
8
|
tweened?: boolean | Parameters<typeof motionStore>[1]['tweened'];
|
|
9
9
|
disablePointer?: boolean | undefined;
|
|
10
|
-
scroll?: "
|
|
10
|
+
scroll?: "none" | "scale" | "translate" | undefined;
|
|
11
11
|
clickDistance?: number | undefined;
|
|
12
12
|
initialTranslate?: {
|
|
13
13
|
x: number;
|
package/package.json
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "techniq/layerchart",
|
|
7
|
-
"version": "0.32.
|
|
7
|
+
"version": "0.32.2",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@changesets/cli": "^2.27.1",
|
|
10
10
|
"@mdi/js": "^7.4.47",
|
|
11
11
|
"@rollup/plugin-dsv": "^3.0.4",
|
|
12
12
|
"@sveltejs/adapter-auto": "^3.1.1",
|
|
13
|
-
"@sveltejs/kit": "^2.5.
|
|
14
|
-
"@sveltejs/package": "^2.
|
|
13
|
+
"@sveltejs/kit": "^2.5.3",
|
|
14
|
+
"@sveltejs/package": "^2.3.0",
|
|
15
15
|
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
|
16
16
|
"@tailwindcss/typography": "^0.5.10",
|
|
17
17
|
"@types/d3-array": "^3.2.1",
|
|
@@ -32,14 +32,13 @@
|
|
|
32
32
|
"@types/prismjs": "^1.26.3",
|
|
33
33
|
"@types/shapefile": "^0.6.4",
|
|
34
34
|
"@types/topojson-client": "^3.1.4",
|
|
35
|
-
"autoprefixer": "^10.4.
|
|
36
|
-
"d3-color": "^3.1.0",
|
|
35
|
+
"autoprefixer": "^10.4.18",
|
|
37
36
|
"execa": "^8.0.1",
|
|
38
|
-
"marked": "^12.0.
|
|
37
|
+
"marked": "^12.0.1",
|
|
39
38
|
"mdsvex": "^0.11.0",
|
|
40
39
|
"posthog-js": "^1.95.1",
|
|
41
40
|
"prettier": "^3.2.5",
|
|
42
|
-
"prettier-plugin-svelte": "^3.2.
|
|
41
|
+
"prettier-plugin-svelte": "^3.2.2",
|
|
43
42
|
"prism-svelte": "^0.5.0",
|
|
44
43
|
"prism-themes": "^1.9.0",
|
|
45
44
|
"prismjs": "^1.29.0",
|
|
@@ -47,17 +46,17 @@
|
|
|
47
46
|
"shapefile": "^0.6.6",
|
|
48
47
|
"solar-calculator": "^0.3.0",
|
|
49
48
|
"svelte": "^4.2.12",
|
|
50
|
-
"svelte-check": "^3.6.
|
|
49
|
+
"svelte-check": "^3.6.6",
|
|
51
50
|
"svelte-json-tree": "^2.2.0",
|
|
52
51
|
"svelte-preprocess": "^5.1.3",
|
|
53
|
-
"svelte2tsx": "^0.7.
|
|
52
|
+
"svelte2tsx": "^0.7.3",
|
|
54
53
|
"tailwindcss": "^3.4.1",
|
|
55
54
|
"topojson-client": "^3.1.0",
|
|
56
55
|
"tslib": "^2.6.2",
|
|
57
|
-
"typescript": "^5.
|
|
56
|
+
"typescript": "^5.4.2",
|
|
58
57
|
"unist-util-visit": "^5.0.0",
|
|
59
58
|
"us-atlas": "^3.0.1",
|
|
60
|
-
"vite": "^5.1.
|
|
59
|
+
"vite": "^5.1.5"
|
|
61
60
|
},
|
|
62
61
|
"type": "module",
|
|
63
62
|
"dependencies": {
|
|
@@ -67,6 +66,7 @@
|
|
|
67
66
|
"d3-delaunay": "^6.0.4",
|
|
68
67
|
"d3-dsv": "^3.0.1",
|
|
69
68
|
"d3-geo": "^3.1.0",
|
|
69
|
+
"d3-geo-voronoi": "^2.0.1",
|
|
70
70
|
"d3-hierarchy": "^3.1.2",
|
|
71
71
|
"d3-interpolate": "^3.0.1",
|
|
72
72
|
"d3-interpolate-path": "^2.3.0",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"d3-shape": "^3.2.0",
|
|
79
79
|
"d3-tile": "^1.0.0",
|
|
80
80
|
"d3-time": "^3.1.0",
|
|
81
|
-
"date-fns": "^3.
|
|
82
|
-
"layercake": "^8.0.
|
|
81
|
+
"date-fns": "^3.4.0",
|
|
82
|
+
"layercake": "^8.0.3",
|
|
83
83
|
"lodash-es": "^4.17.21",
|
|
84
|
-
"posthog-js": "^1.
|
|
84
|
+
"posthog-js": "^1.113.0",
|
|
85
85
|
"shapefile": "^0.6.6",
|
|
86
|
-
"svelte-ux": "^0.61.
|
|
86
|
+
"svelte-ux": "^0.61.5",
|
|
87
87
|
"topojson-client": "^3.1.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|