layerchart 0.15.6 → 0.17.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/README.md +22 -1
- package/dist/components/Arc.svelte +10 -10
- package/dist/components/Arc.svelte.d.ts +2 -1
- package/dist/components/Area.svelte +10 -10
- package/dist/components/AreaStack.svelte +25 -25
- package/dist/components/Axis.svelte +131 -0
- package/dist/components/Axis.svelte.d.ts +25 -0
- package/dist/components/Bars.svelte +30 -71
- package/dist/components/Bars.svelte.d.ts +1 -1
- package/dist/components/Baseline.svelte +20 -20
- package/dist/components/Blur.svelte +7 -7
- package/dist/components/Chart.svelte +46 -40
- package/dist/components/Chart.svelte.d.ts +2 -0
- package/dist/components/ChartClipPath.svelte +7 -7
- package/dist/components/Circle.svelte +7 -7
- package/dist/components/CircleClipPath.svelte +5 -5
- package/dist/components/ClipPath.svelte +4 -4
- package/dist/components/ClipPathUse.svelte +5 -5
- package/dist/components/ConnectedPoints.svelte +16 -16
- package/dist/components/GeoPath.svelte +11 -11
- package/dist/components/GeoPoint.svelte +3 -3
- package/dist/components/GeoTile.svelte +5 -5
- package/dist/components/Graticule.svelte +12 -12
- package/dist/components/Group.svelte +1 -1
- package/dist/components/HighlightLine.svelte +25 -25
- package/dist/components/HighlightRect.svelte +1 -1
- package/dist/components/Labels.svelte +83 -74
- package/dist/components/Labels.svelte.d.ts +4 -3
- package/dist/components/Legend.svelte +59 -59
- package/dist/components/Legend.svelte.d.ts +3 -2
- package/dist/components/Line.svelte +8 -8
- package/dist/components/LinearGradient.svelte +22 -22
- package/dist/components/Link.svelte +10 -10
- package/dist/components/Link.svelte.d.ts +1 -1
- package/dist/components/Pack.svelte.d.ts +2 -2
- package/dist/components/Partition.svelte.d.ts +5 -5
- package/dist/components/Path.svelte +16 -16
- package/dist/components/Pattern.svelte +3 -3
- package/dist/components/Pie.svelte +21 -21
- package/dist/components/Pie.svelte.d.ts +18 -18
- package/dist/components/Points.svelte +14 -14
- package/dist/components/Rect.svelte +8 -8
- package/dist/components/RectClipPath.svelte +5 -5
- package/dist/components/Sankey.svelte.d.ts +2 -2
- package/dist/components/Text.svelte +32 -32
- package/dist/components/Threshold.svelte +25 -25
- package/dist/components/TileImage.svelte +21 -21
- package/dist/components/Tooltip.svelte +25 -25
- package/dist/components/TooltipContext.svelte +80 -78
- package/dist/components/TooltipContext.svelte.d.ts +1 -1
- package/dist/components/TooltipItem.svelte +11 -12
- package/dist/components/TooltipItem.svelte.d.ts +2 -1
- package/dist/components/Tree.svelte.d.ts +9 -9
- package/dist/components/Zoom.svelte +18 -18
- package/dist/components/Zoom.svelte.d.ts +1 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/index.js +1 -2
- package/dist/docs/Blockquote.svelte +2 -2
- package/dist/docs/Blockquote.svelte.d.ts +6 -17
- package/dist/docs/Code.svelte +25 -27
- package/dist/docs/Code.svelte.d.ts +8 -17
- package/dist/docs/GeoDebug.svelte +26 -27
- package/dist/docs/Header1.svelte +2 -3
- package/dist/docs/Header1.svelte.d.ts +5 -14
- package/dist/docs/Layout.svelte +11 -11
- package/dist/docs/Layout.svelte.d.ts +9 -20
- package/dist/docs/Link.svelte +2 -2
- package/dist/docs/Link.svelte.d.ts +5 -14
- package/dist/docs/Preview.svelte +25 -25
- package/dist/docs/Preview.svelte.d.ts +1 -1
- package/dist/docs/RangeField.svelte +18 -18
- package/dist/docs/TilesetField.svelte +13 -13
- package/dist/docs/ViewSourceButton.svelte +42 -0
- package/dist/docs/ViewSourceButton.svelte.d.ts +19 -0
- package/dist/docs/ZoomControls.svelte +40 -41
- package/dist/docs/ZoomControls.svelte.d.ts +2 -2
- package/dist/utils/genData.d.ts +2 -2
- package/dist/utils/quadtree.d.ts +10 -2
- package/dist/utils/quadtree.js +1 -1
- package/dist/utils/rect.d.ts +19 -0
- package/dist/utils/rect.js +97 -0
- package/dist/utils/scales.d.ts +8 -0
- package/dist/utils/scales.js +17 -0
- package/package.json +90 -88
- package/dist/components/AxisX.svelte +0 -43
- package/dist/components/AxisX.svelte.d.ts +0 -37
- package/dist/components/AxisY.svelte +0 -55
- package/dist/components/AxisY.svelte.d.ts +0 -37
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} Header1Props */
|
|
2
|
-
/** @typedef {typeof __propDef.events} Header1Events */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} Header1Slots */
|
|
4
|
-
export default class Header1 extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}> {
|
|
11
|
-
}
|
|
12
|
-
export type Header1Props = typeof __propDef.props;
|
|
13
|
-
export type Header1Events = typeof __propDef.events;
|
|
14
|
-
export type Header1Slots = typeof __propDef.slots;
|
|
15
1
|
import { SvelteComponentTyped } from "svelte";
|
|
16
2
|
declare const __propDef: {
|
|
17
3
|
props: {
|
|
@@ -24,4 +10,9 @@ declare const __propDef: {
|
|
|
24
10
|
default: {};
|
|
25
11
|
};
|
|
26
12
|
};
|
|
13
|
+
export type Header1Props = typeof __propDef.props;
|
|
14
|
+
export type Header1Events = typeof __propDef.events;
|
|
15
|
+
export type Header1Slots = typeof __propDef.slots;
|
|
16
|
+
export default class Header1 extends SvelteComponentTyped<Header1Props, Header1Events, Header1Slots> {
|
|
17
|
+
}
|
|
27
18
|
export {};
|
package/dist/docs/Layout.svelte
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<script context="module">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
// Custom components: https://mdsvex.com/docs#custom-components
|
|
3
|
+
import blockquote from './Blockquote.svelte';
|
|
4
|
+
import a from './Link.svelte';
|
|
5
|
+
import h1 from './Header1.svelte';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export { a, blockquote };
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
|
-
<script>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
<script>"use strict";
|
|
11
|
+
// frontmatter: https://mdsvex.com/docs#frontmatter-1
|
|
12
|
+
// export let name = undefined;
|
|
13
|
+
// export let sourceUrl = undefined;
|
|
14
|
+
// export let docUrl = undefined;
|
|
15
|
+
// export let description = undefined;
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<slot />
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} LayoutProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} LayoutEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} LayoutSlots */
|
|
4
|
-
export default class Layout extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}> {
|
|
11
|
-
}
|
|
12
|
-
export type LayoutProps = typeof __propDef.props;
|
|
13
|
-
export type LayoutEvents = typeof __propDef.events;
|
|
14
|
-
export type LayoutSlots = typeof __propDef.slots;
|
|
15
|
-
import a from './Link.svelte';
|
|
16
|
-
import blockquote from './Blockquote.svelte';
|
|
17
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import blockquote from './Blockquote.svelte';
|
|
3
|
+
import a from './Link.svelte';
|
|
4
|
+
export { a, blockquote };
|
|
18
5
|
declare const __propDef: {
|
|
19
|
-
props:
|
|
20
|
-
[x: string]: never;
|
|
21
|
-
};
|
|
6
|
+
props: Record<string, never>;
|
|
22
7
|
events: {
|
|
23
8
|
[evt: string]: CustomEvent<any>;
|
|
24
9
|
};
|
|
@@ -26,4 +11,8 @@ declare const __propDef: {
|
|
|
26
11
|
default: {};
|
|
27
12
|
};
|
|
28
13
|
};
|
|
29
|
-
export
|
|
14
|
+
export type LayoutProps = typeof __propDef.props;
|
|
15
|
+
export type LayoutEvents = typeof __propDef.events;
|
|
16
|
+
export type LayoutSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Layout extends SvelteComponentTyped<LayoutProps, LayoutEvents, LayoutSlots> {
|
|
18
|
+
}
|
package/dist/docs/Link.svelte
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} LinkProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} LinkEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} LinkSlots */
|
|
4
|
-
export default class Link extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}> {
|
|
11
|
-
}
|
|
12
|
-
export type LinkProps = typeof __propDef.props;
|
|
13
|
-
export type LinkEvents = typeof __propDef.events;
|
|
14
|
-
export type LinkSlots = typeof __propDef.slots;
|
|
15
1
|
import { SvelteComponentTyped } from "svelte";
|
|
16
2
|
declare const __propDef: {
|
|
17
3
|
props: {
|
|
@@ -24,4 +10,9 @@ declare const __propDef: {
|
|
|
24
10
|
default: {};
|
|
25
11
|
};
|
|
26
12
|
};
|
|
13
|
+
export type LinkProps = typeof __propDef.props;
|
|
14
|
+
export type LinkEvents = typeof __propDef.events;
|
|
15
|
+
export type LinkSlots = typeof __propDef.slots;
|
|
16
|
+
export default class Link extends SvelteComponentTyped<LinkProps, LinkEvents, LinkSlots> {
|
|
17
|
+
}
|
|
27
18
|
export {};
|
package/dist/docs/Preview.svelte
CHANGED
|
@@ -4,42 +4,42 @@ import 'prism-svelte';
|
|
|
4
4
|
import { mdiCodeTags, mdiContentCopy } from '@mdi/js';
|
|
5
5
|
import { slide } from 'svelte/transition';
|
|
6
6
|
import { Button } from 'svelte-ux';
|
|
7
|
-
export let code =
|
|
7
|
+
export let code = undefined;
|
|
8
8
|
export let language = 'svelte';
|
|
9
9
|
export let highlightedCode = Prism.highlight(code, Prism.languages.svelte, language);
|
|
10
10
|
export let showCode = false;
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<div class="border border-black/20 rounded bg-white">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
<div class="p-4">
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
{#if code && showCode}
|
|
19
|
+
<div class="relative">
|
|
20
|
+
<pre
|
|
21
|
+
class="language-{language} rounded"
|
|
22
|
+
style="margin: 0; white-space: normal;"
|
|
23
|
+
transition:slide|local>
|
|
24
24
|
<code class="language-{language}">{@html highlightedCode}</code>
|
|
25
25
|
</pre>
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
<div class="absolute top-0 right-0 p-2">
|
|
28
|
+
<Button
|
|
29
|
+
icon={mdiContentCopy}
|
|
30
|
+
class=" text-white/70 hover:bg-white/20 py-1"
|
|
31
|
+
size="sm"
|
|
32
|
+
on:click={() => navigator.clipboard.writeText(code)}
|
|
33
|
+
>
|
|
34
|
+
Copy
|
|
35
|
+
</Button>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
{/if}
|
|
39
39
|
</div>
|
|
40
40
|
|
|
41
41
|
{#if code}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
<Button icon={mdiCodeTags} class=" text-black/70 py-1" on:click={() => (showCode = !showCode)}>
|
|
43
|
+
{showCode ? 'Hide' : 'Show'} Code
|
|
44
|
+
</Button>
|
|
45
45
|
{/if}
|
|
@@ -7,22 +7,22 @@ export let step = 1;
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<Field let:id {...$$restProps}>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
<Button
|
|
11
|
+
icon={mdiChevronLeft}
|
|
12
|
+
on:click={() => (value -= value > min ? step : 0)}
|
|
13
|
+
class="mr-2"
|
|
14
|
+
size="sm"
|
|
15
|
+
/>
|
|
16
|
+
<input type="range" bind:value {min} {max} {step} {id} class="h-6 w-full" />
|
|
17
|
+
<span class="ml-2 text-sm text-black/50 tabular-nums text-right inline-grid">
|
|
18
|
+
<span class="col-span-full row-span-full invisible">{min}</span>
|
|
19
|
+
<span class="col-span-full row-span-full">{value}</span>
|
|
20
|
+
<span class="col-span-full row-span-full invisible">{max}</span>
|
|
21
|
+
</span>
|
|
22
|
+
<Button
|
|
23
|
+
icon={mdiChevronRight}
|
|
24
|
+
on:click={() => (value += value < max ? step : 0)}
|
|
25
|
+
class="ml-2"
|
|
26
|
+
size="sm"
|
|
27
|
+
/>
|
|
28
28
|
</Field>
|
|
@@ -77,17 +77,17 @@ $: serviceUrl = getServiceUrl(selected);
|
|
|
77
77
|
</script>
|
|
78
78
|
|
|
79
79
|
<Field label="Tileset" let:id>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
<select bind:value={selected} class="w-full outline-none appearance-none text-sm" {id}>
|
|
81
|
+
{#each Object.entries(serviceOptions) as [group, options]}
|
|
82
|
+
<optgroup label={group}>
|
|
83
|
+
{#each Object.keys(options) as option}
|
|
84
|
+
<option value="{group}:{option}">{option}</option>
|
|
85
|
+
{/each}
|
|
86
|
+
</optgroup>
|
|
87
|
+
{/each}
|
|
88
|
+
</select>
|
|
89
|
+
<div slot="append">
|
|
90
|
+
<div class="text-[10px] text-black/50 text-center">2x</div>
|
|
91
|
+
<Switch bind:checked={doubleScale} size="md" />
|
|
92
|
+
</div>
|
|
93
93
|
</Field>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script>import { mdiGithub } from '@mdi/js';
|
|
2
|
+
import { Button, Dialog, Toggle, Tooltip } from 'svelte-ux';
|
|
3
|
+
import Code from './Code.svelte';
|
|
4
|
+
export let label;
|
|
5
|
+
export let source;
|
|
6
|
+
export let href;
|
|
7
|
+
export let icon;
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if source}
|
|
11
|
+
<Toggle let:on={open} let:toggle>
|
|
12
|
+
<Button {icon} on:click={toggle} variant="fill-light" color="blue" size="sm">{label}</Button>
|
|
13
|
+
<Dialog {open} on:close={toggle}>
|
|
14
|
+
<div class="grid grid-cols-[1fr,auto] gap-1 items-center p-4">
|
|
15
|
+
<div>
|
|
16
|
+
<div class="text-lg font-semibold">{label}</div>
|
|
17
|
+
<div class="text-xs text-black/50">{href}</div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
{#if href}
|
|
21
|
+
<Button icon={mdiGithub} variant="fill-light" color="accent" {href} target="_blank">
|
|
22
|
+
Edit on Github
|
|
23
|
+
</Button>
|
|
24
|
+
{/if}
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div class="max-h-[80vh] w-[70vw] overflow-auto">
|
|
28
|
+
<Code {source} language={source.startsWith('<script') ? 'svelte' : 'js'} />
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div slot="actions">
|
|
32
|
+
<Button variant="fill" color="blue">Close</Button>
|
|
33
|
+
</div>
|
|
34
|
+
</Dialog>
|
|
35
|
+
</Toggle>
|
|
36
|
+
{:else if href}
|
|
37
|
+
<Tooltip title="Edit this page">
|
|
38
|
+
<Button {icon} {href} target="_blank" variant="fill-light" color="blue" size="sm">
|
|
39
|
+
{label}
|
|
40
|
+
</Button>
|
|
41
|
+
</Tooltip>
|
|
42
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
label: string;
|
|
5
|
+
source: string;
|
|
6
|
+
href: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type ViewSourceButtonProps = typeof __propDef.props;
|
|
15
|
+
export type ViewSourceButtonEvents = typeof __propDef.events;
|
|
16
|
+
export type ViewSourceButtonSlots = typeof __propDef.slots;
|
|
17
|
+
export default class ViewSourceButton extends SvelteComponentTyped<ViewSourceButtonProps, ViewSourceButtonEvents, ViewSourceButtonSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<script>import { Button, Tooltip } from 'svelte-ux';
|
|
2
|
-
import { cls } from 'svelte-ux/utils/styles';
|
|
1
|
+
<script>import { Button, Tooltip, cls } from 'svelte-ux';
|
|
3
2
|
import { mdiArrowULeftTop, mdiMagnifyPlusOutline, mdiMagnifyMinusOutline, mdiImageFilterCenterFocus } from '@mdi/js';
|
|
4
3
|
export let zoom;
|
|
5
4
|
export let placement = 'top-right';
|
|
@@ -7,44 +6,44 @@ export let orientation = 'vertical';
|
|
|
7
6
|
</script>
|
|
8
7
|
|
|
9
8
|
<div
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
class={cls(
|
|
10
|
+
'bg-black/5 rounded-full m-1 backdrop-blur z-10 flex',
|
|
11
|
+
orientation === 'vertical' && 'flex-col',
|
|
12
|
+
{
|
|
13
|
+
'top-left': 'absolute top-0 left-0',
|
|
14
|
+
top: 'absolute top-0 left-1/2 -translate-x-1/2',
|
|
15
|
+
'top-right': 'absolute top-0 right-0',
|
|
16
|
+
left: 'absolute top-1/2 left-0 -translate-y-1/2',
|
|
17
|
+
center: 'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2',
|
|
18
|
+
right: 'absolute top-1/2 right-0 -translate-y-1/2',
|
|
19
|
+
'bottom-left': 'absolute bottom-0 left-0',
|
|
20
|
+
bottom: 'absolute bottom-0 left-1/2 -translate-x-1/2',
|
|
21
|
+
'bottom-right': 'absolute bottom-0 right-0'
|
|
22
|
+
}[placement]
|
|
23
|
+
)}
|
|
25
24
|
>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
<Tooltip title="Zoom in">
|
|
26
|
+
<Button
|
|
27
|
+
icon={mdiMagnifyPlusOutline}
|
|
28
|
+
on:click={() => zoom.increase()}
|
|
29
|
+
class="text-black/50 p-2"
|
|
30
|
+
/>
|
|
31
|
+
</Tooltip>
|
|
32
|
+
<Tooltip title="Zoom out">
|
|
33
|
+
<Button
|
|
34
|
+
icon={mdiMagnifyMinusOutline}
|
|
35
|
+
on:click={() => zoom.decrease()}
|
|
36
|
+
class="text-black/50 p-2"
|
|
37
|
+
/>
|
|
38
|
+
</Tooltip>
|
|
39
|
+
<Tooltip title="Center">
|
|
40
|
+
<Button
|
|
41
|
+
icon={mdiImageFilterCenterFocus}
|
|
42
|
+
on:click={() => zoom.translateCenter()}
|
|
43
|
+
class="text-black/50 p-2"
|
|
44
|
+
/>
|
|
45
|
+
</Tooltip>
|
|
46
|
+
<Tooltip title="Reset">
|
|
47
|
+
<Button icon={mdiArrowULeftTop} on:click={() => zoom.reset()} class="text-black/50 p-2" />
|
|
48
|
+
</Tooltip>
|
|
50
49
|
</div>
|
|
@@ -3,8 +3,8 @@ import type Zoom from '../components/Zoom.svelte';
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
zoom: Zoom;
|
|
6
|
-
placement?: ("
|
|
7
|
-
orientation?: "
|
|
6
|
+
placement?: ("top" | "bottom" | "left" | "right" | "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
7
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
8
8
|
};
|
|
9
9
|
events: {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
package/dist/utils/genData.d.ts
CHANGED
package/dist/utils/quadtree.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import type { Quadtree } from 'd3-quadtree';
|
|
2
|
+
type Rect = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
1
8
|
/**
|
|
2
|
-
* Transverse
|
|
9
|
+
* Transverse quadtree and generate rect dimensions
|
|
3
10
|
*/
|
|
4
|
-
export declare function quadtreeRects(quadtree:
|
|
11
|
+
export declare function quadtreeRects<T>(quadtree: Quadtree<T>, showLeaves?: boolean): Rect[];
|
|
12
|
+
export {};
|
package/dist/utils/quadtree.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type DimensionGetterOptions = {
|
|
2
|
+
/** Override `x` accessor from context */
|
|
3
|
+
x?: (item: any) => any;
|
|
4
|
+
/** Override `y` accessor from context */
|
|
5
|
+
y?: (item: any) => any;
|
|
6
|
+
groupBy?: string;
|
|
7
|
+
padding?: number;
|
|
8
|
+
groupPadding?: {
|
|
9
|
+
inner?: number;
|
|
10
|
+
outer?: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare function createDimensionGetter(context: any, options?: DimensionGetterOptions): import("svelte/store").Readable<(item: any) => {
|
|
14
|
+
x: any;
|
|
15
|
+
y: any;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { derived } from 'svelte/store';
|
|
2
|
+
import { max, min } from 'd3-array';
|
|
3
|
+
import { groupScaleBand, isScaleBand } from './scales';
|
|
4
|
+
// TOOD: Pass in overrides for `x` and `y` accessors
|
|
5
|
+
export function createDimensionGetter(context, options) {
|
|
6
|
+
const { flatData, xGet, yGet, xRange, yRange, xScale, yScale, x: xAccessor, y: yAccessor } = context;
|
|
7
|
+
const groupBy = options?.groupBy;
|
|
8
|
+
const padding = options?.padding ?? 0;
|
|
9
|
+
return derived([flatData, xGet, yGet, xRange, yRange, xScale, yScale, xAccessor, yAccessor], ([$flatData, $xGet, $yGet, $xRange, $yRange, $xScale, $yScale, $xAccessor, $yAccessor]) => {
|
|
10
|
+
return function getter(item) {
|
|
11
|
+
if (isScaleBand($yScale)) {
|
|
12
|
+
// Horizontal band
|
|
13
|
+
const y1Scale = groupBy
|
|
14
|
+
? groupScaleBand($yScale, $flatData, groupBy, options?.groupPadding)
|
|
15
|
+
: null;
|
|
16
|
+
const y = $yGet(item) + (y1Scale ? y1Scale(item[groupBy]) : 0) + padding / 2;
|
|
17
|
+
const height = Math.max(0, $yScale.bandwidth ? (y1Scale ? y1Scale.bandwidth() : $yScale.bandwidth()) - padding : 0);
|
|
18
|
+
const _x = options?.x
|
|
19
|
+
? typeof options.x === 'string'
|
|
20
|
+
? (d) => d[options.x]
|
|
21
|
+
: options?.x
|
|
22
|
+
: $xAccessor;
|
|
23
|
+
const xValue = _x(item);
|
|
24
|
+
let left = 0;
|
|
25
|
+
let right = 0;
|
|
26
|
+
if (Array.isArray(xValue)) {
|
|
27
|
+
// Array contains both top and bottom values (stack, etc);
|
|
28
|
+
left = min(xValue);
|
|
29
|
+
right = max(xValue);
|
|
30
|
+
}
|
|
31
|
+
else if (xValue == null) {
|
|
32
|
+
// null/undefined value
|
|
33
|
+
left = 0;
|
|
34
|
+
right = 0;
|
|
35
|
+
}
|
|
36
|
+
else if (xValue > 0) {
|
|
37
|
+
// Positive value
|
|
38
|
+
left = min($xRange); // or `0`?
|
|
39
|
+
right = xValue;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Negative value
|
|
43
|
+
left = xValue;
|
|
44
|
+
right = min($xRange); // or `0`?
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
x: $xScale(left),
|
|
48
|
+
y,
|
|
49
|
+
width: $xScale(right) - $xScale(left),
|
|
50
|
+
height
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Vertical band or linear
|
|
55
|
+
const x1Scale = groupBy
|
|
56
|
+
? groupScaleBand($xScale, $flatData, groupBy, options?.groupPadding)
|
|
57
|
+
: null;
|
|
58
|
+
const x = $xGet(item) + (x1Scale ? x1Scale(item[groupBy]) : 0) + padding / 2;
|
|
59
|
+
const width = Math.max(0, $xScale.bandwidth ? (x1Scale ? x1Scale.bandwidth() : $xScale.bandwidth()) - padding : 0);
|
|
60
|
+
const _y = options?.y
|
|
61
|
+
? typeof options.y === 'string'
|
|
62
|
+
? (d) => d[options.y]
|
|
63
|
+
: options?.y
|
|
64
|
+
: $yAccessor;
|
|
65
|
+
const yValue = _y(item);
|
|
66
|
+
let top = 0;
|
|
67
|
+
let bottom = 0;
|
|
68
|
+
if (Array.isArray(yValue)) {
|
|
69
|
+
// Array contains both top and bottom values (stack, etc);
|
|
70
|
+
top = max(yValue);
|
|
71
|
+
bottom = min(yValue);
|
|
72
|
+
}
|
|
73
|
+
else if (yValue == null) {
|
|
74
|
+
// null/undefined value
|
|
75
|
+
top = 0;
|
|
76
|
+
bottom = 0;
|
|
77
|
+
}
|
|
78
|
+
else if (yValue > 0) {
|
|
79
|
+
// Positive value
|
|
80
|
+
top = yValue;
|
|
81
|
+
bottom = min($yRange); // or `0`?
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Negative value
|
|
85
|
+
top = min($yRange); // or `0`?
|
|
86
|
+
bottom = yValue;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
x,
|
|
90
|
+
y: $yScale(top),
|
|
91
|
+
width,
|
|
92
|
+
height: $yScale(bottom) - $yScale(top)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
package/dist/utils/scales.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tweened, spring } from 'svelte/motion';
|
|
2
2
|
import { type MotionOptions } from '../stores/motionStore';
|
|
3
|
+
import { type ScaleBand } from 'd3-scale';
|
|
3
4
|
/**
|
|
4
5
|
* Implemenation for missing `scaleBand().invert()`
|
|
5
6
|
*
|
|
@@ -17,6 +18,13 @@ export declare function isScaleBand(scale: any): boolean;
|
|
|
17
18
|
* Useful to map mouse event location (x,y) to domain value
|
|
18
19
|
*/
|
|
19
20
|
export declare function scaleInvert(scale: any, value: number): any;
|
|
21
|
+
/** Create a `scaleBand()` within another scaleBand()'s bandwidth (typically a x1 of an x0 scale, used for grouping) */
|
|
22
|
+
export declare function groupScaleBand<Domain extends {
|
|
23
|
+
toString(): string;
|
|
24
|
+
}>(scale: ScaleBand<Domain>, flatData: any[], groupBy: string, padding?: {
|
|
25
|
+
inner?: number;
|
|
26
|
+
outer?: number;
|
|
27
|
+
}): ScaleBand<string>;
|
|
20
28
|
/**
|
|
21
29
|
* Animate d3-scale as domain and/or range are updated using tweened store
|
|
22
30
|
*/
|
package/dist/utils/scales.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { derived } from 'svelte/store';
|
|
2
2
|
import { tweened, spring } from 'svelte/motion';
|
|
3
3
|
import { motionStore } from '../stores/motionStore';
|
|
4
|
+
import { scaleBand } from 'd3-scale';
|
|
5
|
+
import { unique } from 'svelte-ux/utils/array';
|
|
4
6
|
/**
|
|
5
7
|
* Implemenation for missing `scaleBand().invert()`
|
|
6
8
|
*
|
|
@@ -36,6 +38,21 @@ export function scaleInvert(scale, value) {
|
|
|
36
38
|
return scale.invert(value);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
/** Create a `scaleBand()` within another scaleBand()'s bandwidth (typically a x1 of an x0 scale, used for grouping) */
|
|
42
|
+
export function groupScaleBand(scale, flatData, groupBy, padding) {
|
|
43
|
+
//
|
|
44
|
+
const groupKeys = unique(flatData.map((d) => d[groupBy]));
|
|
45
|
+
let newScale = scaleBand().domain(groupKeys).range([0, scale.bandwidth()]);
|
|
46
|
+
if (padding) {
|
|
47
|
+
if (padding.inner) {
|
|
48
|
+
newScale = newScale.paddingInner(padding.inner);
|
|
49
|
+
}
|
|
50
|
+
if (padding.outer) {
|
|
51
|
+
newScale = newScale.paddingOuter(padding.outer);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return newScale;
|
|
55
|
+
}
|
|
39
56
|
/**
|
|
40
57
|
* Animate d3-scale as domain and/or range are updated using tweened store
|
|
41
58
|
*/
|