layerchart 0.5.1 → 0.6.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/components/Arc.svelte +2 -2
- package/components/Area.svelte +2 -2
- package/components/Bounds.svelte +5 -5
- package/components/Bounds.svelte.d.ts +3 -0
- package/components/Circle.svelte +6 -6
- package/components/Circle.svelte.d.ts +2 -2
- package/components/Group.svelte +3 -3
- package/components/Line.svelte +5 -5
- package/components/Link.svelte +2 -2
- package/components/Pack.svelte +19 -0
- package/components/Pack.svelte.d.ts +23 -0
- package/components/Path.svelte +2 -2
- package/components/Pie.svelte +2 -2
- package/components/Rect.svelte +5 -5
- package/components/Treemap.svelte +4 -18
- package/components/Treemap.svelte.d.ts +2 -3
- package/components/Zoom.svelte +20 -6
- package/components/Zoom.svelte.d.ts +20 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/package.json +2 -1
- package/stores/motionStore.d.ts +5 -4
- package/stores/motionStore.js +1 -1
- package/utils/scales.d.ts +6 -5
- package/utils/scales.js +9 -8
package/components/Arc.svelte
CHANGED
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
import { getContext } from 'svelte';
|
|
16
16
|
import { arc as d3arc } from 'd3-shape';
|
|
17
17
|
import { scaleLinear } from 'd3-scale';
|
|
18
|
-
import {
|
|
18
|
+
import { motionStore } from '../stores/motionStore';
|
|
19
19
|
import { degreesToRadians } from '../utils/math';
|
|
20
20
|
export let spring = undefined;
|
|
21
21
|
export let tweened = undefined;
|
|
22
22
|
export let value = 0;
|
|
23
|
-
let tweened_value =
|
|
23
|
+
let tweened_value = motionStore(value, { spring, tweened });
|
|
24
24
|
$: tweened_value.set(value);
|
|
25
25
|
export let domain = [0, 100];
|
|
26
26
|
/**
|
package/components/Area.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { area as d3Area } from 'd3-shape';
|
|
3
3
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
4
|
-
import {
|
|
4
|
+
import { motionStore } from '../stores/motionStore';
|
|
5
5
|
import Path from './Path.svelte';
|
|
6
6
|
const { data: contextData, xGet, yGet, yRange } = getContext('LayerCake');
|
|
7
7
|
// Properties to override what is used from context
|
|
@@ -18,7 +18,7 @@ export let color = 'var(--color-blue-500)';
|
|
|
18
18
|
export let opacity = 0.3;
|
|
19
19
|
export let line = false;
|
|
20
20
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
21
|
-
$: tweened_d =
|
|
21
|
+
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
22
22
|
$: {
|
|
23
23
|
const path = d3Area()
|
|
24
24
|
.x(x ?? $xGet)
|
package/components/Bounds.svelte
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { cubicOut } from 'svelte/easing';
|
|
3
2
|
import { scaleLinear } from 'd3-scale';
|
|
4
|
-
import {
|
|
3
|
+
import { motionScale } from '../utils/scales';
|
|
5
4
|
const { width, height } = getContext('LayerCake');
|
|
6
5
|
export let domain;
|
|
7
6
|
export let range;
|
|
8
|
-
|
|
7
|
+
export let spring = undefined;
|
|
8
|
+
export let tweened = undefined;
|
|
9
9
|
function getExtents(extents, axis, fallback) {
|
|
10
10
|
const resolvedExtents = typeof extents === 'function' ? extents({ width: $width, height: $height }) : extents;
|
|
11
11
|
return [
|
|
@@ -13,10 +13,10 @@ function getExtents(extents, axis, fallback) {
|
|
|
13
13
|
resolvedExtents?.[axis + '1'] ?? fallback // x1 or y1, fallback as $width or $height
|
|
14
14
|
];
|
|
15
15
|
}
|
|
16
|
-
const xScale =
|
|
16
|
+
const xScale = motionScale(scaleLinear, { spring, tweened });
|
|
17
17
|
$: xScale.domain(getExtents(domain, 'x', $width));
|
|
18
18
|
$: xScale.range(getExtents(range, 'x', $width));
|
|
19
|
-
const yScale =
|
|
19
|
+
const yScale = motionScale(scaleLinear, { spring, tweened });
|
|
20
20
|
$: yScale.domain(getExtents(domain, 'y', $height));
|
|
21
21
|
$: yScale.range(getExtents(range, 'y', $height));
|
|
22
22
|
</script>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { motionScale } from '../utils/scales';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
domain: {
|
|
@@ -29,6 +30,8 @@ declare const __propDef: {
|
|
|
29
30
|
x1: number;
|
|
30
31
|
y1: number;
|
|
31
32
|
});
|
|
33
|
+
spring?: boolean | Parameters<typeof motionScale>[1]['spring'];
|
|
34
|
+
tweened?: boolean | Parameters<typeof motionScale>[1]['tweened'];
|
|
32
35
|
};
|
|
33
36
|
events: {
|
|
34
37
|
[evt: string]: CustomEvent<any>;
|
package/components/Circle.svelte
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
export let cx;
|
|
3
|
-
export let cy;
|
|
1
|
+
<script>import { motionStore } from '../stores/motionStore';
|
|
2
|
+
export let cx = 0;
|
|
3
|
+
export let cy = 0;
|
|
4
4
|
export let r;
|
|
5
5
|
export let spring = undefined;
|
|
6
6
|
export let tweened = undefined;
|
|
7
|
-
let tweened_cx =
|
|
8
|
-
let tweened_cy =
|
|
9
|
-
let tweened_r =
|
|
7
|
+
let tweened_cx = motionStore(cx, { spring, tweened });
|
|
8
|
+
let tweened_cy = motionStore(cy, { spring, tweened });
|
|
9
|
+
let tweened_r = motionStore(r, { spring, tweened });
|
|
10
10
|
$: tweened_cx.set(cx);
|
|
11
11
|
$: tweened_cy.set(cy);
|
|
12
12
|
$: tweened_r.set(r);
|
|
@@ -3,8 +3,8 @@ import type { spring as springStore, tweened as tweenedStore } from 'svelte/moti
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
|
-
cx
|
|
7
|
-
cy
|
|
6
|
+
cx?: number;
|
|
7
|
+
cy?: number;
|
|
8
8
|
r: number;
|
|
9
9
|
spring?: boolean | Parameters<typeof springStore>[1];
|
|
10
10
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
package/components/Group.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import {
|
|
2
|
+
import { motionStore } from '../stores/motionStore';
|
|
3
3
|
const { width, height } = getContext('LayerCake');
|
|
4
4
|
/**
|
|
5
5
|
* Translate x
|
|
@@ -15,8 +15,8 @@ export let y = undefined;
|
|
|
15
15
|
export let center = false;
|
|
16
16
|
export let spring = undefined;
|
|
17
17
|
export let tweened = undefined;
|
|
18
|
-
let tweened_x =
|
|
19
|
-
let tweened_y =
|
|
18
|
+
let tweened_x = motionStore(x, { spring, tweened });
|
|
19
|
+
let tweened_y = motionStore(y, { spring, tweened });
|
|
20
20
|
$: tweened_x.set(x);
|
|
21
21
|
$: tweened_y.set(y);
|
|
22
22
|
let transform = undefined;
|
package/components/Line.svelte
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { motionStore } from '../stores/motionStore';
|
|
2
2
|
export let x1;
|
|
3
3
|
export let y1;
|
|
4
4
|
export let x2;
|
|
5
5
|
export let y2;
|
|
6
6
|
export let spring = undefined;
|
|
7
7
|
export let tweened = undefined;
|
|
8
|
-
let tweened_x1 =
|
|
9
|
-
let tweened_y1 =
|
|
10
|
-
let tweened_x2 =
|
|
11
|
-
let tweened_y2 =
|
|
8
|
+
let tweened_x1 = motionStore(x1, { spring, tweened });
|
|
9
|
+
let tweened_y1 = motionStore(y1, { spring, tweened });
|
|
10
|
+
let tweened_x2 = motionStore(x2, { spring, tweened });
|
|
11
|
+
let tweened_y2 = motionStore(y2, { spring, tweened });
|
|
12
12
|
$: tweened_x1.set(x1);
|
|
13
13
|
$: tweened_y1.set(y1);
|
|
14
14
|
$: tweened_x2.set(x2);
|
package/components/Link.svelte
CHANGED
|
@@ -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 {
|
|
3
|
+
import { motionStore } from '../stores/motionStore';
|
|
4
4
|
// Properties to override what is used from context
|
|
5
5
|
export let data = undefined; // TODO: Update Type
|
|
6
6
|
export let orientation = 'horizontal';
|
|
@@ -17,7 +17,7 @@ export let tweened = undefined;
|
|
|
17
17
|
export let color = 'black';
|
|
18
18
|
export let width = undefined;
|
|
19
19
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
20
|
-
$: tweened_d =
|
|
20
|
+
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
21
21
|
$: {
|
|
22
22
|
orientation; // subscribe to orientation changes to link is update
|
|
23
23
|
const link = d3Link(curve).source(source).target(target).x(x).y(y);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>import { getContext } from 'svelte';
|
|
2
|
+
import { pack as d3Pack } from 'd3-hierarchy';
|
|
3
|
+
const { data, width, height } = getContext('LayerCake');
|
|
4
|
+
export let size = undefined;
|
|
5
|
+
/**
|
|
6
|
+
* see: https://github.com/d3/d3-hierarchy#pack_padding
|
|
7
|
+
*/
|
|
8
|
+
export let padding = undefined;
|
|
9
|
+
let pack;
|
|
10
|
+
$: {
|
|
11
|
+
pack = d3Pack().size(size ?? [$width, $height]);
|
|
12
|
+
if (padding) {
|
|
13
|
+
pack.padding(padding);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
$: packData = pack($data);
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<slot nodes={packData.descendants()} />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
size?: [number, number] | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* see: https://github.com/d3/d3-hierarchy#pack_padding
|
|
7
|
+
*/ padding?: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {
|
|
14
|
+
nodes: import("d3-hierarchy").HierarchyCircularNode<unknown>[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type PackProps = typeof __propDef.props;
|
|
19
|
+
export declare type PackEvents = typeof __propDef.events;
|
|
20
|
+
export declare type PackSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Pack extends SvelteComponentTyped<PackProps, PackEvents, PackSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
package/components/Path.svelte
CHANGED
|
@@ -6,7 +6,7 @@ import { getContext } from 'svelte';
|
|
|
6
6
|
import { line as d3Line } from 'd3-shape';
|
|
7
7
|
// import { interpolateString } from 'd3-interpolate';
|
|
8
8
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
9
|
-
import {
|
|
9
|
+
import { motionStore } from '../stores/motionStore';
|
|
10
10
|
const { data: contextData, xGet, yGet, zGet } = getContext('LayerCake');
|
|
11
11
|
// Properties to override what is used from context
|
|
12
12
|
export let data = undefined; // TODO: Update Type
|
|
@@ -19,7 +19,7 @@ export let defined = undefined;
|
|
|
19
19
|
export let color = 'black';
|
|
20
20
|
export let width = undefined;
|
|
21
21
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
22
|
-
$: tweened_d =
|
|
22
|
+
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
23
23
|
$: {
|
|
24
24
|
const path = d3Line()
|
|
25
25
|
.x(x ?? $xGet)
|
package/components/Pie.svelte
CHANGED
|
@@ -3,7 +3,7 @@ import { pie as d3pie } from 'd3-shape';
|
|
|
3
3
|
import Arc from './Arc.svelte';
|
|
4
4
|
import Group from './Group.svelte';
|
|
5
5
|
import { degreesToRadians } from '../utils/math';
|
|
6
|
-
import {
|
|
6
|
+
import { motionStore } from '../stores/motionStore';
|
|
7
7
|
/*
|
|
8
8
|
TODO:
|
|
9
9
|
- [ ] Offset (always, on hover)
|
|
@@ -48,7 +48,7 @@ export let tweened = undefined;
|
|
|
48
48
|
export let offset = 0;
|
|
49
49
|
const { data: contextData, x, y, xRange, rGet, config } = getContext('LayerCake');
|
|
50
50
|
$: resolved_endAngle = endAngle ?? degreesToRadians($config.xRange ? $xRange[1] : range[1]);
|
|
51
|
-
let tweened_endAngle =
|
|
51
|
+
let tweened_endAngle = motionStore(0, { spring, tweened });
|
|
52
52
|
$: tweened_endAngle.set(resolved_endAngle);
|
|
53
53
|
$: pie = d3pie()
|
|
54
54
|
.startAngle(startAngle ?? degreesToRadians($config.xRange ? $xRange[0] : range[0]))
|
package/components/Rect.svelte
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { motionStore } from '../stores/motionStore';
|
|
2
2
|
export let x = 0;
|
|
3
3
|
export let y = 0;
|
|
4
4
|
export let width;
|
|
5
5
|
export let height;
|
|
6
6
|
export let spring = undefined;
|
|
7
7
|
export let tweened = undefined;
|
|
8
|
-
let tweened_x =
|
|
9
|
-
let tweened_y =
|
|
10
|
-
let tweened_width =
|
|
11
|
-
let tweened_height =
|
|
8
|
+
let tweened_x = motionStore(x, { spring, tweened });
|
|
9
|
+
let tweened_y = motionStore(y, { spring, tweened });
|
|
10
|
+
let tweened_width = motionStore(width, { spring, tweened });
|
|
11
|
+
let tweened_height = motionStore(height, { spring, tweened });
|
|
12
12
|
$: tweened_x.set(x);
|
|
13
13
|
$: tweened_y.set(y);
|
|
14
14
|
$: tweened_width.set(width);
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
<script
|
|
2
|
-
* TODO:
|
|
3
|
-
* - [ ] Improve zoomable nested (apply extent ratio? const extentRatio = ($extents.y1 - $extents.y0) / $height;
|
|
4
|
-
*/
|
|
5
|
-
import { getContext } from 'svelte';
|
|
1
|
+
<script>import { getContext } from 'svelte';
|
|
6
2
|
import * as d3 from 'd3-hierarchy';
|
|
7
|
-
import { group } from 'd3-array';
|
|
8
3
|
import { aspectTile } from '../utils/treemap';
|
|
9
4
|
const { data, width, height } = getContext('LayerCake');
|
|
10
5
|
export let tile = d3.treemapSquarify;
|
|
@@ -15,7 +10,6 @@ export let paddingTop = 0;
|
|
|
15
10
|
export let paddingBottom = 0;
|
|
16
11
|
export let paddingLeft = undefined;
|
|
17
12
|
export let paddingRight = undefined;
|
|
18
|
-
export let nodeKey = (node, i) => i;
|
|
19
13
|
export let selected = null;
|
|
20
14
|
$: tileFunc =
|
|
21
15
|
tile === 'squarify'
|
|
@@ -56,17 +50,9 @@ $: {
|
|
|
56
50
|
treemap.paddingRight(paddingRight);
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
|
-
$:
|
|
53
|
+
$: treemapData = treemap($data);
|
|
60
54
|
// TODO: Remove selected
|
|
61
|
-
$: selected =
|
|
62
|
-
// group nodes by depth so can be rendered lowest to highest, to stack properly
|
|
63
|
-
$: nodesByDepth = group(root, (d) => d.depth);
|
|
55
|
+
$: selected = treemapData; // set initial selection
|
|
64
56
|
</script>
|
|
65
57
|
|
|
66
|
-
{
|
|
67
|
-
<g>
|
|
68
|
-
{#each nodes as node, i (nodeKey(node, i))}
|
|
69
|
-
<slot name="node" {node} />
|
|
70
|
-
{/each}
|
|
71
|
-
</g>
|
|
72
|
-
{/each}
|
|
58
|
+
<slot nodes={treemapData.descendants()} />
|
|
@@ -10,15 +10,14 @@ declare const __propDef: {
|
|
|
10
10
|
paddingBottom?: number;
|
|
11
11
|
paddingLeft?: any;
|
|
12
12
|
paddingRight?: any;
|
|
13
|
-
nodeKey?: (node: d3.HierarchyNode<any>, i: number) => any;
|
|
14
13
|
selected?: any;
|
|
15
14
|
};
|
|
16
15
|
events: {
|
|
17
16
|
[evt: string]: CustomEvent<any>;
|
|
18
17
|
};
|
|
19
18
|
slots: {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
default: {
|
|
20
|
+
nodes: any;
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
23
|
};
|
package/components/Zoom.svelte
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import {
|
|
2
|
+
import { motionStore } from '../stores/motionStore';
|
|
3
3
|
const { width, height, padding } = getContext('LayerCake');
|
|
4
|
+
export let spring = undefined;
|
|
5
|
+
export let tweened = undefined;
|
|
4
6
|
let dragging = false;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const translate = motionStore({ x: 0, y: 0 }, { spring, tweened });
|
|
8
|
+
const scale = motionStore({ x: 1, y: 1 }, { spring, tweened });
|
|
7
9
|
let startPoint;
|
|
8
10
|
let startTranslate;
|
|
9
11
|
let svgEl = null;
|
|
@@ -29,6 +31,18 @@ export function translateCenter() {
|
|
|
29
31
|
y: 0
|
|
30
32
|
};
|
|
31
33
|
}
|
|
34
|
+
export function zoomTo(newTranslate, newScale) {
|
|
35
|
+
$translate = {
|
|
36
|
+
x: $width / 2 - newTranslate.x,
|
|
37
|
+
y: $height / 2 - newTranslate.y
|
|
38
|
+
};
|
|
39
|
+
if (newScale) {
|
|
40
|
+
$scale = {
|
|
41
|
+
x: Math.min($width, $height) / newScale.x,
|
|
42
|
+
y: Math.min($width, $height) / newScale.y
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
32
46
|
function handleMouseDown(e) {
|
|
33
47
|
dragging = true;
|
|
34
48
|
svgEl = e.target.ownerSVGElement;
|
|
@@ -51,7 +65,7 @@ function handleMouseMove(e) {
|
|
|
51
65
|
translate.set({
|
|
52
66
|
x: startTranslate.x + deltaX / $scale.x,
|
|
53
67
|
y: startTranslate.y + deltaY / $scale.y
|
|
54
|
-
}, { hard: true });
|
|
68
|
+
}, spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
55
69
|
}
|
|
56
70
|
function handleDoubleClick() {
|
|
57
71
|
increase();
|
|
@@ -65,7 +79,7 @@ function handleWheel(e) {
|
|
|
65
79
|
scale.set({
|
|
66
80
|
x: $scale.x * scaleBy,
|
|
67
81
|
y: $scale.y * scaleBy
|
|
68
|
-
}, { hard: true });
|
|
82
|
+
}, spring ? { hard: true } : tweened ? { duration: 0 } : undefined);
|
|
69
83
|
}
|
|
70
84
|
function localPoint(svgEl, e) {
|
|
71
85
|
const screenCTM = svgEl.getScreenCTM();
|
|
@@ -104,5 +118,5 @@ $: newTranslate = {
|
|
|
104
118
|
fill="transparent"
|
|
105
119
|
/>
|
|
106
120
|
<g transform="translate({newTranslate.x},{newTranslate.y}) scale({$scale.x},{$scale.y})">
|
|
107
|
-
<slot />
|
|
121
|
+
<slot scale={$scale} />
|
|
108
122
|
</g>
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { motionStore } from '../stores/motionStore';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
5
|
+
spring?: boolean | Parameters<typeof motionStore>[1]['spring'];
|
|
6
|
+
tweened?: boolean | Parameters<typeof motionStore>[1]['tweened'];
|
|
4
7
|
reset?: () => void;
|
|
5
8
|
increase?: () => void;
|
|
6
9
|
decrease?: () => void;
|
|
7
10
|
translateCenter?: () => void;
|
|
11
|
+
zoomTo?: (newTranslate: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}, newScale?: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}) => void;
|
|
8
18
|
};
|
|
9
19
|
events: {
|
|
10
20
|
[evt: string]: CustomEvent<any>;
|
|
11
21
|
};
|
|
12
22
|
slots: {
|
|
13
|
-
default: {
|
|
23
|
+
default: {
|
|
24
|
+
scale: any;
|
|
25
|
+
};
|
|
14
26
|
};
|
|
15
27
|
};
|
|
16
28
|
export declare type ZoomProps = typeof __propDef.props;
|
|
@@ -21,5 +33,12 @@ export default class Zoom extends SvelteComponentTyped<ZoomProps, ZoomEvents, Zo
|
|
|
21
33
|
get increase(): () => void;
|
|
22
34
|
get decrease(): () => void;
|
|
23
35
|
get translateCenter(): () => void;
|
|
36
|
+
get zoomTo(): (newTranslate: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
}, newScale?: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}) => void;
|
|
24
43
|
}
|
|
25
44
|
export {};
|
package/components/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { default as Labels } from './Labels.svelte';
|
|
|
19
19
|
export { default as Line } from './Line.svelte';
|
|
20
20
|
export { default as LinearGradient } from './LinearGradient.svelte';
|
|
21
21
|
export { default as Link } from './Link.svelte';
|
|
22
|
+
export { default as Pack } from './Pack.svelte';
|
|
22
23
|
export { default as Partition } from './Partition.svelte';
|
|
23
24
|
export { default as Path } from './Path.svelte';
|
|
24
25
|
export { default as Pattern } from './Pattern.svelte';
|
package/components/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export { default as Labels } from './Labels.svelte';
|
|
|
19
19
|
export { default as Line } from './Line.svelte';
|
|
20
20
|
export { default as LinearGradient } from './LinearGradient.svelte';
|
|
21
21
|
export { default as Link } from './Link.svelte';
|
|
22
|
+
export { default as Pack } from './Pack.svelte';
|
|
22
23
|
export { default as Partition } from './Partition.svelte';
|
|
23
24
|
export { default as Path } from './Path.svelte';
|
|
24
25
|
export { default as Pattern } from './Pattern.svelte';
|
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.6.1",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@rollup/plugin-dsv": "^2.0.3",
|
|
9
9
|
"@sveltejs/adapter-vercel": "^1.0.0-next.58",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"./components/Line.svelte": "./components/Line.svelte",
|
|
71
71
|
"./components/LinearGradient.svelte": "./components/LinearGradient.svelte",
|
|
72
72
|
"./components/Link.svelte": "./components/Link.svelte",
|
|
73
|
+
"./components/Pack.svelte": "./components/Pack.svelte",
|
|
73
74
|
"./components/Partition.svelte": "./components/Partition.svelte",
|
|
74
75
|
"./components/Path.svelte": "./components/Path.svelte",
|
|
75
76
|
"./components/Pattern.svelte": "./components/Pattern.svelte",
|
package/stores/motionStore.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { spring, tweened } from 'svelte/motion';
|
|
2
|
+
export declare type MotionOptions = {
|
|
3
|
+
spring?: boolean | Parameters<typeof spring>[1];
|
|
4
|
+
tweened?: boolean | Parameters<typeof tweened>[1];
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
7
|
* Convenient wrapper to create a motion store (spring(), tweened()) based on properties, or fall back to basic writable() store
|
|
4
8
|
*/
|
|
5
|
-
export declare function
|
|
6
|
-
spring?: boolean | Parameters<typeof spring>[1];
|
|
7
|
-
tweened?: boolean | Parameters<typeof tweened>[1];
|
|
8
|
-
}): import("svelte/motion").Tweened<unknown> | import("svelte/motion").Spring<any> | import("svelte/store").Writable<any>;
|
|
9
|
+
export declare function motionStore(value: any, options: MotionOptions): import("svelte/motion").Tweened<unknown> | import("svelte/motion").Spring<any> | import("svelte/store").Writable<any>;
|
package/stores/motionStore.js
CHANGED
|
@@ -3,7 +3,7 @@ import { spring, tweened } from 'svelte/motion';
|
|
|
3
3
|
/**
|
|
4
4
|
* Convenient wrapper to create a motion store (spring(), tweened()) based on properties, or fall back to basic writable() store
|
|
5
5
|
*/
|
|
6
|
-
export function
|
|
6
|
+
export function motionStore(value, options) {
|
|
7
7
|
if (options.spring) {
|
|
8
8
|
return spring(value, options.spring === true ? undefined : options.spring);
|
|
9
9
|
}
|
package/utils/scales.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { tweened
|
|
1
|
+
import { tweened } from 'svelte/motion';
|
|
2
|
+
import { MotionOptions } from '../stores/motionStore';
|
|
2
3
|
/**
|
|
3
4
|
* Implemenation for missing `scaleBand().invert()`
|
|
4
5
|
*
|
|
@@ -18,10 +19,10 @@ export declare function tweenedScale(scale: any, tweenedOptions?: Parameters<typ
|
|
|
18
19
|
range: (values: any) => Promise<void>;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Create a store wrapper around a d3-scale which interpolates the domain and/or range using `tweened()` or `spring()` stores. Fallbacks to `writable()` if not interpolating
|
|
22
23
|
*/
|
|
23
|
-
export declare function
|
|
24
|
+
export declare function motionScale(scale: any, options: MotionOptions): {
|
|
24
25
|
subscribe: (this: void, run: import("svelte/store").Subscriber<any>, invalidate?: (value?: any) => void) => import("svelte/store").Unsubscriber;
|
|
25
|
-
domain: (values: any) => Promise<void>;
|
|
26
|
-
range: (values: any) => Promise<void>;
|
|
26
|
+
domain: (values: any) => void | Promise<void>;
|
|
27
|
+
range: (values: any) => void | Promise<void>;
|
|
27
28
|
};
|
package/utils/scales.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { derived } from 'svelte/store';
|
|
2
|
-
import { tweened
|
|
2
|
+
import { tweened } from 'svelte/motion';
|
|
3
|
+
import { motionStore } from '../stores/motionStore';
|
|
3
4
|
/**
|
|
4
5
|
* Implemenation for missing `scaleBand().invert()`
|
|
5
6
|
*
|
|
@@ -44,12 +45,12 @@ export function tweenedScale(scale, tweenedOptions = {}) {
|
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* Create a store wrapper around a d3-scale which interpolates the domain and/or range using `tweened()` or `spring()` stores. Fallbacks to `writable()` if not interpolating
|
|
48
49
|
*/
|
|
49
|
-
export function
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const tweenedScale = derived([
|
|
50
|
+
export function motionScale(scale, options) {
|
|
51
|
+
const domainStore = motionStore(undefined, options);
|
|
52
|
+
const rangeStore = motionStore(undefined, options);
|
|
53
|
+
const tweenedScale = derived([domainStore, rangeStore], ([domain, range]) => {
|
|
53
54
|
const scaleInstance = scale.domain ? scale : scale(); // support `scaleLinear` or `scaleLinear()` (which could have `.interpolate()` and others set)
|
|
54
55
|
if (domain) {
|
|
55
56
|
scaleInstance.domain(domain);
|
|
@@ -61,7 +62,7 @@ export function springScale(scale, springOptions = {}) {
|
|
|
61
62
|
});
|
|
62
63
|
return {
|
|
63
64
|
subscribe: tweenedScale.subscribe,
|
|
64
|
-
domain: (values) =>
|
|
65
|
-
range: (values) =>
|
|
65
|
+
domain: (values) => domainStore.set(values),
|
|
66
|
+
range: (values) => rangeStore.set(values)
|
|
66
67
|
};
|
|
67
68
|
}
|