layerchart 0.13.3 → 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 +9 -11
- 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
package/package.json
CHANGED
|
@@ -1,124 +1,89 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"./components/Text.svelte": "./components/Text.svelte",
|
|
91
|
-
"./components/Threshold.svelte": "./components/Threshold.svelte",
|
|
92
|
-
"./components/Tooltip.svelte": "./components/Tooltip.svelte",
|
|
93
|
-
"./components/TooltipContext.svelte": "./components/TooltipContext.svelte",
|
|
94
|
-
"./components/TooltipItem.svelte": "./components/TooltipItem.svelte",
|
|
95
|
-
"./components/TooltipSeparator.svelte": "./components/TooltipSeparator.svelte",
|
|
96
|
-
"./components/Tree.svelte": "./components/Tree.svelte",
|
|
97
|
-
"./components/Treemap.svelte": "./components/Treemap.svelte",
|
|
98
|
-
"./components/Zoom.svelte": "./components/Zoom.svelte",
|
|
99
|
-
"./components": "./components/index.js",
|
|
100
|
-
"./docs/Blockquote.svelte": "./docs/Blockquote.svelte",
|
|
101
|
-
"./docs/Code.svelte": "./docs/Code.svelte",
|
|
102
|
-
"./docs/Header1.svelte": "./docs/Header1.svelte",
|
|
103
|
-
"./docs/Layout.svelte": "./docs/Layout.svelte",
|
|
104
|
-
"./docs/Link.svelte": "./docs/Link.svelte",
|
|
105
|
-
"./docs/Preview.svelte": "./docs/Preview.svelte",
|
|
106
|
-
".": "./index.js",
|
|
107
|
-
"./stores/motionStore": "./stores/motionStore.js",
|
|
108
|
-
"./utils/event": "./utils/event.js",
|
|
109
|
-
"./utils/genData": "./utils/genData.js",
|
|
110
|
-
"./utils/graph": "./utils/graph.js",
|
|
111
|
-
"./utils/hierarchy": "./utils/hierarchy.js",
|
|
112
|
-
"./utils": "./utils/index.js",
|
|
113
|
-
"./utils/math": "./utils/math.js",
|
|
114
|
-
"./utils/path": "./utils/path.js",
|
|
115
|
-
"./utils/pivot": "./utils/pivot.js",
|
|
116
|
-
"./utils/quadtree": "./utils/quadtree.js",
|
|
117
|
-
"./utils/scales": "./utils/scales.js",
|
|
118
|
-
"./utils/stack": "./utils/stack.js",
|
|
119
|
-
"./utils/string": "./utils/string.js",
|
|
120
|
-
"./utils/ticks": "./utils/ticks.js",
|
|
121
|
-
"./utils/treemap": "./utils/treemap.js"
|
|
122
|
-
},
|
|
123
|
-
"svelte": "./index.js"
|
|
124
|
-
}
|
|
2
|
+
"name": "layerchart",
|
|
3
|
+
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": "techniq/layerchart",
|
|
6
|
+
"version": "0.14.0",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite dev",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"package": "svelte-package",
|
|
12
|
+
"prepublishOnly": "svelte-package",
|
|
13
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
14
|
+
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
|
15
|
+
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
|
|
16
|
+
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@rollup/plugin-dsv": "^3.0.2",
|
|
20
|
+
"@sveltejs/adapter-vercel": "^2.4.0",
|
|
21
|
+
"@sveltejs/kit": "^1.13.0",
|
|
22
|
+
"@sveltejs/package": "^2.0.2",
|
|
23
|
+
"@tailwindcss/typography": "^0.5.9",
|
|
24
|
+
"@types/d3-array": "^3.0.4",
|
|
25
|
+
"@types/d3-delaunay": "^6.0.1",
|
|
26
|
+
"@types/d3-dsv": "^3.0.1",
|
|
27
|
+
"@types/d3-geo": "^3.0.3",
|
|
28
|
+
"@types/d3-hierarchy": "^3.1.2",
|
|
29
|
+
"@types/d3-interpolate": "^3.0.1",
|
|
30
|
+
"@types/d3-quadtree": "^3.0.2",
|
|
31
|
+
"@types/d3-random": "^3.0.1",
|
|
32
|
+
"@types/d3-sankey": "^0.12.1",
|
|
33
|
+
"@types/d3-scale": "^4.0.3",
|
|
34
|
+
"@types/d3-shape": "^3.1.1",
|
|
35
|
+
"@types/lodash-es": "^4.17.7",
|
|
36
|
+
"@types/topojson-client": "^3.1.1",
|
|
37
|
+
"autoprefixer": "^10.4.14",
|
|
38
|
+
"mdsvex": "^0.10.6",
|
|
39
|
+
"prettier": "^2.8.6",
|
|
40
|
+
"prettier-plugin-svelte": "^2.9.0",
|
|
41
|
+
"prism-themes": "^1.9.0",
|
|
42
|
+
"rehype-slug": "^5.1.0",
|
|
43
|
+
"svelte-check": "^3.1.4",
|
|
44
|
+
"svelte-preprocess": "^5.0.1",
|
|
45
|
+
"svelte2tsx": "^0.6.0",
|
|
46
|
+
"tailwindcss": "^3.2.7",
|
|
47
|
+
"tslib": "^2.5.0",
|
|
48
|
+
"typescript": "^5.0.2",
|
|
49
|
+
"unist-util-visit": "^4.1.2",
|
|
50
|
+
"us-atlas": "^3.0.0",
|
|
51
|
+
"vite": "^4.2.1",
|
|
52
|
+
"vite-plugin-sveld": "^1.1.0"
|
|
53
|
+
},
|
|
54
|
+
"type": "module",
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@mdi/js": "^7.2.96",
|
|
57
|
+
"d3-array": "^3.2.3",
|
|
58
|
+
"d3-delaunay": "^6.0.2",
|
|
59
|
+
"d3-dsv": "^3.0.1",
|
|
60
|
+
"d3-geo": "^3.1.0",
|
|
61
|
+
"d3-hierarchy": "^3.1.2",
|
|
62
|
+
"d3-interpolate": "^3.0.1",
|
|
63
|
+
"d3-interpolate-path": "^2.3.0",
|
|
64
|
+
"d3-quadtree": "^3.0.1",
|
|
65
|
+
"d3-random": "^3.0.1",
|
|
66
|
+
"d3-sankey": "^0.12.3",
|
|
67
|
+
"d3-scale": "^4.0.2",
|
|
68
|
+
"d3-scale-chromatic": "^3.0.0",
|
|
69
|
+
"d3-shape": "^3.2.0",
|
|
70
|
+
"d3-tile": "^1.0.0",
|
|
71
|
+
"date-fns": "^2.29.3",
|
|
72
|
+
"layercake": "^7.3.4",
|
|
73
|
+
"lodash-es": "^4.17.21",
|
|
74
|
+
"svelte": "^3.57.0",
|
|
75
|
+
"svelte-ux": "^0.27.21",
|
|
76
|
+
"topojson-client": "^3.1.0"
|
|
77
|
+
},
|
|
78
|
+
"main": "./dist/index.js",
|
|
79
|
+
"exports": {
|
|
80
|
+
".": {
|
|
81
|
+
"types": "./dist/index.d.ts",
|
|
82
|
+
"svelte": "./dist/index.js"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"files": [
|
|
86
|
+
"dist"
|
|
87
|
+
],
|
|
88
|
+
"svelte": "./dist/index.js"
|
|
89
|
+
}
|
package/components/Legend.svelte
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>import { getContext } from 'svelte';
|
|
2
|
-
export let formatLabel = (label) => label;
|
|
3
|
-
const { rScale, rDomain, rRange } = getContext('LayerCake');
|
|
4
|
-
// zip values together
|
|
5
|
-
export let items = $rDomain.map((d, i) => ({ label: d, color: $rRange[i] }));
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<slot {items} scale={$rScale}>
|
|
9
|
-
<div {...$$restProps}>
|
|
10
|
-
{#each items as { label, color }}
|
|
11
|
-
<div class="flex items-center gap-1">
|
|
12
|
-
<div class="h-4 w-4 rounded-full" style:background-color={color} />
|
|
13
|
-
{formatLabel(label)}
|
|
14
|
-
</div>
|
|
15
|
-
{/each}
|
|
16
|
-
</div>
|
|
17
|
-
</slot>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
formatLabel?: ((label: string) => string) | undefined;
|
|
6
|
-
items?: any;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {
|
|
12
|
-
default: {
|
|
13
|
-
items: any;
|
|
14
|
-
scale: any;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export type LegendProps = typeof __propDef.props;
|
|
19
|
-
export type LegendEvents = typeof __propDef.events;
|
|
20
|
-
export type LegendSlots = typeof __propDef.slots;
|
|
21
|
-
export default class Legend extends SvelteComponentTyped<LegendProps, LegendEvents, LegendSlots> {
|
|
22
|
-
}
|
|
23
|
-
export {};
|
package/components/Zoom.svelte
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { motionStore } from '../stores/motionStore';
|
|
3
|
-
const { width, height, padding } = getContext('LayerCake');
|
|
4
|
-
export let spring = undefined;
|
|
5
|
-
export let tweened = undefined;
|
|
6
|
-
export let disablePointer = false;
|
|
7
|
-
let dragging = false;
|
|
8
|
-
const translate = motionStore({ x: 0, y: 0 }, { spring, tweened });
|
|
9
|
-
const scale = motionStore({ x: 1, y: 1 }, { spring, tweened });
|
|
10
|
-
let startPoint;
|
|
11
|
-
let startTranslate;
|
|
12
|
-
let svgEl = null;
|
|
13
|
-
export function reset() {
|
|
14
|
-
$translate = { x: 0, y: 0 };
|
|
15
|
-
$scale = { x: 1, y: 1 };
|
|
16
|
-
}
|
|
17
|
-
export function increase() {
|
|
18
|
-
$scale = {
|
|
19
|
-
x: $scale.x * 1.25,
|
|
20
|
-
y: $scale.y * 1.25
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export function decrease() {
|
|
24
|
-
$scale = {
|
|
25
|
-
x: $scale.x * 0.8,
|
|
26
|
-
y: $scale.y * 0.8
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export function translateCenter() {
|
|
30
|
-
$translate = {
|
|
31
|
-
x: 0,
|
|
32
|
-
y: 0
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export function zoomTo(newTranslate, newScale) {
|
|
36
|
-
$translate = {
|
|
37
|
-
x: $width / 2 - newTranslate.x,
|
|
38
|
-
y: $height / 2 - newTranslate.y
|
|
39
|
-
};
|
|
40
|
-
if (newScale) {
|
|
41
|
-
$scale = {
|
|
42
|
-
x: Math.min($width, $height) / newScale.x,
|
|
43
|
-
y: Math.min($width, $height) / newScale.y
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function handleMouseDown(e) {
|
|
48
|
-
if (disablePointer)
|
|
49
|
-
return;
|
|
50
|
-
dragging = true;
|
|
51
|
-
svgEl = e.target.ownerSVGElement;
|
|
52
|
-
startPoint = localPoint(svgEl, e);
|
|
53
|
-
startTranslate = $translate;
|
|
54
|
-
window.addEventListener('mousemove', handleMouseMove);
|
|
55
|
-
window.addEventListener('mouseup', handleMouseUp);
|
|
56
|
-
}
|
|
57
|
-
function handleMouseUp(e) {
|
|
58
|
-
dragging = false;
|
|
59
|
-
window.removeEventListener('mousemove', handleMouseMove);
|
|
60
|
-
window.removeEventListener('mouseup', handleMouseUp);
|
|
61
|
-
}
|
|
62
|
-
function handleMouseMove(e) {
|
|
63
|
-
if (!dragging)
|
|
64
|
-
return;
|
|
65
|
-
const endPoint = localPoint(svgEl, e);
|
|
66
|
-
const deltaX = endPoint.x - startPoint.x;
|
|
67
|
-
const deltaY = endPoint.y - startPoint.y;
|
|
68
|
-
translate.set({
|
|
69
|
-
x: startTranslate.x + deltaX / $scale.x,
|
|
70
|
-
y: startTranslate.y + deltaY / $scale.y
|
|
71
|
-
}, spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
72
|
-
}
|
|
73
|
-
function handleDoubleClick() {
|
|
74
|
-
if (disablePointer)
|
|
75
|
-
return;
|
|
76
|
-
increase();
|
|
77
|
-
}
|
|
78
|
-
function handleWheel(e) {
|
|
79
|
-
if (disablePointer)
|
|
80
|
-
return;
|
|
81
|
-
e.preventDefault();
|
|
82
|
-
const scaleBy = -e.deltaY > 0 ? 1.1 : 0.9;
|
|
83
|
-
// TODO: Update to match d3-zoom delta
|
|
84
|
-
// https://github.com/d3/d3-zoom#zoom_wheelDelta
|
|
85
|
-
// const scaleBy = -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 0.002);
|
|
86
|
-
scale.set({
|
|
87
|
-
x: $scale.x * scaleBy,
|
|
88
|
-
y: $scale.y * scaleBy
|
|
89
|
-
}, spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
90
|
-
}
|
|
91
|
-
function localPoint(svgEl, e) {
|
|
92
|
-
const screenCTM = svgEl.getScreenCTM();
|
|
93
|
-
const coords = {
|
|
94
|
-
x: e.clientX,
|
|
95
|
-
y: e.clientY
|
|
96
|
-
};
|
|
97
|
-
let point = svgEl.createSVGPoint();
|
|
98
|
-
point.x = coords.x;
|
|
99
|
-
point.y = coords.y;
|
|
100
|
-
point = point.matrixTransform(screenCTM.inverse());
|
|
101
|
-
return {
|
|
102
|
-
x: point.x,
|
|
103
|
-
y: point.y
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
$: center = { x: $width / 2, y: $height / 2 };
|
|
107
|
-
$: viewportCenter = {
|
|
108
|
-
x: center.x - $translate.x,
|
|
109
|
-
y: center.y - $translate.y
|
|
110
|
-
};
|
|
111
|
-
$: newTranslate = {
|
|
112
|
-
x: $translate.x * $scale.x + center.x - center.x * $scale.x,
|
|
113
|
-
y: $translate.y * $scale.y + center.y - center.y * $scale.y
|
|
114
|
-
};
|
|
115
|
-
</script>
|
|
116
|
-
|
|
117
|
-
<g
|
|
118
|
-
on:mousewheel={handleWheel}
|
|
119
|
-
on:mousedown={handleMouseDown}
|
|
120
|
-
on:dblclick={handleDoubleClick}
|
|
121
|
-
on:click
|
|
122
|
-
>
|
|
123
|
-
<rect
|
|
124
|
-
x={-$padding.left}
|
|
125
|
-
y={-$padding.top}
|
|
126
|
-
width={$width + $padding.left + $padding.right}
|
|
127
|
-
height={$height + $padding.top + $padding.bottom}
|
|
128
|
-
fill="transparent"
|
|
129
|
-
/>
|
|
130
|
-
<g transform="translate({newTranslate.x},{newTranslate.y}) scale({$scale.x},{$scale.y})">
|
|
131
|
-
<slot scale={$scale} />
|
|
132
|
-
</g>
|
|
133
|
-
</g>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|