layerchart 0.13.4 → 0.14.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.
- package/{components → dist/components}/AxisX.svelte.d.ts +1 -2
- package/{components → dist/components}/AxisY.svelte.d.ts +1 -2
- package/dist/components/Blur.svelte +16 -0
- package/dist/components/Blur.svelte.d.ts +21 -0
- package/{components → dist/components}/Chart.svelte +31 -8
- package/{components → dist/components}/Chart.svelte.d.ts +6 -1
- package/{components → dist/components}/ChartClipPath.svelte.d.ts +1 -1
- package/dist/components/ClipPathUse.svelte +17 -0
- package/dist/components/ClipPathUse.svelte.d.ts +27 -0
- package/dist/components/ColorRamp.svelte +19 -0
- package/dist/components/ColorRamp.svelte.d.ts +20 -0
- package/dist/components/GeoContext.svelte +55 -0
- package/dist/components/GeoContext.svelte.d.ts +40 -0
- package/dist/components/GeoPath.svelte +56 -0
- package/dist/components/GeoPath.svelte.d.ts +36 -0
- package/dist/components/GeoPoint.svelte +28 -0
- package/dist/components/GeoPoint.svelte.d.ts +23 -0
- package/dist/components/GeoTile.svelte +47 -0
- package/dist/components/GeoTile.svelte.d.ts +24 -0
- package/dist/components/Graticule.svelte +26 -0
- package/dist/components/Graticule.svelte.d.ts +21 -0
- package/{components → dist/components}/Labels.svelte.d.ts +3 -5
- package/dist/components/Legend.svelte +163 -0
- package/dist/components/Legend.svelte.d.ts +32 -0
- package/dist/components/TileImage.svelte +84 -0
- package/dist/components/TileImage.svelte.d.ts +24 -0
- package/{components → dist/components}/Tooltip.svelte +6 -6
- package/{components → dist/components}/TooltipContext.svelte +7 -1
- package/{components → dist/components}/TooltipContext.svelte.d.ts +1 -0
- package/{components → dist/components}/TooltipItem.svelte.d.ts +1 -2
- package/{components → dist/components}/Treemap.svelte.d.ts +1 -1
- package/dist/components/Zoom.svelte +185 -0
- package/{components → dist/components}/Zoom.svelte.d.ts +36 -9
- package/{components → dist/components}/index.d.ts +9 -0
- package/{components → dist/components}/index.js +9 -0
- package/dist/docs/GeoDebug.svelte +43 -0
- package/dist/docs/GeoDebug.svelte.d.ts +16 -0
- package/{docs → dist/docs}/Header1.svelte.d.ts +2 -2
- package/{docs → dist/docs}/Layout.svelte.d.ts +3 -3
- package/{docs → dist/docs}/Link.svelte.d.ts +2 -2
- package/{docs → dist/docs}/Preview.svelte +1 -7
- package/dist/docs/RangeField.svelte +18 -0
- package/dist/docs/RangeField.svelte.d.ts +20 -0
- package/dist/docs/TilesetField.svelte +93 -0
- package/dist/docs/TilesetField.svelte.d.ts +17 -0
- package/dist/docs/ZoomControls.svelte +50 -0
- package/dist/docs/ZoomControls.svelte.d.ts +19 -0
- package/{utils → dist/utils}/event.js +1 -1
- package/{utils → dist/utils}/ticks.d.ts +3 -3
- package/package.json +88 -123
- package/components/Legend.svelte +0 -17
- package/components/Legend.svelte.d.ts +0 -23
- package/components/Zoom.svelte +0 -133
- /package/{components → dist/components}/Arc.svelte +0 -0
- /package/{components → dist/components}/Arc.svelte.d.ts +0 -0
- /package/{components → dist/components}/Area.svelte +0 -0
- /package/{components → dist/components}/Area.svelte.d.ts +0 -0
- /package/{components → dist/components}/AreaStack.svelte +0 -0
- /package/{components → dist/components}/AreaStack.svelte.d.ts +0 -0
- /package/{components → dist/components}/AxisX.svelte +0 -0
- /package/{components → dist/components}/AxisY.svelte +0 -0
- /package/{components → dist/components}/Bars.svelte +0 -0
- /package/{components → dist/components}/Bars.svelte.d.ts +0 -0
- /package/{components → dist/components}/Baseline.svelte +0 -0
- /package/{components → dist/components}/Baseline.svelte.d.ts +0 -0
- /package/{components → dist/components}/Bounds.svelte +0 -0
- /package/{components → dist/components}/Bounds.svelte.d.ts +0 -0
- /package/{components → dist/components}/ChartClipPath.svelte +0 -0
- /package/{components → dist/components}/Circle.svelte +0 -0
- /package/{components → dist/components}/Circle.svelte.d.ts +0 -0
- /package/{components → dist/components}/CircleClipPath.svelte +0 -0
- /package/{components → dist/components}/CircleClipPath.svelte.d.ts +0 -0
- /package/{components → dist/components}/ClipPath.svelte +0 -0
- /package/{components → dist/components}/ClipPath.svelte.d.ts +0 -0
- /package/{components → dist/components}/ConnectedPoints.svelte +0 -0
- /package/{components → dist/components}/ConnectedPoints.svelte.d.ts +0 -0
- /package/{components → dist/components}/Group.svelte +0 -0
- /package/{components → dist/components}/Group.svelte.d.ts +0 -0
- /package/{components → dist/components}/HighlightLine.svelte +0 -0
- /package/{components → dist/components}/HighlightLine.svelte.d.ts +0 -0
- /package/{components → dist/components}/HighlightRect.svelte +0 -0
- /package/{components → dist/components}/HighlightRect.svelte.d.ts +0 -0
- /package/{components → dist/components}/Labels.svelte +0 -0
- /package/{components → dist/components}/Line.svelte +0 -0
- /package/{components → dist/components}/Line.svelte.d.ts +0 -0
- /package/{components → dist/components}/LinearGradient.svelte +0 -0
- /package/{components → dist/components}/LinearGradient.svelte.d.ts +0 -0
- /package/{components → dist/components}/Link.svelte +0 -0
- /package/{components → dist/components}/Link.svelte.d.ts +0 -0
- /package/{components → dist/components}/Pack.svelte +0 -0
- /package/{components → dist/components}/Pack.svelte.d.ts +0 -0
- /package/{components → dist/components}/Partition.svelte +0 -0
- /package/{components → dist/components}/Partition.svelte.d.ts +0 -0
- /package/{components → dist/components}/Path.svelte +0 -0
- /package/{components → dist/components}/Path.svelte.d.ts +0 -0
- /package/{components → dist/components}/Pattern.svelte +0 -0
- /package/{components → dist/components}/Pattern.svelte.d.ts +0 -0
- /package/{components → dist/components}/Pie.svelte +0 -0
- /package/{components → dist/components}/Pie.svelte.d.ts +0 -0
- /package/{components → dist/components}/Points.svelte +0 -0
- /package/{components → dist/components}/Points.svelte.d.ts +0 -0
- /package/{components → dist/components}/Rect.svelte +0 -0
- /package/{components → dist/components}/RectClipPath.svelte +0 -0
- /package/{components → dist/components}/RectClipPath.svelte.d.ts +0 -0
- /package/{components → dist/components}/Sankey.svelte +0 -0
- /package/{components → dist/components}/Sankey.svelte.d.ts +0 -0
- /package/{components → dist/components}/Text.svelte +0 -0
- /package/{components → dist/components}/Text.svelte.d.ts +0 -0
- /package/{components → dist/components}/Threshold.svelte +0 -0
- /package/{components → dist/components}/Threshold.svelte.d.ts +0 -0
- /package/{components → dist/components}/Tooltip.svelte.d.ts +0 -0
- /package/{components → dist/components}/TooltipItem.svelte +0 -0
- /package/{components → dist/components}/TooltipSeparator.svelte +0 -0
- /package/{components → dist/components}/TooltipSeparator.svelte.d.ts +0 -0
- /package/{components → dist/components}/Tree.svelte +0 -0
- /package/{components → dist/components}/Tree.svelte.d.ts +0 -0
- /package/{components → dist/components}/Treemap.svelte +0 -0
- /package/{docs → dist/docs}/Blockquote.svelte +0 -0
- /package/{docs → dist/docs}/Blockquote.svelte.d.ts +0 -0
- /package/{docs → dist/docs}/Code.svelte +0 -0
- /package/{docs → dist/docs}/Code.svelte.d.ts +0 -0
- /package/{docs → dist/docs}/Header1.svelte +0 -0
- /package/{docs → dist/docs}/Layout.svelte +0 -0
- /package/{docs → dist/docs}/Link.svelte +0 -0
- /package/{docs → dist/docs}/Preview.svelte.d.ts +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{stores → dist/stores}/motionStore.d.ts +0 -0
- /package/{stores → dist/stores}/motionStore.js +0 -0
- /package/{utils → dist/utils}/event.d.ts +0 -0
- /package/{utils → dist/utils}/genData.d.ts +0 -0
- /package/{utils → dist/utils}/genData.js +0 -0
- /package/{utils → dist/utils}/graph.d.ts +0 -0
- /package/{utils → dist/utils}/graph.js +0 -0
- /package/{utils → dist/utils}/hierarchy.d.ts +0 -0
- /package/{utils → dist/utils}/hierarchy.js +0 -0
- /package/{utils → dist/utils}/index.d.ts +0 -0
- /package/{utils → dist/utils}/index.js +0 -0
- /package/{utils → dist/utils}/math.d.ts +0 -0
- /package/{utils → dist/utils}/math.js +0 -0
- /package/{utils → dist/utils}/path.d.ts +0 -0
- /package/{utils → dist/utils}/path.js +0 -0
- /package/{utils → dist/utils}/pivot.d.ts +0 -0
- /package/{utils → dist/utils}/pivot.js +0 -0
- /package/{utils → dist/utils}/quadtree.d.ts +0 -0
- /package/{utils → dist/utils}/quadtree.js +0 -0
- /package/{utils → dist/utils}/scales.d.ts +0 -0
- /package/{utils → dist/utils}/scales.js +0 -0
- /package/{utils → dist/utils}/stack.d.ts +0 -0
- /package/{utils → dist/utils}/stack.js +0 -0
- /package/{utils → dist/utils}/string.d.ts +0 -0
- /package/{utils → dist/utils}/string.js +0 -0
- /package/{utils → dist/utils}/ticks.js +0 -0
- /package/{utils → dist/utils}/treemap.d.ts +0 -0
- /package/{utils → dist/utils}/treemap.js +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { FormatType } from 'svelte-ux/utils/format';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
gridlines?: boolean | svelte.JSX.SVGProps<SVGLineElement>;
|
|
6
|
-
formatTick?:
|
|
5
|
+
formatTick?: any;
|
|
7
6
|
ticks?: undefined;
|
|
8
7
|
xTick?: undefined;
|
|
9
8
|
yTick?: number | undefined;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { FormatType } from 'svelte-ux/utils/format';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
gridlines?: boolean | svelte.JSX.SVGProps<SVGLineElement>;
|
|
6
5
|
ticks?: number | Function | undefined;
|
|
7
|
-
formatTick?:
|
|
6
|
+
formatTick?: any;
|
|
8
7
|
xTick?: number | undefined;
|
|
9
8
|
yTick?: number | undefined;
|
|
10
9
|
dxTick?: number | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script>import { uniqueId } from 'svelte-ux/utils/string';
|
|
2
|
+
export let id = uniqueId('blur-');
|
|
3
|
+
export let stdDeviation = 5;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<defs>
|
|
7
|
+
<filter {id}>
|
|
8
|
+
<feGaussianBlur in="SourceGraphic" {stdDeviation} />
|
|
9
|
+
</filter>
|
|
10
|
+
</defs>
|
|
11
|
+
|
|
12
|
+
{#if $$slots.default}
|
|
13
|
+
<g filter="url(#{id})">
|
|
14
|
+
<slot {id} />
|
|
15
|
+
</g>
|
|
16
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
stdDeviation?: number | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type BlurProps = typeof __propDef.props;
|
|
17
|
+
export type BlurEvents = typeof __propDef.events;
|
|
18
|
+
export type BlurSlots = typeof __propDef.slots;
|
|
19
|
+
export default class Blur extends SvelteComponentTyped<BlurProps, BlurEvents, BlurSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
// export { Svg, Html };
|
|
3
3
|
// TODO: Workaround for sveld error: `Cannot read properties of null (reading 'type')` in `ComponentParser`
|
|
4
4
|
// See: https://github.com/carbon-design-system/sveld/issues/104
|
|
5
|
-
import { LayerCake, Svg as _Svg, Html as _Html } from 'layercake';
|
|
5
|
+
import { LayerCake, Svg as _Svg, Html as _Html, Canvas as _Canvas, WebGL as _WebGL } from 'layercake';
|
|
6
6
|
export const Svg = _Svg;
|
|
7
7
|
export const Html = _Html;
|
|
8
|
+
export const Canvas = _Canvas;
|
|
9
|
+
export const WebGL = _WebGL;
|
|
8
10
|
</script>
|
|
9
11
|
|
|
10
12
|
<script>import { max, min } from 'd3-array';
|
|
11
13
|
import { get } from 'lodash-es';
|
|
12
14
|
import { isScaleBand } from '../utils/scales';
|
|
13
15
|
import TooltipContext from './TooltipContext.svelte';
|
|
16
|
+
import GeoContext from './GeoContext.svelte';
|
|
14
17
|
/**
|
|
15
18
|
* Resolve a value from data based on the accessor type
|
|
16
19
|
*/
|
|
@@ -57,6 +60,7 @@ $: if (yBaseline != null) {
|
|
|
57
60
|
*/
|
|
58
61
|
$: yReverse = yScale ? !isScaleBand(yScale) : true;
|
|
59
62
|
export let tooltip = undefined;
|
|
63
|
+
export let geo = undefined;
|
|
60
64
|
</script>
|
|
61
65
|
|
|
62
66
|
<LayerCake
|
|
@@ -75,11 +79,30 @@ export let tooltip = undefined;
|
|
|
75
79
|
let:width
|
|
76
80
|
let:element
|
|
77
81
|
>
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
<GeoContext {...geo} let:projection>
|
|
83
|
+
{#if tooltip}
|
|
84
|
+
<TooltipContext {...tooltip} let:tooltip>
|
|
85
|
+
<slot
|
|
86
|
+
{aspectRatio}
|
|
87
|
+
{containerHeight}
|
|
88
|
+
{containerWidth}
|
|
89
|
+
{height}
|
|
90
|
+
{width}
|
|
91
|
+
{element}
|
|
92
|
+
{projection}
|
|
93
|
+
{tooltip}
|
|
94
|
+
/>
|
|
95
|
+
</TooltipContext>
|
|
96
|
+
{:else}
|
|
97
|
+
<slot
|
|
98
|
+
{aspectRatio}
|
|
99
|
+
{containerHeight}
|
|
100
|
+
{containerWidth}
|
|
101
|
+
{height}
|
|
102
|
+
{width}
|
|
103
|
+
{element}
|
|
104
|
+
{projection}
|
|
105
|
+
/>
|
|
106
|
+
{/if}
|
|
107
|
+
</GeoContext>
|
|
85
108
|
</LayerCake>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { Svg as _Svg, Html as _Html } from 'layercake';
|
|
2
|
+
import { Svg as _Svg, Html as _Html, Canvas as _Canvas, WebGL as _WebGL } from 'layercake';
|
|
3
3
|
export declare const Svg: typeof _Svg;
|
|
4
4
|
export declare const Html: typeof _Html;
|
|
5
|
+
export declare const Canvas: typeof _Canvas;
|
|
6
|
+
export declare const WebGL: typeof _WebGL;
|
|
5
7
|
import type { ComponentProps } from 'svelte';
|
|
6
8
|
import TooltipContext from './TooltipContext.svelte';
|
|
9
|
+
import GeoContext from './GeoContext.svelte';
|
|
7
10
|
declare const __propDef: {
|
|
8
11
|
props: {
|
|
9
12
|
[x: string]: any;
|
|
@@ -14,6 +17,7 @@ declare const __propDef: {
|
|
|
14
17
|
xBaseline?: number | null | undefined;
|
|
15
18
|
yBaseline?: number | null | undefined;
|
|
16
19
|
tooltip?: ComponentProps<TooltipContext> | undefined;
|
|
20
|
+
geo?: ComponentProps<GeoContext> | undefined;
|
|
17
21
|
};
|
|
18
22
|
events: {
|
|
19
23
|
[evt: string]: CustomEvent<any>;
|
|
@@ -26,6 +30,7 @@ declare const __propDef: {
|
|
|
26
30
|
height: number;
|
|
27
31
|
width: number;
|
|
28
32
|
element: Element;
|
|
33
|
+
projection: import("d3-geo").GeoProjection | import("d3-geo").GeoIdentityTransform;
|
|
29
34
|
};
|
|
30
35
|
};
|
|
31
36
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>import { uniqueId } from 'svelte-ux/utils/string';
|
|
2
|
+
import ClipPath from './ClipPath.svelte';
|
|
3
|
+
/** Id of path or shape */
|
|
4
|
+
export let refId;
|
|
5
|
+
/** Unique id for clipPath */
|
|
6
|
+
export let clipPathId = uniqueId('clipPath-');
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<ClipPath id={clipPathId}>
|
|
10
|
+
<use href="#{refId}" />
|
|
11
|
+
</ClipPath>
|
|
12
|
+
|
|
13
|
+
{#if $$slots.default}
|
|
14
|
+
<g style="clip-path: url(#{clipPathId})" on:click on:mousemove on:mouseleave on:keydown>
|
|
15
|
+
<slot {refId} {clipPathId} />
|
|
16
|
+
</g>
|
|
17
|
+
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/** Id of path or shape */ refId: string;
|
|
5
|
+
/** Unique id for clipPath */ clipPathId?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
click: MouseEvent;
|
|
9
|
+
mousemove: MouseEvent;
|
|
10
|
+
mouseleave: MouseEvent;
|
|
11
|
+
keydown: KeyboardEvent;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
default: {
|
|
17
|
+
refId: string;
|
|
18
|
+
clipPathId: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type ClipPathUseProps = typeof __propDef.props;
|
|
23
|
+
export type ClipPathUseEvents = typeof __propDef.events;
|
|
24
|
+
export type ClipPathUseSlots = typeof __propDef.slots;
|
|
25
|
+
export default class ClipPathUse extends SvelteComponentTyped<ClipPathUseProps, ClipPathUseEvents, ClipPathUseSlots> {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>export let interpolator;
|
|
2
|
+
export let steps = 10;
|
|
3
|
+
export let height = '20px';
|
|
4
|
+
export let width = '100%';
|
|
5
|
+
let href = '';
|
|
6
|
+
$: {
|
|
7
|
+
const canvas = document.createElement('canvas');
|
|
8
|
+
canvas.width = steps;
|
|
9
|
+
canvas.height = 1;
|
|
10
|
+
const context = canvas.getContext('2d');
|
|
11
|
+
for (let i = 0; i < steps; ++i) {
|
|
12
|
+
context.fillStyle = interpolator(i / (steps - 1));
|
|
13
|
+
context.fillRect(i, 0, 1, 1);
|
|
14
|
+
}
|
|
15
|
+
href = canvas.toDataURL();
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<image {href} preserveAspectRatio="none" style:height style:width {...$$restProps} />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
interpolator: (t: number) => string;
|
|
6
|
+
steps?: number | undefined;
|
|
7
|
+
height?: string | number | undefined;
|
|
8
|
+
width?: string | number | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {};
|
|
14
|
+
};
|
|
15
|
+
export type ColorRampProps = typeof __propDef.props;
|
|
16
|
+
export type ColorRampEvents = typeof __propDef.events;
|
|
17
|
+
export type ColorRampSlots = typeof __propDef.slots;
|
|
18
|
+
export default class ColorRamp extends SvelteComponentTyped<ColorRampProps, ColorRampEvents, ColorRampSlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script context="module">import { getContext, setContext } from 'svelte';
|
|
2
|
+
import { writable } from 'svelte/store';
|
|
3
|
+
import { geoMercator } from 'd3-geo';
|
|
4
|
+
export const geoContextKey = {};
|
|
5
|
+
export function geoContext() {
|
|
6
|
+
return getContext(geoContextKey);
|
|
7
|
+
}
|
|
8
|
+
function setGeoContext(geo) {
|
|
9
|
+
setContext(geoContextKey, geo);
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script>const { width, height } = getContext('LayerCake');
|
|
14
|
+
/** @type {Function} projection - A d3 projection function. Pass this in as an uncalled function, e.g. `projection={geoAlbersUsa}`. */
|
|
15
|
+
export let projection = geoMercator;
|
|
16
|
+
export let fitGeojson;
|
|
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
|
+
export let fixedAspectRatio = undefined;
|
|
19
|
+
export let clipAngle = undefined;
|
|
20
|
+
export let clipExtent = undefined;
|
|
21
|
+
export let rotate = undefined;
|
|
22
|
+
export let scale = undefined;
|
|
23
|
+
export let translate = undefined;
|
|
24
|
+
export let center = undefined;
|
|
25
|
+
const geo = writable(projection());
|
|
26
|
+
setGeoContext(geo);
|
|
27
|
+
$: fitSizeRange = (fixedAspectRatio ? [100, 100 / fixedAspectRatio] : [$width, $height]);
|
|
28
|
+
$: {
|
|
29
|
+
const _projection = projection();
|
|
30
|
+
if (fitGeojson && 'fitSize' in _projection) {
|
|
31
|
+
_projection.fitSize(fitSizeRange, fitGeojson);
|
|
32
|
+
}
|
|
33
|
+
if (scale && 'scale' in _projection) {
|
|
34
|
+
_projection.scale(scale);
|
|
35
|
+
}
|
|
36
|
+
if (rotate && 'rotate' in _projection) {
|
|
37
|
+
_projection.rotate([rotate.yaw, rotate.pitch, rotate.roll]);
|
|
38
|
+
}
|
|
39
|
+
if (translate && 'translate' in _projection) {
|
|
40
|
+
_projection.translate(translate);
|
|
41
|
+
}
|
|
42
|
+
if (center && 'center' in _projection) {
|
|
43
|
+
_projection.center(center);
|
|
44
|
+
}
|
|
45
|
+
if (clipAngle && 'clipAngle' in _projection) {
|
|
46
|
+
_projection.clipAngle(clipAngle);
|
|
47
|
+
}
|
|
48
|
+
if (clipExtent && 'clipExtent' in _projection) {
|
|
49
|
+
_projection.clipExtent(clipExtent);
|
|
50
|
+
}
|
|
51
|
+
geo.set(_projection);
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<slot projection={$geo} />
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type Writable } from 'svelte/store';
|
|
3
|
+
import { type GeoIdentityTransform, type GeoPermissibleObjects, type GeoProjection } from 'd3-geo';
|
|
4
|
+
export declare const geoContextKey: {};
|
|
5
|
+
export type GeoContext = Writable<GeoProjection | GeoIdentityTransform>;
|
|
6
|
+
export declare function geoContext(): GeoContext;
|
|
7
|
+
declare const __propDef: {
|
|
8
|
+
props: {
|
|
9
|
+
/** @type {Function} projection - A d3 projection function. Pass this in as an uncalled function, e.g. `projection={geoAlbersUsa}`. */ projection?: (() => GeoProjection | GeoIdentityTransform) | undefined;
|
|
10
|
+
fitGeojson: GeoPermissibleObjects;
|
|
11
|
+
/** 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. */ fixedAspectRatio?: number | undefined;
|
|
12
|
+
clipAngle?: number | undefined;
|
|
13
|
+
clipExtent?: [[number, number], [number, number]] | undefined;
|
|
14
|
+
rotate?: {
|
|
15
|
+
/** Lambda (Center Meridian) */
|
|
16
|
+
yaw: number;
|
|
17
|
+
/** Phi */
|
|
18
|
+
pitch: number;
|
|
19
|
+
/** Gamma */
|
|
20
|
+
roll: number;
|
|
21
|
+
} | undefined;
|
|
22
|
+
scale?: number | undefined;
|
|
23
|
+
translate?: [number, number] | undefined;
|
|
24
|
+
center?: [number, number] | undefined;
|
|
25
|
+
};
|
|
26
|
+
events: {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {
|
|
30
|
+
default: {
|
|
31
|
+
projection: GeoProjection | GeoIdentityTransform;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type GeoContextProps = typeof __propDef.props;
|
|
36
|
+
export type GeoContextEvents = typeof __propDef.events;
|
|
37
|
+
export type GeoContextSlots = typeof __propDef.slots;
|
|
38
|
+
export default class GeoContext extends SvelteComponentTyped<GeoContextProps, GeoContextEvents, GeoContextSlots> {
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, getContext } from 'svelte';
|
|
2
|
+
import { geoPath as d3geoPath } from 'd3-geo';
|
|
3
|
+
import { geoContext } from './GeoContext.svelte';
|
|
4
|
+
import { scaleCanvas } from 'layercake';
|
|
5
|
+
export let geojson;
|
|
6
|
+
export let fill = undefined;
|
|
7
|
+
export let fillScale = undefined;
|
|
8
|
+
export let stroke = undefined;
|
|
9
|
+
export let strokeWidth = undefined;
|
|
10
|
+
/** Render to canvas */
|
|
11
|
+
export let render = undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Tooltip context to setup mouse events to show tooltip for related data
|
|
14
|
+
*/
|
|
15
|
+
export let tooltip = undefined;
|
|
16
|
+
const dispatch = createEventDispatcher();
|
|
17
|
+
const { rGet, width, height } = getContext('LayerCake');
|
|
18
|
+
const canvas = getContext('canvas');
|
|
19
|
+
const geo = geoContext();
|
|
20
|
+
$: geoPath = d3geoPath($geo);
|
|
21
|
+
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
22
|
+
$: ctx = canvas?.ctx;
|
|
23
|
+
$: if (renderContext === 'canvas' && $ctx) {
|
|
24
|
+
// console.count('render');
|
|
25
|
+
scaleCanvas($ctx, $width, $height);
|
|
26
|
+
$ctx.clearRect(0, 0, $width, $height);
|
|
27
|
+
if (render) {
|
|
28
|
+
render($ctx, { geoPath });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
$ctx.beginPath();
|
|
32
|
+
// Set the context here since setting it in `$: geoPath` is a circular reference
|
|
33
|
+
geoPath.context($ctx);
|
|
34
|
+
geoPath(geojson);
|
|
35
|
+
$ctx.fillStyle = fill || (fillScale && $rGet(fillScale)) || 'transparent';
|
|
36
|
+
$ctx.fill();
|
|
37
|
+
$ctx.lineWidth = strokeWidth;
|
|
38
|
+
$ctx.strokeStyle = stroke;
|
|
39
|
+
$ctx.stroke();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
{#if renderContext === 'svg'}
|
|
45
|
+
<slot {geoPath}>
|
|
46
|
+
<path
|
|
47
|
+
d={geoPath(geojson)}
|
|
48
|
+
fill={fill || (fillScale && $rGet(fillScale)) || 'transparent'}
|
|
49
|
+
stroke={stroke || 'black'}
|
|
50
|
+
on:mousemove={(e) => tooltip?.show(e, geojson)}
|
|
51
|
+
on:mouseleave={(e) => tooltip?.hide()}
|
|
52
|
+
on:click={(event) => dispatch('click', { geoPath, event })}
|
|
53
|
+
{...$$restProps}
|
|
54
|
+
/>
|
|
55
|
+
</slot>
|
|
56
|
+
{/if}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type GeoPath, type GeoPermissibleObjects } from 'd3-geo';
|
|
3
|
+
import type { TooltipContextValue } from './TooltipContext.svelte';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
geojson: GeoPermissibleObjects;
|
|
8
|
+
fill?: string | undefined;
|
|
9
|
+
fillScale?: Object | undefined;
|
|
10
|
+
stroke?: string | undefined;
|
|
11
|
+
strokeWidth?: number | string | undefined;
|
|
12
|
+
render?: ((ctx: CanvasRenderingContext2D, { geoPath: GeoPath }: {
|
|
13
|
+
geoPath: any;
|
|
14
|
+
}) => any) | undefined;
|
|
15
|
+
tooltip?: TooltipContextValue | undefined;
|
|
16
|
+
};
|
|
17
|
+
events: {
|
|
18
|
+
click: CustomEvent<{
|
|
19
|
+
geoPath: GeoPath;
|
|
20
|
+
event: MouseEvent;
|
|
21
|
+
}>;
|
|
22
|
+
} & {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {
|
|
26
|
+
default: {
|
|
27
|
+
geoPath: GeoPath<any, GeoPermissibleObjects>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type GeoPathProps = typeof __propDef.props;
|
|
32
|
+
export type GeoPathEvents = typeof __propDef.events;
|
|
33
|
+
export type GeoPathSlots = typeof __propDef.slots;
|
|
34
|
+
export default class GeoPath extends SvelteComponentTyped<GeoPathProps, GeoPathEvents, GeoPathSlots> {
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script>import { getContext } from 'svelte';
|
|
2
|
+
import { scaleCanvas } from 'layercake';
|
|
3
|
+
import { geoContext } from './GeoContext.svelte';
|
|
4
|
+
/** Latitude */
|
|
5
|
+
export let lat;
|
|
6
|
+
/** Longitude */
|
|
7
|
+
export let long;
|
|
8
|
+
/** Render to canvas */
|
|
9
|
+
export let render = () => { };
|
|
10
|
+
const { width, height } = getContext('LayerCake');
|
|
11
|
+
const canvas = getContext('canvas');
|
|
12
|
+
const geo = geoContext();
|
|
13
|
+
$: [x, y] = $geo([long, lat]) ?? [0, 0];
|
|
14
|
+
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
15
|
+
$: ctx = canvas?.ctx;
|
|
16
|
+
$: if (renderContext === 'canvas' && $ctx) {
|
|
17
|
+
// console.count('render');
|
|
18
|
+
scaleCanvas($ctx, $width, $height);
|
|
19
|
+
$ctx.clearRect(0, 0, $width, $height);
|
|
20
|
+
render($ctx, { x, y });
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if renderContext === 'svg'}
|
|
25
|
+
<g transform="translate({x},{y})">
|
|
26
|
+
<slot />
|
|
27
|
+
</g>
|
|
28
|
+
{/if}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/** Latitude */ lat: number;
|
|
5
|
+
/** Longitude */ long: number;
|
|
6
|
+
/** Render to canvas */ render?: ((ctx: CanvasRenderingContext2D, coords: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}) => any) | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {
|
|
15
|
+
default: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type GeoPointProps = typeof __propDef.props;
|
|
19
|
+
export type GeoPointEvents = typeof __propDef.events;
|
|
20
|
+
export type GeoPointSlots = typeof __propDef.slots;
|
|
21
|
+
export default class GeoPoint extends SvelteComponentTyped<GeoPointProps, GeoPointEvents, GeoPointSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>import { getContext } from 'svelte';
|
|
2
|
+
import { scaleCanvas } from 'layercake';
|
|
3
|
+
import { tile as d3Tile } from 'd3-tile';
|
|
4
|
+
import { geoContext } from './GeoContext.svelte';
|
|
5
|
+
import TileImage from './TileImage.svelte';
|
|
6
|
+
export let url;
|
|
7
|
+
export let zoomDelta = 0;
|
|
8
|
+
export let tileSize = 256;
|
|
9
|
+
export let disableCache = false;
|
|
10
|
+
export let debug = false;
|
|
11
|
+
const { width, height } = getContext('LayerCake');
|
|
12
|
+
const canvas = getContext('canvas');
|
|
13
|
+
const geo = geoContext();
|
|
14
|
+
$: tile = d3Tile()
|
|
15
|
+
.size([$width, $height])
|
|
16
|
+
.scale($geo.scale() * 2 * Math.PI)
|
|
17
|
+
.translate($geo([0, 0]))
|
|
18
|
+
.tileSize(tileSize)
|
|
19
|
+
.zoomDelta(zoomDelta);
|
|
20
|
+
$: tiles = tile();
|
|
21
|
+
$: ({
|
|
22
|
+
translate: [tx, ty],
|
|
23
|
+
scale: k
|
|
24
|
+
} = tiles);
|
|
25
|
+
$: renderContext = canvas ? 'canvas' : 'svg';
|
|
26
|
+
$: ctx = canvas?.ctx;
|
|
27
|
+
$: if (renderContext === 'canvas' && $ctx && url) {
|
|
28
|
+
// console.count('render');
|
|
29
|
+
scaleCanvas($ctx, $width, $height);
|
|
30
|
+
$ctx.clearRect(0, 0, $width, $height);
|
|
31
|
+
tiles.forEach(([x, y, z]) => {
|
|
32
|
+
const image = new Image();
|
|
33
|
+
image.onload = () => {
|
|
34
|
+
$ctx.drawImage(image, (x + tx) * k, (y + ty) * k, k, k);
|
|
35
|
+
};
|
|
36
|
+
image.src = url(x, y, z);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
{#if renderContext === 'svg' && url}
|
|
42
|
+
<slot {tiles}>
|
|
43
|
+
{#each tiles as [x, y, z] (url(x, y, z))}
|
|
44
|
+
<TileImage {url} {x} {y} {z} {tx} {ty} {k} {disableCache} {debug} />
|
|
45
|
+
{/each}
|
|
46
|
+
</slot>
|
|
47
|
+
{/if}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
url: (x: number, y: number, z: number) => string;
|
|
5
|
+
zoomDelta?: number | undefined;
|
|
6
|
+
tileSize?: number | undefined;
|
|
7
|
+
disableCache?: boolean | undefined;
|
|
8
|
+
debug?: boolean | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {
|
|
15
|
+
tiles: any;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type GeoTileProps = typeof __propDef.props;
|
|
20
|
+
export type GeoTileEvents = typeof __propDef.events;
|
|
21
|
+
export type GeoTileSlots = typeof __propDef.slots;
|
|
22
|
+
export default class GeoTile extends SvelteComponentTyped<GeoTileProps, GeoTileEvents, GeoTileSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>import { geoGraticule } from 'd3-geo';
|
|
2
|
+
import GeoPath from './GeoPath.svelte';
|
|
3
|
+
// TODO: Support full api (stepMinor/Major, extent[Minor/Major], etc
|
|
4
|
+
export let lines = undefined;
|
|
5
|
+
export let outline = undefined;
|
|
6
|
+
export let step = [10, 10];
|
|
7
|
+
$: graticule = geoGraticule();
|
|
8
|
+
$: graticule.step(step);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<g class="graticule">
|
|
12
|
+
<!-- TODO: Any reason to still render the single `MultiLineString` path if using `lines` and/or `outline` -->
|
|
13
|
+
{#if !lines && !outline}
|
|
14
|
+
<GeoPath geojson={graticule()} {...$$restProps} />
|
|
15
|
+
{/if}
|
|
16
|
+
|
|
17
|
+
{#if lines}
|
|
18
|
+
{#each graticule.lines() as line}
|
|
19
|
+
<GeoPath geojson={line} {...lines} />
|
|
20
|
+
{/each}
|
|
21
|
+
{/if}
|
|
22
|
+
|
|
23
|
+
{#if outline}
|
|
24
|
+
<GeoPath geojson={graticule.outline()} {...outline} />
|
|
25
|
+
{/if}
|
|
26
|
+
</g>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import GeoPath from './GeoPath.svelte';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
lines?: Omit<ComponentProps<GeoPath>, 'geojson'> | boolean | undefined;
|
|
8
|
+
outline?: Omit<ComponentProps<GeoPath>, 'geojson'> | boolean | undefined;
|
|
9
|
+
step?: [number, number] | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
};
|
|
16
|
+
export type GraticuleProps = typeof __propDef.props;
|
|
17
|
+
export type GraticuleEvents = typeof __propDef.events;
|
|
18
|
+
export type GraticuleSlots = typeof __propDef.slots;
|
|
19
|
+
export default class Graticule extends SvelteComponentTyped<GraticuleProps, GraticuleEvents, GraticuleSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { type FormatNumberStyle } from 'svelte-ux/utils/number';
|
|
3
|
-
import { type FormatType } from 'svelte-ux/utils/format';
|
|
4
2
|
declare const __propDef: {
|
|
5
3
|
props: {
|
|
6
4
|
[x: string]: any;
|
|
7
|
-
orientation?: "
|
|
5
|
+
orientation?: "auto" | "outside" | "inside" | undefined;
|
|
8
6
|
significantDigits?: number | undefined;
|
|
9
|
-
format?:
|
|
10
|
-
formatStyle?:
|
|
7
|
+
format?: any;
|
|
8
|
+
formatStyle?: any;
|
|
11
9
|
overlap?: boolean | undefined;
|
|
12
10
|
groupBy?: string | undefined;
|
|
13
11
|
};
|