layerchart 0.16.0 → 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/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 +19 -19
- package/dist/components/Blur.svelte +6 -6
- package/dist/components/Chart.svelte +46 -46
- package/dist/components/ChartClipPath.svelte +7 -7
- package/dist/components/Circle.svelte +7 -7
- package/dist/components/CircleClipPath.svelte +4 -4
- package/dist/components/ClipPath.svelte +3 -3
- package/dist/components/ClipPathUse.svelte +4 -4
- 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 +82 -73
- package/dist/components/Labels.svelte.d.ts +2 -2
- package/dist/components/Legend.svelte +57 -57
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/Line.svelte +8 -8
- package/dist/components/LinearGradient.svelte +22 -22
- package/dist/components/Link.svelte +9 -9
- 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 +4 -4
- package/dist/components/Sankey.svelte.d.ts +2 -2
- package/dist/components/Text.svelte +21 -21
- 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 +10 -10
- package/dist/components/Tree.svelte.d.ts +9 -9
- package/dist/components/Zoom.svelte +18 -18
- package/dist/components/index.d.ts +1 -2
- package/dist/components/index.js +1 -2
- package/dist/docs/Blockquote.svelte +1 -1
- package/dist/docs/Code.svelte +19 -19
- package/dist/docs/Code.svelte.d.ts +2 -2
- package/dist/docs/GeoDebug.svelte +25 -25
- package/dist/docs/Header1.svelte +1 -1
- package/dist/docs/Layout.svelte +5 -5
- package/dist/docs/Link.svelte +1 -1
- package/dist/docs/Preview.svelte +24 -24
- 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 +39 -39
- package/dist/docs/ZoomControls.svelte.d.ts +2 -2
- package/dist/utils/genData.d.ts +2 -2
- 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 -90
- package/dist/components/AxisX.svelte +0 -43
- package/dist/components/AxisX.svelte.d.ts +0 -38
- package/dist/components/AxisY.svelte +0 -55
- package/dist/components/AxisY.svelte.d.ts +0 -38
|
@@ -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 {};
|
|
@@ -6,44 +6,44 @@ export let orientation = 'vertical';
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<div
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
)}
|
|
24
24
|
>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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>
|
|
49
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
|
@@ -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
|
*/
|
package/package.json
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
2
|
+
"name": "layerchart",
|
|
3
|
+
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": "techniq/layerchart",
|
|
6
|
+
"version": "0.17.0",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite dev",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"package": "svelte-package",
|
|
12
|
+
"prepublishOnly": "svelte-package",
|
|
13
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
14
|
+
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
|
15
|
+
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
|
|
16
|
+
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@rollup/plugin-dsv": "^3.0.2",
|
|
20
|
+
"@sveltejs/adapter-vercel": "^3.0.1",
|
|
21
|
+
"@sveltejs/kit": "^1.20.4",
|
|
22
|
+
"@sveltejs/package": "^2.0.2",
|
|
23
|
+
"@tailwindcss/typography": "^0.5.9",
|
|
24
|
+
"@types/d3-array": "^3.0.5",
|
|
25
|
+
"@types/d3-delaunay": "^6.0.1",
|
|
26
|
+
"@types/d3-dsv": "^3.0.1",
|
|
27
|
+
"@types/d3-geo": "^3.0.3",
|
|
28
|
+
"@types/d3-hierarchy": "^3.1.2",
|
|
29
|
+
"@types/d3-interpolate": "^3.0.1",
|
|
30
|
+
"@types/d3-quadtree": "^3.0.2",
|
|
31
|
+
"@types/d3-random": "^3.0.1",
|
|
32
|
+
"@types/d3-sankey": "^0.12.1",
|
|
33
|
+
"@types/d3-scale": "^4.0.3",
|
|
34
|
+
"@types/d3-shape": "^3.1.1",
|
|
35
|
+
"@types/lodash-es": "^4.17.7",
|
|
36
|
+
"@types/shapefile": "^0.6.1",
|
|
37
|
+
"@types/topojson-client": "^3.1.1",
|
|
38
|
+
"autoprefixer": "^10.4.14",
|
|
39
|
+
"mdsvex": "^0.10.6",
|
|
40
|
+
"prettier": "^2.8.8",
|
|
41
|
+
"prettier-plugin-svelte": "^2.10.1",
|
|
42
|
+
"prism-themes": "^1.9.0",
|
|
43
|
+
"rehype-slug": "^5.1.0",
|
|
44
|
+
"svelte-check": "^3.4.4",
|
|
45
|
+
"svelte-preprocess": "^5.0.4",
|
|
46
|
+
"svelte2tsx": "^0.6.16",
|
|
47
|
+
"tailwindcss": "^3.3.2",
|
|
48
|
+
"tslib": "^2.5.3",
|
|
49
|
+
"typescript": "^5.1.3",
|
|
50
|
+
"unist-util-visit": "^4.1.2",
|
|
51
|
+
"us-atlas": "^3.0.1",
|
|
52
|
+
"vite": "^4.3.9",
|
|
53
|
+
"vite-plugin-sveld": "^1.1.0"
|
|
54
|
+
},
|
|
55
|
+
"type": "module",
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@mdi/js": "^7.2.96",
|
|
58
|
+
"@vercel/analytics": "^1.0.1",
|
|
59
|
+
"d3-array": "^3.2.4",
|
|
60
|
+
"d3-delaunay": "^6.0.4",
|
|
61
|
+
"d3-dsv": "^3.0.1",
|
|
62
|
+
"d3-geo": "^3.1.0",
|
|
63
|
+
"d3-hierarchy": "^3.1.2",
|
|
64
|
+
"d3-interpolate": "^3.0.1",
|
|
65
|
+
"d3-interpolate-path": "^2.3.0",
|
|
66
|
+
"d3-quadtree": "^3.0.1",
|
|
67
|
+
"d3-random": "^3.0.1",
|
|
68
|
+
"d3-sankey": "^0.12.3",
|
|
69
|
+
"d3-scale": "^4.0.2",
|
|
70
|
+
"d3-scale-chromatic": "^3.0.0",
|
|
71
|
+
"d3-shape": "^3.2.0",
|
|
72
|
+
"d3-tile": "^1.0.0",
|
|
73
|
+
"date-fns": "^2.30.0",
|
|
74
|
+
"layercake": "^7.4.0",
|
|
75
|
+
"lodash-es": "^4.17.21",
|
|
76
|
+
"shapefile": "^0.6.6",
|
|
77
|
+
"svelte": "^3.59.1",
|
|
78
|
+
"svelte-ux": "^0.42.0",
|
|
79
|
+
"topojson-client": "^3.1.0"
|
|
80
|
+
},
|
|
81
|
+
"main": "./dist/index.js",
|
|
82
|
+
"exports": {
|
|
83
|
+
".": {
|
|
84
|
+
"types": "./dist/index.d.ts",
|
|
85
|
+
"svelte": "./dist/index.js"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"files": [
|
|
89
|
+
"dist"
|
|
90
|
+
],
|
|
91
|
+
"svelte": "./dist/index.js"
|
|
92
92
|
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { format } from 'svelte-ux';
|
|
3
|
-
import { max } from 'd3-array';
|
|
4
|
-
import Text from './Text.svelte';
|
|
5
|
-
import { isScaleBand } from '../utils/scales';
|
|
6
|
-
const { height, xScale, yRange } = getContext('LayerCake');
|
|
7
|
-
export let gridlines = false;
|
|
8
|
-
export let formatTick = undefined;
|
|
9
|
-
export let ticks = undefined;
|
|
10
|
-
export let xTick = undefined;
|
|
11
|
-
export let yTick = 8;
|
|
12
|
-
export let dxTick = 0;
|
|
13
|
-
export let dyTick = 0;
|
|
14
|
-
export let labelProps = undefined;
|
|
15
|
-
$: isBand = isScaleBand($xScale);
|
|
16
|
-
$: tickVals = Array.isArray(ticks)
|
|
17
|
-
? ticks
|
|
18
|
-
: isBand
|
|
19
|
-
? $xScale.domain()
|
|
20
|
-
: $xScale.ticks(typeof ticks === 'function' ? ticks($xScale) : ticks);
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<g class="axis x-axis">
|
|
24
|
-
{#each tickVals as tick, i}
|
|
25
|
-
<g class="tick tick-{tick}" transform="translate({$xScale(tick)},{max($yRange)})">
|
|
26
|
-
{#if gridlines !== false}
|
|
27
|
-
<line y1={$height * -1} y2="0" x1="0" x2="0" class="stroke-gray-200" {...gridlines} />
|
|
28
|
-
{/if}
|
|
29
|
-
<Text
|
|
30
|
-
x={xTick || isBand ? $xScale.bandwidth() / 2 : 0}
|
|
31
|
-
y={yTick}
|
|
32
|
-
dx={dxTick}
|
|
33
|
-
dy={dyTick}
|
|
34
|
-
rotate={315}
|
|
35
|
-
textAnchor="end"
|
|
36
|
-
verticalAnchor="middle"
|
|
37
|
-
class="text-[10px] stroke-white [stroke-width:2px] font-light"
|
|
38
|
-
value={format(tick, formatTick ?? $xScale.tickFormat?.())}
|
|
39
|
-
{...labelProps}
|
|
40
|
-
/>
|
|
41
|
-
</g>
|
|
42
|
-
{/each}
|
|
43
|
-
</g>
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { type FormatType } from 'svelte-ux';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
gridlines?: boolean | svelte.JSX.SVGProps<SVGLineElement>;
|
|
6
|
-
formatTick?: FormatType;
|
|
7
|
-
ticks?: undefined;
|
|
8
|
-
xTick?: undefined;
|
|
9
|
-
yTick?: number | undefined;
|
|
10
|
-
dxTick?: number | undefined;
|
|
11
|
-
dyTick?: number | undefined;
|
|
12
|
-
labelProps?: {
|
|
13
|
-
[x: string]: any;
|
|
14
|
-
value?: string | number | undefined;
|
|
15
|
-
width?: number | undefined;
|
|
16
|
-
x?: string | number | undefined;
|
|
17
|
-
y?: string | number | undefined;
|
|
18
|
-
dx?: string | number | undefined;
|
|
19
|
-
dy?: string | number | undefined;
|
|
20
|
-
lineHeight?: string | undefined;
|
|
21
|
-
capHeight?: string | undefined;
|
|
22
|
-
scaleToFit?: boolean | undefined;
|
|
23
|
-
textAnchor?: "start" | "middle" | "end" | "inherit" | undefined;
|
|
24
|
-
verticalAnchor?: "start" | "middle" | "end" | "inherit" | undefined;
|
|
25
|
-
rotate?: number | undefined;
|
|
26
|
-
} | undefined;
|
|
27
|
-
};
|
|
28
|
-
events: {
|
|
29
|
-
[evt: string]: CustomEvent<any>;
|
|
30
|
-
};
|
|
31
|
-
slots: {};
|
|
32
|
-
};
|
|
33
|
-
export type AxisXProps = typeof __propDef.props;
|
|
34
|
-
export type AxisXEvents = typeof __propDef.events;
|
|
35
|
-
export type AxisXSlots = typeof __propDef.slots;
|
|
36
|
-
export default class AxisX extends SvelteComponentTyped<AxisXProps, AxisXEvents, AxisXSlots> {
|
|
37
|
-
}
|
|
38
|
-
export {};
|