layerchart 0.14.1 → 0.15.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script context="module">import { getContext, setContext } from 'svelte';
|
|
1
|
+
<script context="module">import { getContext, setContext, tick } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
import { geoMercator } from 'd3-geo';
|
|
4
4
|
export const geoContextKey = {};
|
|
@@ -25,20 +25,35 @@ export let center = undefined;
|
|
|
25
25
|
const geo = writable(projection());
|
|
26
26
|
setGeoContext(geo);
|
|
27
27
|
$: fitSizeRange = (fixedAspectRatio ? [100, 100 / fixedAspectRatio] : [$width, $height]);
|
|
28
|
+
$: console.log({ $width, $height });
|
|
29
|
+
let initialized = false;
|
|
28
30
|
$: {
|
|
31
|
+
console.log('update', { fitGeojson, translate, scale });
|
|
29
32
|
const _projection = projection();
|
|
30
|
-
if (fitGeojson && 'fitSize' in _projection) {
|
|
31
|
-
_projection.fitSize(fitSizeRange, fitGeojson);
|
|
32
|
-
}
|
|
33
33
|
if (scale && 'scale' in _projection) {
|
|
34
34
|
_projection.scale(scale);
|
|
35
35
|
}
|
|
36
|
-
if (rotate && 'rotate' in _projection) {
|
|
37
|
-
_projection.rotate([rotate.yaw, rotate.pitch, rotate.roll]);
|
|
38
|
-
}
|
|
39
36
|
if (translate && 'translate' in _projection) {
|
|
40
37
|
_projection.translate(translate);
|
|
41
38
|
}
|
|
39
|
+
// Apply before `rotate` but after `translate` / `scale`
|
|
40
|
+
if (fitGeojson && 'fitSize' in _projection) {
|
|
41
|
+
if (!initialized || (translate == undefined && scale == undefined)) {
|
|
42
|
+
console.log({ fitGeojson, $width, $height });
|
|
43
|
+
console.log('translate/scale before', {
|
|
44
|
+
translate: _projection.translate(),
|
|
45
|
+
scale: _projection.scale()
|
|
46
|
+
});
|
|
47
|
+
_projection.fitSize(fitSizeRange, fitGeojson);
|
|
48
|
+
console.log('translate/scale after', {
|
|
49
|
+
translate: _projection.translate(),
|
|
50
|
+
scale: _projection.scale()
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (rotate && 'rotate' in _projection) {
|
|
55
|
+
_projection.rotate([rotate.yaw, rotate.pitch, rotate.roll]);
|
|
56
|
+
}
|
|
42
57
|
if (center && 'center' in _projection) {
|
|
43
58
|
_projection.center(center);
|
|
44
59
|
}
|
|
@@ -48,6 +63,9 @@ $: {
|
|
|
48
63
|
if (clipExtent && 'clipExtent' in _projection) {
|
|
49
64
|
_projection.clipExtent(clipExtent);
|
|
50
65
|
}
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
initialized = true;
|
|
68
|
+
}, 3000);
|
|
51
69
|
geo.set(_projection);
|
|
52
70
|
}
|
|
53
71
|
</script>
|
|
@@ -11,8 +11,8 @@ export let title = '';
|
|
|
11
11
|
export let width = 320;
|
|
12
12
|
export let height = 10;
|
|
13
13
|
export let ticks = width / 64;
|
|
14
|
-
export let tickFormat;
|
|
15
|
-
export let tickValues;
|
|
14
|
+
export let tickFormat = undefined;
|
|
15
|
+
export let tickValues = undefined;
|
|
16
16
|
export let tickFontSize = 10;
|
|
17
17
|
export let tickSize = 4;
|
|
18
18
|
export let placement = undefined;
|
|
@@ -83,7 +83,6 @@ else if (scale.invertExtent) {
|
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
// Ordinal
|
|
86
|
-
console.log({ title });
|
|
87
86
|
xScale = scaleBand().domain(scale.domain()).rangeRound([0, width]);
|
|
88
87
|
swatches = scale.domain().map((d) => {
|
|
89
88
|
return {
|
|
@@ -120,44 +119,46 @@ else {
|
|
|
120
119
|
{...$$restProps}
|
|
121
120
|
>
|
|
122
121
|
<div class={cls('text-[10px] font-semibold', classes.title)}>{title}</div>
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
122
|
+
<slot values={tickValues} {scale}>
|
|
123
|
+
<svg
|
|
124
|
+
{width}
|
|
125
|
+
height={height + tickSize + tickFontSize}
|
|
126
|
+
viewBox="0 0 {width} {height + tickSize + tickFontSize}"
|
|
127
|
+
class="overflow-visible"
|
|
128
|
+
>
|
|
129
|
+
<g>
|
|
130
|
+
{#if interpolator}
|
|
131
|
+
<ColorRamp {width} {height} {interpolator} />
|
|
132
|
+
{:else if swatches}
|
|
133
|
+
{#each swatches as swatch, i}
|
|
134
|
+
<rect {...swatch} />
|
|
135
|
+
{/each}
|
|
136
|
+
{/if}
|
|
137
|
+
</g>
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
<g>
|
|
140
|
+
{#each tickValues ?? xScale?.ticks?.(ticks) ?? [] as tick, i}
|
|
141
|
+
<text
|
|
142
|
+
text-anchor="middle"
|
|
143
|
+
x={xScale(tick) + tickLabelOffset}
|
|
144
|
+
y={height + tickSize + tickFontSize}
|
|
145
|
+
style:font-size={tickFontSize}
|
|
146
|
+
class={classes.label}
|
|
147
|
+
>
|
|
148
|
+
{tickFormat ? format(tick, tickFormat) : tick}
|
|
149
|
+
</text>
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
{#if tickLine}
|
|
152
|
+
<line
|
|
153
|
+
x1={xScale(tick)}
|
|
154
|
+
y1={0}
|
|
155
|
+
x2={xScale(tick)}
|
|
156
|
+
y2={height + tickSize}
|
|
157
|
+
class={cls('stroke-black', classes.tick)}
|
|
158
|
+
/>
|
|
159
|
+
{/if}
|
|
160
|
+
{/each}
|
|
161
|
+
</g>
|
|
162
|
+
</svg>
|
|
163
|
+
</slot>
|
|
163
164
|
</div>
|
|
@@ -7,8 +7,8 @@ declare const __propDef: {
|
|
|
7
7
|
width?: number | undefined;
|
|
8
8
|
height?: number | undefined;
|
|
9
9
|
ticks?: number | undefined;
|
|
10
|
-
tickFormat
|
|
11
|
-
tickValues
|
|
10
|
+
tickFormat?: any;
|
|
11
|
+
tickValues?: any[] | undefined;
|
|
12
12
|
tickFontSize?: number | undefined;
|
|
13
13
|
tickSize?: number | undefined;
|
|
14
14
|
placement?: ("left" | "right" | "top" | "center" | "top-left" | "top-right" | "bottom-left" | "bottom" | "bottom-right") | undefined;
|
|
@@ -22,7 +22,12 @@ declare const __propDef: {
|
|
|
22
22
|
events: {
|
|
23
23
|
[evt: string]: CustomEvent<any>;
|
|
24
24
|
};
|
|
25
|
-
slots: {
|
|
25
|
+
slots: {
|
|
26
|
+
default: {
|
|
27
|
+
values: any[] | undefined;
|
|
28
|
+
scale: any;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
26
31
|
};
|
|
27
32
|
export type LegendProps = typeof __propDef.props;
|
|
28
33
|
export type LegendEvents = typeof __propDef.events;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { getContext, createEventDispatcher } from 'svelte';
|
|
1
|
+
<script>import { getContext, createEventDispatcher, onMount } from 'svelte';
|
|
2
2
|
import { motionStore } from '../stores/motionStore';
|
|
3
3
|
const { width, height, padding } = getContext('LayerCake');
|
|
4
4
|
export let mode = 'svg';
|
|
@@ -159,7 +159,13 @@ $: if (mode === 'svg') {
|
|
|
159
159
|
};
|
|
160
160
|
transform = `translate(${newTranslate.x},${newTranslate.y}) scale(${$scale})`;
|
|
161
161
|
}
|
|
162
|
+
let isMounted = false;
|
|
163
|
+
onMount(() => {
|
|
164
|
+
isMounted = true;
|
|
165
|
+
});
|
|
166
|
+
// $: if (isMounted) {
|
|
162
167
|
$: dispatch('zoom', { scale: $scale, translate: $translate });
|
|
168
|
+
// }
|
|
163
169
|
</script>
|
|
164
170
|
|
|
165
171
|
<g
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "techniq/layerchart",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.15.0",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite dev",
|
|
9
9
|
"build": "vite build",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rollup/plugin-dsv": "^3.0.2",
|
|
20
|
-
"@sveltejs/adapter-vercel": "^2.4.
|
|
21
|
-
"@sveltejs/kit": "^1.
|
|
20
|
+
"@sveltejs/adapter-vercel": "^2.4.3",
|
|
21
|
+
"@sveltejs/kit": "^1.15.9",
|
|
22
22
|
"@sveltejs/package": "^2.0.2",
|
|
23
23
|
"@tailwindcss/typography": "^0.5.9",
|
|
24
24
|
"@types/d3-array": "^3.0.4",
|
|
@@ -36,26 +36,27 @@
|
|
|
36
36
|
"@types/topojson-client": "^3.1.1",
|
|
37
37
|
"autoprefixer": "^10.4.14",
|
|
38
38
|
"mdsvex": "^0.10.6",
|
|
39
|
-
"prettier": "^2.8.
|
|
40
|
-
"prettier-plugin-svelte": "^2.
|
|
39
|
+
"prettier": "^2.8.8",
|
|
40
|
+
"prettier-plugin-svelte": "^2.10.0",
|
|
41
41
|
"prism-themes": "^1.9.0",
|
|
42
42
|
"rehype-slug": "^5.1.0",
|
|
43
|
-
"svelte-check": "^3.
|
|
43
|
+
"svelte-check": "^3.2.0",
|
|
44
44
|
"svelte-preprocess": "^5.0.1",
|
|
45
|
-
"svelte2tsx": "^0.6.
|
|
46
|
-
"tailwindcss": "^3.2
|
|
45
|
+
"svelte2tsx": "^0.6.11",
|
|
46
|
+
"tailwindcss": "^3.3.2",
|
|
47
47
|
"tslib": "^2.5.0",
|
|
48
|
-
"typescript": "^5.0.
|
|
48
|
+
"typescript": "^5.0.4",
|
|
49
49
|
"unist-util-visit": "^4.1.2",
|
|
50
|
-
"us-atlas": "^3.0.
|
|
51
|
-
"vite": "^4.
|
|
50
|
+
"us-atlas": "^3.0.1",
|
|
51
|
+
"vite": "^4.3.3",
|
|
52
52
|
"vite-plugin-sveld": "^1.1.0"
|
|
53
53
|
},
|
|
54
54
|
"type": "module",
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@mdi/js": "^7.2.96",
|
|
57
|
+
"@vercel/analytics": "^1.0.0",
|
|
57
58
|
"d3-array": "^3.2.3",
|
|
58
|
-
"d3-delaunay": "^6.0.
|
|
59
|
+
"d3-delaunay": "^6.0.4",
|
|
59
60
|
"d3-dsv": "^3.0.1",
|
|
60
61
|
"d3-geo": "^3.1.0",
|
|
61
62
|
"d3-hierarchy": "^3.1.2",
|
|
@@ -69,10 +70,10 @@
|
|
|
69
70
|
"d3-shape": "^3.2.0",
|
|
70
71
|
"d3-tile": "^1.0.0",
|
|
71
72
|
"date-fns": "^2.29.3",
|
|
72
|
-
"layercake": "^7.
|
|
73
|
+
"layercake": "^7.4.0",
|
|
73
74
|
"lodash-es": "^4.17.21",
|
|
74
|
-
"svelte": "^3.
|
|
75
|
-
"svelte-ux": "^0.
|
|
75
|
+
"svelte": "^3.58.0",
|
|
76
|
+
"svelte-ux": "^0.31.0",
|
|
76
77
|
"topojson-client": "^3.1.0"
|
|
77
78
|
},
|
|
78
79
|
"main": "./dist/index.js",
|