layerchart 0.31.2 → 0.32.1
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/Arc.svelte +2 -2
- package/dist/components/Area.svelte +1 -1
- package/dist/components/Axis.svelte +38 -12
- package/dist/components/Axis.svelte.d.ts +7 -0
- package/dist/components/Bar.svelte +2 -2
- package/dist/components/Bar.svelte.d.ts +4 -3
- package/dist/components/Bars.svelte +1 -0
- package/dist/components/Bars.svelte.d.ts +4 -3
- package/dist/components/Bounds.svelte +2 -2
- package/dist/components/Bounds.svelte.d.ts +1 -1
- package/dist/components/Chart.svelte +1 -1
- package/dist/components/Circle.svelte +2 -2
- package/dist/components/Circle.svelte.d.ts +1 -1
- package/dist/components/GeoEdgeFade.svelte +22 -0
- package/dist/components/GeoEdgeFade.svelte.d.ts +21 -0
- package/dist/components/GeoPoint.svelte +8 -3
- package/dist/components/GeoPoint.svelte.d.ts +4 -3
- package/dist/components/GeoSpline.svelte +37 -0
- package/dist/components/GeoSpline.svelte.d.ts +23 -0
- package/dist/components/Group.svelte +1 -1
- package/dist/components/Highlight.svelte +1 -1
- package/dist/components/Highlight.svelte.d.ts +1 -1
- package/dist/components/Labels.svelte +22 -15
- package/dist/components/Labels.svelte.d.ts +2 -0
- package/dist/components/Line.svelte +1 -1
- package/dist/components/Link.svelte +1 -1
- package/dist/components/Pie.svelte +2 -2
- package/dist/components/Points.svelte +1 -1
- package/dist/components/Rect.svelte +1 -1
- package/dist/components/Rect.svelte.d.ts +1 -1
- package/dist/components/RectClipPath.svelte.d.ts +4 -3
- package/dist/components/Spline.svelte +16 -6
- package/dist/components/Text.svelte +17 -5
- package/dist/components/Text.svelte.d.ts +5 -0
- package/dist/components/TooltipContext.svelte +3 -3
- package/dist/components/Treemap.svelte +5 -2
- package/dist/components/Zoom.svelte +12 -12
- package/dist/components/Zoom.svelte.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/utils/genData.js +1 -1
- package/dist/utils/index.d.ts +7 -7
- package/dist/utils/index.js +7 -7
- package/dist/utils/rect.js +1 -1
- package/dist/utils/scales.d.ts +1 -1
- package/dist/utils/scales.js +1 -1
- package/dist/utils/stack.js +1 -1
- package/package.json +2 -2
|
@@ -16,8 +16,8 @@ import { getContext, tick } from 'svelte';
|
|
|
16
16
|
import { arc as d3arc } from 'd3-shape';
|
|
17
17
|
import { scaleLinear } from 'd3-scale';
|
|
18
18
|
import { min, max } from 'd3-array';
|
|
19
|
-
import { motionStore } from '../stores/motionStore';
|
|
20
|
-
import { degreesToRadians } from '../utils/math';
|
|
19
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
20
|
+
import { degreesToRadians } from '../utils/math.js';
|
|
21
21
|
export let spring = undefined;
|
|
22
22
|
export let tweened = undefined;
|
|
23
23
|
export let value = 0;
|
|
@@ -3,7 +3,7 @@ import { area as d3Area, areaRadial } from 'd3-shape';
|
|
|
3
3
|
import { max } from 'd3-array';
|
|
4
4
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
5
5
|
import { cls } from 'svelte-ux';
|
|
6
|
-
import { motionStore } from '../stores/motionStore';
|
|
6
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
7
7
|
import Spline from './Spline.svelte';
|
|
8
8
|
const { data: contextData, xScale, yScale, xGet, yGet, yRange } = getContext('LayerCake');
|
|
9
9
|
/** Override data instead of using context */
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import {
|
|
2
|
+
import { fade } from 'svelte/transition';
|
|
3
|
+
import { cubicIn } from 'svelte/easing';
|
|
3
4
|
import { extent } from 'd3-array';
|
|
4
5
|
import { pointRadial } from 'd3-shape';
|
|
6
|
+
import { format as formatValue, cls } from 'svelte-ux';
|
|
7
|
+
import Circle from './Circle.svelte';
|
|
8
|
+
import Line from './Line.svelte';
|
|
5
9
|
import Text from './Text.svelte';
|
|
6
|
-
import { isScaleBand } from '../utils/scales';
|
|
10
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
7
11
|
const { xScale, yScale, xRange, yRange, width } = getContext('LayerCake');
|
|
8
12
|
/** Location of axis */
|
|
9
13
|
export let placement;
|
|
@@ -17,6 +21,10 @@ export let ticks = placement === 'left' || placement === 'right' ? 4 : undefined
|
|
|
17
21
|
export let tickSize = 4;
|
|
18
22
|
export let format = undefined;
|
|
19
23
|
export let labelProps = undefined;
|
|
24
|
+
export let spring = undefined;
|
|
25
|
+
export let tweened = undefined;
|
|
26
|
+
export let transitionIn = tweened ? fade : () => { };
|
|
27
|
+
export let transitionInParams = { easing: cubicIn };
|
|
20
28
|
$: orientation =
|
|
21
29
|
placement === 'angle'
|
|
22
30
|
? 'angle'
|
|
@@ -118,22 +126,26 @@ function getDefaultLabelProps(tick) {
|
|
|
118
126
|
{#if rule !== false}
|
|
119
127
|
{@const lineProps = typeof rule === 'object' ? rule : null}
|
|
120
128
|
{#if orientation === 'vertical'}
|
|
121
|
-
<
|
|
129
|
+
<Line
|
|
122
130
|
x1={placement === 'right' ? xRangeMax : xRangeMin}
|
|
123
131
|
x2={placement === 'right' ? xRangeMax : xRangeMin}
|
|
124
132
|
y1={$yRange[0] || 0}
|
|
125
133
|
y2={$yRange[1] || 0}
|
|
134
|
+
{tweened}
|
|
135
|
+
{spring}
|
|
126
136
|
{...lineProps}
|
|
127
137
|
class={cls('rule stroke-surface-content/50', lineProps?.class)}
|
|
128
138
|
/>
|
|
129
139
|
{/if}
|
|
130
140
|
|
|
131
141
|
{#if orientation === 'horizontal'}
|
|
132
|
-
<
|
|
142
|
+
<Line
|
|
133
143
|
x1={$xRange[0] || 0}
|
|
134
144
|
x2={$xRange[1] || 0}
|
|
135
145
|
y1={placement === 'top' ? yRangeMin : yRangeMax}
|
|
136
146
|
y2={placement === 'top' ? yRangeMin : yRangeMax}
|
|
147
|
+
{tweened}
|
|
148
|
+
{spring}
|
|
137
149
|
{...lineProps}
|
|
138
150
|
class={cls('rule stroke-surface-content/50', lineProps?.class)}
|
|
139
151
|
/>
|
|
@@ -142,36 +154,42 @@ function getDefaultLabelProps(tick) {
|
|
|
142
154
|
<!-- TODO: angle rule? -->
|
|
143
155
|
|
|
144
156
|
{#if orientation === 'radius'}
|
|
145
|
-
<
|
|
157
|
+
<Circle
|
|
146
158
|
r={$yRange[0] || 0}
|
|
159
|
+
{tweened}
|
|
160
|
+
{spring}
|
|
147
161
|
{...lineProps}
|
|
148
162
|
class={cls('rule stroke-surface-content/20 fill-none', lineProps?.class)}
|
|
149
163
|
/>
|
|
150
164
|
{/if}
|
|
151
165
|
{/if}
|
|
152
166
|
|
|
153
|
-
{#each tickVals as tick
|
|
167
|
+
{#each tickVals as tick (tick)}
|
|
154
168
|
{@const tickCoords = getCoords(tick)}
|
|
155
169
|
{@const radialTickCoords = pointRadial(tickCoords.x, tickCoords.y)}
|
|
156
170
|
|
|
157
|
-
<g>
|
|
171
|
+
<g in:transitionIn={transitionInParams}>
|
|
158
172
|
{#if grid !== false}
|
|
159
173
|
{@const lineProps = typeof grid === 'object' ? grid : null}
|
|
160
174
|
{#if orientation === 'horizontal'}
|
|
161
|
-
<
|
|
175
|
+
<Line
|
|
162
176
|
x1={tickCoords.x}
|
|
163
177
|
y1={yRangeMin}
|
|
164
178
|
x2={tickCoords.x}
|
|
165
179
|
y2={yRangeMax}
|
|
180
|
+
{tweened}
|
|
181
|
+
{spring}
|
|
166
182
|
{...lineProps}
|
|
167
183
|
class={cls('grid stroke-surface-content/10', lineProps?.class)}
|
|
168
184
|
/>
|
|
169
185
|
{:else if orientation === 'vertical'}
|
|
170
|
-
<
|
|
186
|
+
<Line
|
|
171
187
|
x1={0}
|
|
172
188
|
y1={tickCoords.y}
|
|
173
189
|
x2={$width}
|
|
174
190
|
y2={tickCoords.y}
|
|
191
|
+
{tweened}
|
|
192
|
+
{spring}
|
|
175
193
|
{...lineProps}
|
|
176
194
|
class={cls('grid stroke-surface-content/10', lineProps?.class)}
|
|
177
195
|
/>
|
|
@@ -179,11 +197,13 @@ function getDefaultLabelProps(tick) {
|
|
|
179
197
|
{@const [x1, y1] = pointRadial(tickCoords.x, yRangeMin)}
|
|
180
198
|
{@const [x2, y2] = pointRadial(tickCoords.x, yRangeMax)}
|
|
181
199
|
|
|
182
|
-
<
|
|
200
|
+
<Line
|
|
183
201
|
{x1}
|
|
184
202
|
{y1}
|
|
185
203
|
{x2}
|
|
186
204
|
{y2}
|
|
205
|
+
{tweened}
|
|
206
|
+
{spring}
|
|
187
207
|
{...lineProps}
|
|
188
208
|
class={cls('test grid stroke-surface-content/10', lineProps?.class)}
|
|
189
209
|
/>
|
|
@@ -198,19 +218,23 @@ function getDefaultLabelProps(tick) {
|
|
|
198
218
|
|
|
199
219
|
<!-- Tick marks -->
|
|
200
220
|
{#if orientation === 'horizontal'}
|
|
201
|
-
<
|
|
221
|
+
<Line
|
|
202
222
|
x1={tickCoords.x}
|
|
203
223
|
y1={tickCoords.y}
|
|
204
224
|
x2={tickCoords.x}
|
|
205
225
|
y2={tickCoords.y + (placement === 'top' ? -tickSize : tickSize)}
|
|
226
|
+
{tweened}
|
|
227
|
+
{spring}
|
|
206
228
|
class="tick stroke-surface-content/50"
|
|
207
229
|
/>
|
|
208
230
|
{:else if orientation === 'vertical'}
|
|
209
|
-
<
|
|
231
|
+
<Line
|
|
210
232
|
x1={tickCoords.x}
|
|
211
233
|
y1={tickCoords.y}
|
|
212
234
|
x2={tickCoords.x + (placement === 'left' ? -tickSize : tickSize)}
|
|
213
235
|
y2={tickCoords.y}
|
|
236
|
+
{tweened}
|
|
237
|
+
{spring}
|
|
214
238
|
class="tick stroke-surface-content/50"
|
|
215
239
|
/>
|
|
216
240
|
{/if}
|
|
@@ -220,6 +244,8 @@ function getDefaultLabelProps(tick) {
|
|
|
220
244
|
y={orientation === 'angle' ? radialTickCoords[1] : tickCoords.y}
|
|
221
245
|
value={formatValue(tick, format ?? scale.tickFormat?.() ?? ((v) => v))}
|
|
222
246
|
{...getDefaultLabelProps(tick)}
|
|
247
|
+
{tweened}
|
|
248
|
+
{spring}
|
|
223
249
|
{...labelProps}
|
|
224
250
|
class={cls(
|
|
225
251
|
'label text-[10px] stroke-surface-100 [stroke-width:2px] font-light',
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import { type ComponentProps } from 'svelte';
|
|
3
|
+
import { fade } from 'svelte/transition';
|
|
3
4
|
import type { SVGAttributes } from 'svelte/elements';
|
|
5
|
+
import type { spring as springStore, tweened as tweenedStore } from 'svelte/motion';
|
|
6
|
+
import { type TransitionParams } from 'svelte-ux';
|
|
4
7
|
import Text from './Text.svelte';
|
|
5
8
|
declare const __propDef: {
|
|
6
9
|
props: {
|
|
@@ -11,6 +14,10 @@ declare const __propDef: {
|
|
|
11
14
|
/** Length of the tick line */ tickSize?: number | undefined;
|
|
12
15
|
format?: any;
|
|
13
16
|
labelProps?: Partial<ComponentProps<Text>> | undefined;
|
|
17
|
+
spring?: boolean | Parameters<typeof springStore>[1];
|
|
18
|
+
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
19
|
+
transitionIn?: typeof fade | (() => void) | undefined;
|
|
20
|
+
transitionInParams?: TransitionParams | undefined;
|
|
14
21
|
};
|
|
15
22
|
events: {
|
|
16
23
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { createDimensionGetter } from '../utils/rect';
|
|
2
|
+
import { createDimensionGetter } from '../utils/rect.js';
|
|
3
3
|
import Rect from './Rect.svelte';
|
|
4
|
-
const { x: xContext, y: yContext
|
|
4
|
+
const { x: xContext, y: yContext } = getContext('LayerCake');
|
|
5
5
|
export let bar;
|
|
6
6
|
/**
|
|
7
7
|
* Override `x` from context. Useful for multiple Bar instances
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import
|
|
2
|
+
import { type ComponentProps } from 'svelte';
|
|
3
|
+
import Rect from './Rect.svelte';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
[x: string]: any;
|
|
@@ -14,8 +15,8 @@ declare const __propDef: {
|
|
|
14
15
|
groupBy?: string | undefined;
|
|
15
16
|
groupPaddingInner?: number | undefined;
|
|
16
17
|
groupPaddingOuter?: number | undefined;
|
|
17
|
-
spring?:
|
|
18
|
-
tweened?:
|
|
18
|
+
spring?: ComponentProps<Rect>['spring'];
|
|
19
|
+
tweened?: ComponentProps<Rect>['tweened'];
|
|
19
20
|
};
|
|
20
21
|
events: {
|
|
21
22
|
click: MouseEvent;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import
|
|
2
|
+
import { type ComponentProps } from 'svelte';
|
|
3
|
+
import Rect from './Rect.svelte';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
[x: string]: any;
|
|
@@ -9,8 +10,8 @@ declare const __propDef: {
|
|
|
9
10
|
strokeWidth?: number | undefined;
|
|
10
11
|
radius?: number | undefined;
|
|
11
12
|
inset?: number | undefined;
|
|
12
|
-
spring?:
|
|
13
|
-
tweened?:
|
|
13
|
+
spring?: ComponentProps<Rect>['spring'];
|
|
14
|
+
tweened?: ComponentProps<Rect>['tweened'];
|
|
14
15
|
groupBy?: string | undefined;
|
|
15
16
|
groupPaddingInner?: number | undefined;
|
|
16
17
|
groupPaddingOuter?: number | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { scaleLinear } from 'd3-scale';
|
|
3
|
-
import { motionScale } from '../utils/scales';
|
|
3
|
+
import { motionScale } from '../utils/scales.js';
|
|
4
4
|
const { width, height } = getContext('LayerCake');
|
|
5
5
|
export let domain;
|
|
6
6
|
export let range;
|
|
@@ -10,7 +10,7 @@ function getExtents(extents, axis, fallback) {
|
|
|
10
10
|
const resolvedExtents = typeof extents === 'function' ? extents({ width: $width, height: $height }) : extents;
|
|
11
11
|
return [
|
|
12
12
|
resolvedExtents?.[axis + '0'] ?? 0, // x0 or y0
|
|
13
|
-
resolvedExtents?.[axis + '1'] ?? fallback // x1 or y1, fallback as $width or $height
|
|
13
|
+
resolvedExtents?.[axis + '1'] ?? fallback, // x1 or y1, fallback as $width or $height
|
|
14
14
|
];
|
|
15
15
|
}
|
|
16
16
|
const xScale = motionScale(scaleLinear, { spring, tweened });
|
|
@@ -11,7 +11,7 @@ export const WebGL = _WebGL;
|
|
|
11
11
|
|
|
12
12
|
<script>import { max, min } from 'd3-array';
|
|
13
13
|
import { get } from 'lodash-es';
|
|
14
|
-
import { isScaleBand } from '../utils/scales';
|
|
14
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
15
15
|
import TooltipContext from './TooltipContext.svelte';
|
|
16
16
|
import GeoContext from './GeoContext.svelte';
|
|
17
17
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>import { tick } from 'svelte';
|
|
2
2
|
import { cls } from 'svelte-ux';
|
|
3
|
-
import { motionStore } from '../stores/motionStore';
|
|
3
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
4
4
|
export let cx = 0;
|
|
5
5
|
export let initialCx = cx;
|
|
6
6
|
export let cy = 0;
|
|
7
7
|
export let initialCy = cy;
|
|
8
|
-
export let r;
|
|
8
|
+
export let r = 1;
|
|
9
9
|
export let initialR = r;
|
|
10
10
|
export let spring = undefined;
|
|
11
11
|
export let tweened = undefined;
|
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
initialCx?: number | undefined;
|
|
8
8
|
cy?: number | undefined;
|
|
9
9
|
initialCy?: number | undefined;
|
|
10
|
-
r
|
|
10
|
+
r?: number | undefined;
|
|
11
11
|
initialR?: number | undefined;
|
|
12
12
|
spring?: boolean | Parameters<typeof springStore>[1];
|
|
13
13
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>import { getContext } from 'svelte';
|
|
2
|
+
import { scaleLinear } from 'd3-scale';
|
|
3
|
+
import { geoDistance } from 'd3-geo';
|
|
4
|
+
import { geoContext } from './GeoContext.svelte';
|
|
5
|
+
export let link;
|
|
6
|
+
const { width, height } = getContext('LayerCake');
|
|
7
|
+
const geo = geoContext();
|
|
8
|
+
const fade = scaleLinear().domain([-0.1, 0]).range([0, 0.1]);
|
|
9
|
+
const clamper = scaleLinear().domain([0, 1]).range([0, 1]).clamp(true);
|
|
10
|
+
// $: center = $geo.invert([$width / 2, $height / 2]);
|
|
11
|
+
$: center = $geo.invert($geo.translate());
|
|
12
|
+
$: source = link.source;
|
|
13
|
+
$: target = link.target;
|
|
14
|
+
$: startDistance = 1.57 - geoDistance(source, center);
|
|
15
|
+
$: endDistance = 1.57 - geoDistance(target, center);
|
|
16
|
+
$: distance = startDistance < endDistance ? startDistance : endDistance;
|
|
17
|
+
$: opacity = clamper(fade(distance));
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<g {opacity}>
|
|
21
|
+
<slot />
|
|
22
|
+
</g>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
link: {
|
|
5
|
+
source: [number, number];
|
|
6
|
+
target: [number, number];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type GeoEdgeFadeProps = typeof __propDef.props;
|
|
17
|
+
export type GeoEdgeFadeEvents = typeof __propDef.events;
|
|
18
|
+
export type GeoEdgeFadeSlots = typeof __propDef.slots;
|
|
19
|
+
export default class GeoEdgeFade extends SvelteComponentTyped<GeoEdgeFadeProps, GeoEdgeFadeEvents, GeoEdgeFadeSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { scaleCanvas } from 'layercake';
|
|
3
3
|
import { geoContext } from './GeoContext.svelte';
|
|
4
|
+
import Circle from './Circle.svelte';
|
|
4
5
|
/** Latitude */
|
|
5
6
|
export let lat;
|
|
6
7
|
/** Longitude */
|
|
@@ -22,7 +23,11 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
22
23
|
</script>
|
|
23
24
|
|
|
24
25
|
{#if renderContext === 'svg'}
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
26
|
+
{#if $$slots.default}
|
|
27
|
+
<g transform="translate({x},{y})">
|
|
28
|
+
<slot />
|
|
29
|
+
</g>
|
|
30
|
+
{:else}
|
|
31
|
+
<Circle cx={x} cy={y} {...$$restProps} />
|
|
32
|
+
{/if}
|
|
28
33
|
{/if}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
lat: number;
|
|
6
|
+
long: number;
|
|
7
|
+
render?: ((ctx: CanvasRenderingContext2D, coords: {
|
|
7
8
|
x: number;
|
|
8
9
|
y: number;
|
|
9
10
|
}) => any) | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>import { getContext } from 'svelte';
|
|
2
|
+
import { geoOrthographic, geoInterpolate } from 'd3-geo';
|
|
3
|
+
import { curveNatural } from 'd3-shape';
|
|
4
|
+
import { geoContext } from './GeoContext.svelte';
|
|
5
|
+
import Spline from './Spline.svelte';
|
|
6
|
+
export let link;
|
|
7
|
+
/** Amount of loft to apply to the midle of the curve */
|
|
8
|
+
export let loft = 1.0;
|
|
9
|
+
/**
|
|
10
|
+
* Curve of spline drawn. Imported via d3-shape.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { curveNatural } from 'd3-shape';
|
|
14
|
+
* <GeoSpline curve={curveNatrual} />
|
|
15
|
+
*
|
|
16
|
+
* @type {CurveFactory | CurveFactoryLineOnly | undefined}
|
|
17
|
+
*/
|
|
18
|
+
export let curve = curveNatural;
|
|
19
|
+
const { width, height } = getContext('LayerCake');
|
|
20
|
+
const geo = geoContext();
|
|
21
|
+
$: loftedProjection = geoOrthographic()
|
|
22
|
+
.translate($geo.translate())
|
|
23
|
+
.rotate($geo.rotate())
|
|
24
|
+
.scale($geo.scale() * loft);
|
|
25
|
+
$: source = $geo(link.source);
|
|
26
|
+
$: target = $geo(link.target);
|
|
27
|
+
$: middle = loftedProjection(geoInterpolate(link.source, link.target)(0.5));
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<Spline
|
|
31
|
+
data={[source, middle, target]}
|
|
32
|
+
x={(d) => d[0]}
|
|
33
|
+
y={(d) => d[1]}
|
|
34
|
+
defined={(d) => $geo.invert(d)}
|
|
35
|
+
{curve}
|
|
36
|
+
{...$$restProps}
|
|
37
|
+
/>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { CurveFactory, CurveFactoryLineOnly } from 'd3-shape';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
link: {
|
|
7
|
+
source: [number, number];
|
|
8
|
+
target: [number, number];
|
|
9
|
+
};
|
|
10
|
+
loft?: number | undefined;
|
|
11
|
+
curve?: CurveFactory | CurveFactoryLineOnly | undefined;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export type GeoSplineProps = typeof __propDef.props;
|
|
19
|
+
export type GeoSplineEvents = typeof __propDef.events;
|
|
20
|
+
export type GeoSplineSlots = typeof __propDef.slots;
|
|
21
|
+
export default class GeoSpline extends SvelteComponentTyped<GeoSplineProps, GeoSplineEvents, GeoSplineSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { max, min } from 'd3-array';
|
|
3
3
|
import { cls, notNull } from 'svelte-ux';
|
|
4
|
-
import { isScaleBand } from '../utils/scales';
|
|
4
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
5
5
|
import Circle from './Circle.svelte';
|
|
6
6
|
import Line from './Line.svelte';
|
|
7
7
|
import Bar from './Bar.svelte';
|
|
@@ -8,7 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
initialCx?: number | undefined;
|
|
9
9
|
cy?: number | undefined;
|
|
10
10
|
initialCy?: number | undefined;
|
|
11
|
-
r
|
|
11
|
+
r?: number | undefined;
|
|
12
12
|
initialR?: number | undefined;
|
|
13
13
|
spring?: boolean | import("svelte/motion").SpringOpts | undefined;
|
|
14
14
|
tweened?: boolean | import("svelte/motion").TweenedOptions<unknown> | undefined;
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
* - [ ] Support multiple values (threshold, stacks, etc)
|
|
5
5
|
*/
|
|
6
6
|
import { getContext } from 'svelte';
|
|
7
|
-
import { format as formatValue } from 'svelte-ux';
|
|
7
|
+
import { format as formatValue, cls } from 'svelte-ux';
|
|
8
8
|
import { greatestAbs } from 'svelte-ux/utils/array';
|
|
9
9
|
import Text from './Text.svelte';
|
|
10
|
-
import { isScaleBand } from '../utils/scales';
|
|
11
|
-
import { createDimensionGetter } from '../utils/rect';
|
|
10
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
11
|
+
import { createDimensionGetter } from '../utils/rect.js';
|
|
12
12
|
const { flatData, yScale, x, y, custom } = getContext('LayerCake');
|
|
13
|
-
//
|
|
13
|
+
// TODO: Support 'auto' to switch `inside` to `outside` if not enough room
|
|
14
|
+
export let placement = 'outside';
|
|
15
|
+
export let offset = 4;
|
|
14
16
|
export let significantDigits = 3;
|
|
15
17
|
export let format = undefined;
|
|
16
18
|
// export let overlap = false;
|
|
@@ -52,9 +54,9 @@ $: getTextProps = (item) => {
|
|
|
52
54
|
if (labelValue < 0) {
|
|
53
55
|
// left
|
|
54
56
|
return {
|
|
55
|
-
x: dimensions?.x -
|
|
57
|
+
x: dimensions?.x + (placement === 'outside' ? -offset : offset),
|
|
56
58
|
y: dimensions?.y + (dimensions?.height ?? 0) / 2,
|
|
57
|
-
textAnchor: 'end',
|
|
59
|
+
textAnchor: placement === 'outside' ? 'end' : 'start',
|
|
58
60
|
verticalAnchor: 'middle',
|
|
59
61
|
capHeight: '.6rem',
|
|
60
62
|
};
|
|
@@ -62,9 +64,9 @@ $: getTextProps = (item) => {
|
|
|
62
64
|
else {
|
|
63
65
|
// right
|
|
64
66
|
return {
|
|
65
|
-
x: dimensions?.x + dimensions?.width +
|
|
67
|
+
x: dimensions?.x + dimensions?.width + (placement === 'outside' ? offset : -offset),
|
|
66
68
|
y: dimensions?.y + (dimensions?.height ?? 0) / 2,
|
|
67
|
-
textAnchor: 'start',
|
|
69
|
+
textAnchor: placement === 'outside' ? 'start' : 'end',
|
|
68
70
|
verticalAnchor: 'middle',
|
|
69
71
|
capHeight: '.6rem',
|
|
70
72
|
};
|
|
@@ -76,20 +78,20 @@ $: getTextProps = (item) => {
|
|
|
76
78
|
// bottom
|
|
77
79
|
return {
|
|
78
80
|
x: dimensions?.x + (dimensions?.width ?? 0) / 2,
|
|
79
|
-
y: dimensions?.y + dimensions?.height,
|
|
80
|
-
|
|
81
|
+
y: dimensions?.y + dimensions?.height + (placement === 'outside' ? offset : -offset),
|
|
82
|
+
capHeight: '.6rem',
|
|
81
83
|
textAnchor: 'middle',
|
|
82
|
-
verticalAnchor: '
|
|
84
|
+
verticalAnchor: placement === 'outside' ? 'start' : 'end',
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
else {
|
|
86
88
|
// top
|
|
87
89
|
return {
|
|
88
90
|
x: dimensions?.x + (dimensions?.width ?? 0) / 2,
|
|
89
|
-
y: dimensions?.y,
|
|
90
|
-
|
|
91
|
+
y: dimensions?.y + (placement === 'outside' ? -offset : offset),
|
|
92
|
+
capHeight: '.6rem',
|
|
91
93
|
textAnchor: 'middle',
|
|
92
|
-
verticalAnchor: '
|
|
94
|
+
verticalAnchor: placement === 'outside' ? 'end' : 'start',
|
|
93
95
|
};
|
|
94
96
|
}
|
|
95
97
|
}
|
|
@@ -101,7 +103,12 @@ $: getTextProps = (item) => {
|
|
|
101
103
|
<!-- TODO: Add labels for each item when array/stack? Use `getValue(item)` instead and iterate -->
|
|
102
104
|
<Text
|
|
103
105
|
value={getFormattedValue(item)}
|
|
104
|
-
class=
|
|
106
|
+
class={cls(
|
|
107
|
+
'text-xs',
|
|
108
|
+
placement === 'inside'
|
|
109
|
+
? 'fill-surface-300 stroke-surface-content'
|
|
110
|
+
: 'fill-surface-content stroke-surface-100'
|
|
111
|
+
)}
|
|
105
112
|
{...getTextProps(item)}
|
|
106
113
|
{...$$restProps}
|
|
107
114
|
/>
|
|
@@ -3,6 +3,8 @@ import { type FormatType } from 'svelte-ux';
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
|
+
placement?: "inside" | "outside" | undefined;
|
|
7
|
+
offset?: number | undefined;
|
|
6
8
|
significantDigits?: number | undefined;
|
|
7
9
|
format?: FormatType | undefined;
|
|
8
10
|
groupBy?: string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { link as d3Link, curveBumpX, curveBumpY } from 'd3-shape';
|
|
2
2
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
3
|
-
import { motionStore } from '../stores/motionStore';
|
|
3
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
4
4
|
// Override what is used from context
|
|
5
5
|
export let data = undefined; // TODO: Update Type
|
|
6
6
|
/**
|
|
@@ -3,8 +3,8 @@ import { pie as d3pie } from 'd3-shape';
|
|
|
3
3
|
import { min, max } from 'd3-array';
|
|
4
4
|
import Arc from './Arc.svelte';
|
|
5
5
|
import Group from './Group.svelte';
|
|
6
|
-
import { degreesToRadians } from '../utils/math';
|
|
7
|
-
import { motionStore } from '../stores/motionStore';
|
|
6
|
+
import { degreesToRadians } from '../utils/math.js';
|
|
7
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
8
8
|
/*
|
|
9
9
|
TODO:
|
|
10
10
|
- [ ] Offset (always, on hover)
|
|
@@ -3,7 +3,7 @@ import { extent } from 'd3-array';
|
|
|
3
3
|
import { notNull } from 'svelte-ux';
|
|
4
4
|
import Circle from './Circle.svelte';
|
|
5
5
|
import Link from './Link.svelte';
|
|
6
|
-
import { isScaleBand } from '../utils/scales';
|
|
6
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
7
7
|
import { pointRadial } from 'd3-shape';
|
|
8
8
|
const context = getContext('LayerCake');
|
|
9
9
|
const { data, xGet, y, yGet, xScale, yScale, rGet, config } = context;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { tick } from 'svelte';
|
|
2
2
|
import { cls } from 'svelte-ux';
|
|
3
|
-
import { motionStore, resolveOptions, } from '../stores/motionStore';
|
|
3
|
+
import { motionStore, resolveOptions, } from '../stores/motionStore.js';
|
|
4
4
|
export let x = 0;
|
|
5
5
|
export let initialX = x;
|
|
6
6
|
export let y = 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { type SpringOptions, type TweenedOptions } from '../stores/motionStore';
|
|
2
|
+
import { type SpringOptions, type TweenedOptions } from '../stores/motionStore.js';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import Rect from './Rect.svelte';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
[x: string]: any;
|
|
@@ -8,8 +9,8 @@ declare const __propDef: {
|
|
|
8
9
|
y?: number | undefined;
|
|
9
10
|
width: number;
|
|
10
11
|
height: number;
|
|
11
|
-
spring?:
|
|
12
|
-
tweened?:
|
|
12
|
+
spring?: ComponentProps<Rect>['spring'];
|
|
13
|
+
tweened?: ComponentProps<Rect>['tweened'];
|
|
13
14
|
};
|
|
14
15
|
events: {
|
|
15
16
|
[evt: string]: CustomEvent<any>;
|
|
@@ -7,9 +7,9 @@ import { line as d3Line, lineRadial } from 'd3-shape';
|
|
|
7
7
|
// import { interpolateString } from 'd3-interpolate';
|
|
8
8
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
9
9
|
import { cls } from 'svelte-ux';
|
|
10
|
-
import { motionStore } from '../stores/motionStore';
|
|
10
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
11
11
|
import Group from './Group.svelte';
|
|
12
|
-
const { data: contextData, xScale, yScale,
|
|
12
|
+
const { data: contextData, xScale, yScale, x: contextX, y: contextY } = getContext('LayerCake');
|
|
13
13
|
/** Override data instead of using context */
|
|
14
14
|
export let data = undefined;
|
|
15
15
|
/** Pass `<path d={...} />` explicitly instead of calculating from data / context */
|
|
@@ -35,17 +35,27 @@ export let draw = undefined;
|
|
|
35
35
|
*/
|
|
36
36
|
export let curve = undefined;
|
|
37
37
|
export let defined = undefined;
|
|
38
|
+
function getScaleValue(data, scale, accessor) {
|
|
39
|
+
if (scale.domain().length) {
|
|
40
|
+
// If scale is defined with domain, map value
|
|
41
|
+
return scale(accessor(data));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Use raw value
|
|
45
|
+
return accessor(data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
38
48
|
let d = '';
|
|
39
49
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
40
50
|
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
41
51
|
$: {
|
|
42
52
|
const path = radial
|
|
43
53
|
? lineRadial()
|
|
44
|
-
.angle((d) => (
|
|
45
|
-
.radius((d) => (
|
|
54
|
+
.angle((d) => getScaleValue(d, $xScale, x ?? $contextX))
|
|
55
|
+
.radius((d) => getScaleValue(d, $yScale, y ?? $contextY))
|
|
46
56
|
: d3Line()
|
|
47
|
-
.x((d) => (
|
|
48
|
-
.y((d) => (
|
|
57
|
+
.x((d) => getScaleValue(d, $xScale, x ?? $contextX))
|
|
58
|
+
.y((d) => getScaleValue(d, $yScale, y ?? $contextY));
|
|
49
59
|
if (curve)
|
|
50
60
|
path.curve(curve);
|
|
51
61
|
if (defined)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script>import { tick } from 'svelte';
|
|
2
|
+
import { cls } from 'svelte-ux';
|
|
3
|
+
import { getStringWidth } from '../utils/string.js';
|
|
4
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
3
5
|
/*
|
|
4
6
|
TODO:
|
|
5
7
|
- [ ] Handle styled text (use <slot /> to measure?)
|
|
@@ -19,8 +21,10 @@ export let value = 0;
|
|
|
19
21
|
export let width = undefined;
|
|
20
22
|
/** x position of the text */
|
|
21
23
|
export let x = 0;
|
|
24
|
+
export let initialX = x;
|
|
22
25
|
/** y position of the text */
|
|
23
26
|
export let y = 0;
|
|
27
|
+
export let initialY = y;
|
|
24
28
|
/** dx offset of the text */
|
|
25
29
|
export let dx = 0;
|
|
26
30
|
/** dy offset of the text */
|
|
@@ -118,6 +122,14 @@ function isValidXOrY(xOrY) {
|
|
|
118
122
|
// for percentage
|
|
119
123
|
typeof xOrY === 'string');
|
|
120
124
|
}
|
|
125
|
+
export let spring = undefined;
|
|
126
|
+
export let tweened = undefined;
|
|
127
|
+
let tweened_x = motionStore(initialX, { spring, tweened });
|
|
128
|
+
let tweened_y = motionStore(initialY, { spring, tweened });
|
|
129
|
+
$: tick().then(() => {
|
|
130
|
+
tweened_x.set(x);
|
|
131
|
+
tweened_y.set(y);
|
|
132
|
+
});
|
|
121
133
|
</script>
|
|
122
134
|
|
|
123
135
|
<!-- `overflow: visible` allow contents to be shown outside element -->
|
|
@@ -125,15 +137,15 @@ function isValidXOrY(xOrY) {
|
|
|
125
137
|
<svg x={dx} y={dy} class="overflow-visible [paint-order:stroke]">
|
|
126
138
|
{#if isValidXOrY(x) && isValidXOrY(y)}
|
|
127
139
|
<text
|
|
128
|
-
{
|
|
129
|
-
{
|
|
140
|
+
x={$tweened_x}
|
|
141
|
+
y={$tweened_y}
|
|
130
142
|
{transform}
|
|
131
143
|
text-anchor={textAnchor}
|
|
132
144
|
{...$$restProps}
|
|
133
145
|
class={cls($$props.fill === undefined && 'fill-surface-content', $$props.class)}
|
|
134
146
|
>
|
|
135
147
|
{#each wordsByLines as line, index}
|
|
136
|
-
<tspan {
|
|
148
|
+
<tspan x={$tweened_x} dy={index === 0 ? startDy : lineHeight}>
|
|
137
149
|
{line.words.join(' ')}
|
|
138
150
|
</tspan>
|
|
139
151
|
{/each}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { spring as springStore, tweened as tweenedStore } from 'svelte/motion';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
5
6
|
value?: string | number | undefined;
|
|
6
7
|
width?: number | undefined;
|
|
7
8
|
x?: string | number | undefined;
|
|
9
|
+
initialX?: string | number | undefined;
|
|
8
10
|
y?: string | number | undefined;
|
|
11
|
+
initialY?: string | number | undefined;
|
|
9
12
|
dx?: string | number | undefined;
|
|
10
13
|
dy?: string | number | undefined;
|
|
11
14
|
lineHeight?: string | undefined;
|
|
@@ -14,6 +17,8 @@ declare const __propDef: {
|
|
|
14
17
|
textAnchor?: "start" | "end" | "middle" | "inherit" | undefined;
|
|
15
18
|
verticalAnchor?: "start" | "end" | "middle" | "inherit" | undefined;
|
|
16
19
|
rotate?: number | undefined;
|
|
20
|
+
spring?: boolean | Parameters<typeof springStore>[1];
|
|
21
|
+
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
17
22
|
};
|
|
18
23
|
events: {
|
|
19
24
|
[evt: string]: CustomEvent<any>;
|
|
@@ -23,9 +23,9 @@ import { cls, sortFunc } from 'svelte-ux';
|
|
|
23
23
|
import { Svg, Html } from './Chart.svelte';
|
|
24
24
|
import ChartClipPath from './ChartClipPath.svelte';
|
|
25
25
|
import Voronoi from './Voronoi.svelte';
|
|
26
|
-
import { localPoint } from '../utils/event';
|
|
27
|
-
import { isScaleBand, scaleInvert } from '../utils/scales';
|
|
28
|
-
import { quadtreeRects } from '../utils/quadtree';
|
|
26
|
+
import { localPoint } from '../utils/event.js';
|
|
27
|
+
import { isScaleBand, scaleInvert } from '../utils/scales.js';
|
|
28
|
+
import { quadtreeRects } from '../utils/quadtree.js';
|
|
29
29
|
const { flatData, x, xScale, xGet, xRange, y, yScale, yGet, yRange, width, height, padding } = getContext('LayerCake');
|
|
30
30
|
/*
|
|
31
31
|
TODO: Defaults to consider (if possible to detect scale type, which might not be possible)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import * as d3 from 'd3-hierarchy';
|
|
3
|
-
import { aspectTile } from '../utils/treemap';
|
|
3
|
+
import { aspectTile } from '../utils/treemap.js';
|
|
4
4
|
const { data, width, height } = getContext('LayerCake');
|
|
5
5
|
export let tile = d3.treemapSquarify;
|
|
6
6
|
export let padding = 0;
|
|
@@ -27,7 +27,10 @@ $: tileFunc =
|
|
|
27
27
|
: tile;
|
|
28
28
|
let treemap;
|
|
29
29
|
$: {
|
|
30
|
-
treemap = d3
|
|
30
|
+
treemap = d3
|
|
31
|
+
.treemap()
|
|
32
|
+
.size([$width, $height])
|
|
33
|
+
.tile(aspectTile(tileFunc, $width, $height));
|
|
31
34
|
if (padding) {
|
|
32
35
|
treemap.padding(padding);
|
|
33
36
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>import { getContext, createEventDispatcher } from 'svelte';
|
|
2
|
-
import { motionStore } from '../stores/motionStore';
|
|
2
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
3
3
|
const { width, height, padding } = getContext('LayerCake');
|
|
4
4
|
export let mode = 'svg';
|
|
5
|
-
export let translateOnScale;
|
|
5
|
+
export let translateOnScale = false;
|
|
6
6
|
export let spring = undefined;
|
|
7
7
|
export let tweened = undefined;
|
|
8
8
|
export let disablePointer = false;
|
|
@@ -31,14 +31,14 @@ export function decrease() {
|
|
|
31
31
|
export function translateCenter() {
|
|
32
32
|
$translate = {
|
|
33
33
|
x: 0,
|
|
34
|
-
y: 0
|
|
34
|
+
y: 0,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
export function zoomTo(center, rect) {
|
|
38
38
|
// TODO: Improve with geo/projection
|
|
39
39
|
$translate = {
|
|
40
40
|
x: $width / 2 - center.x,
|
|
41
|
-
y: $height / 2 - center.y
|
|
41
|
+
y: $height / 2 - center.y,
|
|
42
42
|
};
|
|
43
43
|
if (rect) {
|
|
44
44
|
$scale = $width < $height ? $width / rect.width : $height / rect.height;
|
|
@@ -63,7 +63,7 @@ function onMouseMove(e) {
|
|
|
63
63
|
const deltaY = endPoint.y - startPoint.y;
|
|
64
64
|
translate.set({
|
|
65
65
|
x: startTranslate.x + deltaX / (mode === 'manual' ? 1 : $scale),
|
|
66
|
-
y: startTranslate.y + deltaY / (mode === 'manual' ? 1 : $scale)
|
|
66
|
+
y: startTranslate.y + deltaY / (mode === 'manual' ? 1 : $scale),
|
|
67
67
|
}, spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
68
68
|
if (!moved) {
|
|
69
69
|
// If dragged beyond threshold, disable click propagation
|
|
@@ -103,7 +103,7 @@ function onWheel(e) {
|
|
|
103
103
|
else if (scroll === 'translate') {
|
|
104
104
|
translate.update((startTranslate) => ({
|
|
105
105
|
x: startTranslate.x + -e.deltaX / (mode === 'manual' ? 1 : $scale),
|
|
106
|
-
y: startTranslate.y + -e.deltaY / (mode === 'manual' ? 1 : $scale)
|
|
106
|
+
y: startTranslate.y + -e.deltaY / (mode === 'manual' ? 1 : $scale),
|
|
107
107
|
}), spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -118,11 +118,11 @@ function scaleTo(value, point, options = undefined) {
|
|
|
118
118
|
// Translate towards point (ex. mouse cursor/center) while zooming in/out
|
|
119
119
|
const invertTransformPoint = {
|
|
120
120
|
x: (point.x - $translate.x) / currentScale,
|
|
121
|
-
y: (point.y - $translate.y) / currentScale
|
|
121
|
+
y: (point.y - $translate.y) / currentScale,
|
|
122
122
|
};
|
|
123
123
|
const newTranslate = {
|
|
124
124
|
x: point.x - invertTransformPoint.x * newScale,
|
|
125
|
-
y: point.y - invertTransformPoint.y * newScale
|
|
125
|
+
y: point.y - invertTransformPoint.y * newScale,
|
|
126
126
|
};
|
|
127
127
|
translate.set(newTranslate, options);
|
|
128
128
|
}
|
|
@@ -136,26 +136,26 @@ function localPoint(svgEl, e) {
|
|
|
136
136
|
point = point.matrixTransform(screenCTM?.inverse());
|
|
137
137
|
return {
|
|
138
138
|
x: point.x,
|
|
139
|
-
y: point.y
|
|
139
|
+
y: point.y,
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
143
143
|
return {
|
|
144
144
|
x: e.clientX,
|
|
145
|
-
y: e.clientY
|
|
145
|
+
y: e.clientY,
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
$: center = { x: $width / 2, y: $height / 2 };
|
|
150
150
|
$: viewportCenter = {
|
|
151
151
|
x: center.x - $translate.x,
|
|
152
|
-
y: center.y - $translate.y
|
|
152
|
+
y: center.y - $translate.y,
|
|
153
153
|
};
|
|
154
154
|
let transform = '';
|
|
155
155
|
$: if (mode === 'svg') {
|
|
156
156
|
const newTranslate = {
|
|
157
157
|
x: $translate.x * $scale + center.x - center.x * $scale,
|
|
158
|
-
y: $translate.y * $scale + center.y - center.y * $scale
|
|
158
|
+
y: $translate.y * $scale + center.y - center.y * $scale,
|
|
159
159
|
};
|
|
160
160
|
transform = `translate(${newTranslate.x},${newTranslate.y}) scale(${$scale})`;
|
|
161
161
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { motionStore } from '../stores/motionStore';
|
|
2
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
mode?: "svg" | "manual" | undefined;
|
|
6
|
-
translateOnScale
|
|
6
|
+
translateOnScale?: boolean | undefined;
|
|
7
7
|
spring?: boolean | Parameters<typeof motionStore>[1]['spring'];
|
|
8
8
|
tweened?: boolean | Parameters<typeof motionStore>[1]['tweened'];
|
|
9
9
|
disablePointer?: boolean | undefined;
|
|
@@ -15,8 +15,10 @@ export { default as ColorRamp } from './ColorRamp.svelte';
|
|
|
15
15
|
export { default as Frame } from './Frame.svelte';
|
|
16
16
|
export { default as GeoCircle } from './GeoCircle.svelte';
|
|
17
17
|
export { default as GeoContext, geoContext } from './GeoContext.svelte';
|
|
18
|
+
export { default as GeoEdgeFade } from './GeoEdgeFade.svelte';
|
|
18
19
|
export { default as GeoPath } from './GeoPath.svelte';
|
|
19
20
|
export { default as GeoPoint } from './GeoPoint.svelte';
|
|
21
|
+
export { default as GeoSpline } from './GeoSpline.svelte';
|
|
20
22
|
export { default as GeoTile } from './GeoTile.svelte';
|
|
21
23
|
export { default as Graticule } from './Graticule.svelte';
|
|
22
24
|
export { default as Group } from './Group.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -15,8 +15,10 @@ export { default as ColorRamp } from './ColorRamp.svelte';
|
|
|
15
15
|
export { default as Frame } from './Frame.svelte';
|
|
16
16
|
export { default as GeoCircle } from './GeoCircle.svelte';
|
|
17
17
|
export { default as GeoContext, geoContext } from './GeoContext.svelte';
|
|
18
|
+
export { default as GeoEdgeFade } from './GeoEdgeFade.svelte';
|
|
18
19
|
export { default as GeoPath } from './GeoPath.svelte';
|
|
19
20
|
export { default as GeoPoint } from './GeoPoint.svelte';
|
|
21
|
+
export { default as GeoSpline } from './GeoSpline.svelte';
|
|
20
22
|
export { default as GeoTile } from './GeoTile.svelte';
|
|
21
23
|
export { default as Graticule } from './Graticule.svelte';
|
|
22
24
|
export { default as Group } from './Group.svelte';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Svg, Html } from 'layercake';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './utils';
|
|
2
|
+
export * from './components/index.js';
|
|
3
|
+
export * from './utils/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Svg, Html } from 'layercake';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './utils';
|
|
2
|
+
export * from './components/index.js';
|
|
3
|
+
export * from './utils/index.js';
|
package/dist/utils/genData.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addMinutes, startOfDay, startOfToday, subDays } from 'date-fns';
|
|
2
|
-
import { degreesToRadians, radiansToDegrees } from './math';
|
|
2
|
+
import { degreesToRadians, radiansToDegrees } from './math.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get random number between min (inclusive) and max (exclusive)
|
|
5
5
|
* see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#getting_a_random_number_between_0_inclusive_and_1_exclusive
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './geo';
|
|
2
|
-
export * from './graph';
|
|
3
|
-
export * from './hierarchy';
|
|
4
|
-
export * from './math';
|
|
5
|
-
export * from './pivot';
|
|
6
|
-
export * from './stack';
|
|
7
|
-
export * from './ticks';
|
|
1
|
+
export * from './geo.js';
|
|
2
|
+
export * from './graph.js';
|
|
3
|
+
export * from './hierarchy.js';
|
|
4
|
+
export * from './math.js';
|
|
5
|
+
export * from './pivot.js';
|
|
6
|
+
export * from './stack.js';
|
|
7
|
+
export * from './ticks.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './geo';
|
|
2
|
-
export * from './graph';
|
|
3
|
-
export * from './hierarchy';
|
|
4
|
-
export * from './math';
|
|
5
|
-
export * from './pivot';
|
|
6
|
-
export * from './stack';
|
|
7
|
-
export * from './ticks';
|
|
1
|
+
export * from './geo.js';
|
|
2
|
+
export * from './graph.js';
|
|
3
|
+
export * from './hierarchy.js';
|
|
4
|
+
export * from './math.js';
|
|
5
|
+
export * from './pivot.js';
|
|
6
|
+
export * from './stack.js';
|
|
7
|
+
export * from './ticks.js';
|
package/dist/utils/rect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { derived } from 'svelte/store';
|
|
2
2
|
import { max, min } from 'd3-array';
|
|
3
|
-
import { groupScaleBand, isScaleBand } from './scales';
|
|
3
|
+
import { groupScaleBand, isScaleBand } from './scales.js';
|
|
4
4
|
// TOOD: Pass in overrides for `x` and `y` accessors
|
|
5
5
|
export function createDimensionGetter(context, options) {
|
|
6
6
|
const { flatData, xGet, yGet, xRange, yRange, xScale, yScale, x: xAccessor, y: yAccessor, } = context;
|
package/dist/utils/scales.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
2
|
import { tweened, spring } from 'svelte/motion';
|
|
3
|
-
import { type MotionOptions } from '../stores/motionStore';
|
|
3
|
+
import { type MotionOptions } from '../stores/motionStore.js';
|
|
4
4
|
import { type ScaleBand } from 'd3-scale';
|
|
5
5
|
/**
|
|
6
6
|
* Implemenation for missing `scaleBand().invert()`
|
package/dist/utils/scales.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { derived } from 'svelte/store';
|
|
2
2
|
import { tweened, spring } from 'svelte/motion';
|
|
3
|
-
import { motionStore } from '../stores/motionStore';
|
|
3
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
4
4
|
import { scaleBand } from 'd3-scale';
|
|
5
5
|
import { unique } from 'svelte-ux/utils/array';
|
|
6
6
|
/**
|
package/dist/utils/stack.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { flatGroup, max, rollup, sum } from 'd3-array';
|
|
2
2
|
import { stack, stackOffsetNone, stackOrderNone } from 'd3-shape';
|
|
3
|
-
import { pivotWider } from './pivot';
|
|
3
|
+
import { pivotWider } from './pivot.js';
|
|
4
4
|
export function createStackData(data, options) {
|
|
5
5
|
if (options.groupBy) {
|
|
6
6
|
// Group then Stack (if needed)
|
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.
|
|
7
|
+
"version": "0.32.1",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@changesets/cli": "^2.27.1",
|
|
10
10
|
"@mdi/js": "^7.4.47",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"lodash-es": "^4.17.21",
|
|
84
84
|
"posthog-js": "^1.108.3",
|
|
85
85
|
"shapefile": "^0.6.6",
|
|
86
|
-
"svelte-ux": "
|
|
86
|
+
"svelte-ux": "^0.61.2",
|
|
87
87
|
"topojson-client": "^3.1.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|