layerchart 0.54.0 → 0.55.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 +170 -144
- package/dist/components/Area.svelte +96 -67
- package/dist/components/Area.svelte.d.ts +1 -0
- package/dist/components/Axis.svelte +205 -155
- package/dist/components/Bar.svelte +72 -45
- package/dist/components/Bars.svelte +45 -34
- package/dist/components/Blur.svelte +5 -3
- package/dist/components/Bounds.svelte +37 -21
- package/dist/components/Brush.svelte +269 -112
- package/dist/components/Brush.svelte.d.ts +7 -0
- package/dist/components/Calendar.svelte +51 -38
- package/dist/components/Chart.svelte +295 -74
- package/dist/components/Chart.svelte.d.ts +17 -17
- package/dist/components/ChartClipPath.svelte +8 -5
- package/dist/components/ChartContext.svelte +243 -93
- package/dist/components/ChartContext.svelte.d.ts +15 -23
- package/dist/components/Circle.svelte +25 -16
- package/dist/components/CircleClipPath.svelte +16 -10
- package/dist/components/ClipPath.svelte +11 -7
- package/dist/components/ColorRamp.svelte +12 -10
- package/dist/components/ForceSimulation.svelte +185 -116
- package/dist/components/Frame.svelte +10 -6
- package/dist/components/GeoCircle.svelte +15 -9
- package/dist/components/GeoContext.svelte +109 -62
- package/dist/components/GeoEdgeFade.svelte +20 -14
- package/dist/components/GeoPath.svelte +107 -69
- package/dist/components/GeoPoint.svelte +32 -18
- package/dist/components/GeoSpline.svelte +30 -22
- package/dist/components/GeoTile.svelte +40 -30
- package/dist/components/GeoVisible.svelte +10 -7
- package/dist/components/Graticule.svelte +14 -8
- package/dist/components/Grid.svelte +75 -48
- package/dist/components/Group.svelte +43 -31
- package/dist/components/Highlight.svelte +284 -243
- package/dist/components/HitCanvas.svelte +75 -42
- package/dist/components/Hull.svelte +40 -20
- package/dist/components/Labels.svelte +81 -70
- package/dist/components/Legend.svelte +105 -74
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/Line.svelte +65 -19
- package/dist/components/Line.svelte.d.ts +13 -1
- package/dist/components/LinearGradient.svelte +21 -15
- package/dist/components/Link.svelte +94 -22
- package/dist/components/Link.svelte.d.ts +17 -1
- package/dist/components/Marker.svelte +81 -0
- package/dist/components/Marker.svelte.d.ts +28 -0
- package/dist/components/MonthPath.svelte +23 -16
- package/dist/components/MotionPath.svelte +34 -25
- package/dist/components/Pack.svelte +21 -14
- package/dist/components/Partition.svelte +35 -20
- package/dist/components/Pattern.svelte +8 -6
- package/dist/components/Pie.svelte +76 -57
- package/dist/components/Point.svelte +11 -7
- package/dist/components/Points.svelte +178 -143
- package/dist/components/RadialGradient.svelte +25 -18
- package/dist/components/Rect.svelte +33 -19
- package/dist/components/RectClipPath.svelte +16 -11
- package/dist/components/Rule.svelte +50 -42
- package/dist/components/Sankey.svelte +55 -30
- package/dist/components/Spline.svelte +167 -96
- package/dist/components/Spline.svelte.d.ts +15 -0
- package/dist/components/Text.svelte +137 -104
- package/dist/components/Threshold.svelte +18 -7
- package/dist/components/TileImage.svelte +56 -50
- package/dist/components/TransformContext.svelte +235 -135
- package/dist/components/TransformControls.svelte +57 -29
- package/dist/components/TransformControls.svelte.d.ts +1 -1
- package/dist/components/Tree.svelte +33 -23
- package/dist/components/Treemap.svelte +69 -41
- package/dist/components/Voronoi.svelte +55 -28
- package/dist/components/charts/AreaChart.svelte +138 -87
- package/dist/components/charts/AreaChart.svelte.d.ts +4 -4
- package/dist/components/charts/BarChart.svelte +179 -114
- package/dist/components/charts/BarChart.svelte.d.ts +4 -4
- package/dist/components/charts/LineChart.svelte +97 -53
- package/dist/components/charts/LineChart.svelte.d.ts +4 -4
- package/dist/components/charts/PieChart.svelte +104 -54
- package/dist/components/charts/PieChart.svelte.d.ts +3 -3
- package/dist/components/charts/ScatterChart.svelte +83 -48
- package/dist/components/charts/ScatterChart.svelte.d.ts +4 -4
- package/dist/components/layout/Canvas.svelte +63 -43
- package/dist/components/layout/Html.svelte +28 -18
- package/dist/components/layout/Svg.svelte +47 -32
- package/dist/components/tooltip/Tooltip.svelte +137 -91
- package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContext.svelte +315 -249
- package/dist/components/tooltip/TooltipHeader.svelte +9 -3
- package/dist/components/tooltip/TooltipItem.svelte +17 -9
- package/dist/components/tooltip/TooltipList.svelte +2 -1
- package/dist/components/tooltip/TooltipSeparator.svelte +3 -2
- package/dist/docs/Blockquote.svelte +4 -3
- package/dist/docs/Code.svelte +15 -8
- package/dist/docs/CurveMenuField.svelte +17 -12
- package/dist/docs/GeoDebug.svelte +13 -9
- package/dist/docs/Header1.svelte +2 -1
- package/dist/docs/Json.svelte +6 -4
- package/dist/docs/Layout.svelte +6 -6
- package/dist/docs/PathDataMenuField.svelte +52 -44
- package/dist/docs/Preview.svelte +39 -33
- package/dist/docs/TilesetField.svelte +80 -62
- package/dist/docs/TransformDebug.svelte +8 -5
- package/dist/docs/ViewSourceButton.svelte +13 -9
- package/dist/stores/motionStore.d.ts +1 -1
- package/dist/utils/scales.d.ts +3 -3
- package/package.json +29 -30
|
@@ -1,26 +1,52 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tick, type ComponentProps } from 'svelte';
|
|
3
|
+
import type { spring as springStore, tweened as tweenedStore } from 'svelte/motion';
|
|
4
|
+
import { cls } from '@layerstack/tailwind';
|
|
5
|
+
|
|
6
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
7
|
+
import { uniqueId } from '@layerstack/utils';
|
|
8
|
+
|
|
9
|
+
import Marker from './Marker.svelte';
|
|
10
|
+
|
|
11
|
+
export let x1: number;
|
|
12
|
+
export let initialX1 = x1;
|
|
13
|
+
|
|
14
|
+
export let y1: number;
|
|
15
|
+
export let initialY1 = y1;
|
|
16
|
+
|
|
17
|
+
export let x2: number;
|
|
18
|
+
export let initialX2 = x2;
|
|
19
|
+
|
|
20
|
+
export let y2: number;
|
|
21
|
+
export let initialY2 = y2;
|
|
22
|
+
|
|
23
|
+
/** Marker to attach to start and end points of path */
|
|
24
|
+
export let marker: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
25
|
+
undefined;
|
|
26
|
+
/** Marker to attach to start point of path */
|
|
27
|
+
export let markerStart: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
28
|
+
marker;
|
|
29
|
+
/** Marker to attach to end point of path */
|
|
30
|
+
export let markerEnd: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
31
|
+
marker;
|
|
32
|
+
|
|
33
|
+
$: markerStartId = markerStart || $$slots['markerStart'] ? uniqueId('marker-') : '';
|
|
34
|
+
$: markerEndId = markerEnd || $$slots['markerEnd'] ? uniqueId('marker-') : '';
|
|
35
|
+
|
|
36
|
+
export let spring: boolean | Parameters<typeof springStore>[1] = undefined;
|
|
37
|
+
export let tweened: boolean | Parameters<typeof tweenedStore>[1] = undefined;
|
|
38
|
+
|
|
39
|
+
let tweened_x1 = motionStore(initialX1, { spring, tweened });
|
|
40
|
+
let tweened_y1 = motionStore(initialY1, { spring, tweened });
|
|
41
|
+
let tweened_x2 = motionStore(initialX2, { spring, tweened });
|
|
42
|
+
let tweened_y2 = motionStore(initialY2, { spring, tweened });
|
|
43
|
+
|
|
44
|
+
$: tick().then(() => {
|
|
19
45
|
tweened_x1.set(x1);
|
|
20
46
|
tweened_y1.set(y1);
|
|
21
47
|
tweened_x2.set(x2);
|
|
22
48
|
tweened_y2.set(y2);
|
|
23
|
-
});
|
|
49
|
+
});
|
|
24
50
|
</script>
|
|
25
51
|
|
|
26
52
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
@@ -29,9 +55,29 @@ $: tick().then(() => {
|
|
|
29
55
|
y1={$tweened_y1}
|
|
30
56
|
x2={$tweened_x2}
|
|
31
57
|
y2={$tweened_y2}
|
|
58
|
+
marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
|
|
59
|
+
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
32
60
|
class={cls($$props.stroke === undefined && 'stroke-surface-content')}
|
|
33
61
|
{...$$restProps}
|
|
34
62
|
on:click
|
|
35
63
|
on:pointermove
|
|
36
64
|
on:pointerleave
|
|
37
65
|
/>
|
|
66
|
+
|
|
67
|
+
<slot name="markerStart" id={markerStartId}>
|
|
68
|
+
{#if markerStart}
|
|
69
|
+
<Marker
|
|
70
|
+
id={markerStartId}
|
|
71
|
+
type={typeof markerStart === 'string' ? markerStart : undefined}
|
|
72
|
+
{...typeof markerStart === 'object' ? markerStart : null}
|
|
73
|
+
/>
|
|
74
|
+
{/if}
|
|
75
|
+
</slot>
|
|
76
|
+
|
|
77
|
+
<slot name="markerEnd" id={markerEndId}>
|
|
78
|
+
<Marker
|
|
79
|
+
id={markerEndId}
|
|
80
|
+
type={typeof markerEnd === 'string' ? markerEnd : undefined}
|
|
81
|
+
{...typeof markerEnd === 'object' ? markerEnd : null}
|
|
82
|
+
/>
|
|
83
|
+
</slot>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type ComponentProps } from 'svelte';
|
|
2
3
|
import type { spring as springStore, tweened as tweenedStore } from 'svelte/motion';
|
|
4
|
+
import Marker from './Marker.svelte';
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: {
|
|
5
7
|
[x: string]: any;
|
|
@@ -11,6 +13,9 @@ declare const __propDef: {
|
|
|
11
13
|
initialX2?: number | undefined;
|
|
12
14
|
y2: number;
|
|
13
15
|
initialY2?: number | undefined;
|
|
16
|
+
marker?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
17
|
+
markerStart?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
18
|
+
markerEnd?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
14
19
|
spring?: boolean | Parameters<typeof springStore>[1];
|
|
15
20
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
16
21
|
};
|
|
@@ -21,7 +26,14 @@ declare const __propDef: {
|
|
|
21
26
|
} & {
|
|
22
27
|
[evt: string]: CustomEvent<any>;
|
|
23
28
|
};
|
|
24
|
-
slots: {
|
|
29
|
+
slots: {
|
|
30
|
+
markerStart: {
|
|
31
|
+
id: string;
|
|
32
|
+
};
|
|
33
|
+
markerEnd: {
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
25
37
|
};
|
|
26
38
|
export type LineProps = typeof __propDef.props;
|
|
27
39
|
export type LineEvents = typeof __propDef.events;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
export let
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { uniqueId } from '@layerstack/utils';
|
|
3
|
+
|
|
4
|
+
/** Unique id for linearGradient */
|
|
5
|
+
export let id: string = uniqueId('linearGradient-');
|
|
6
|
+
|
|
7
|
+
/** Array array of strings (colors), will equally distributed from 0-100%. If array of tuples, will use first value as the offset, and second as color */
|
|
8
|
+
export let stops: string[] | [string | number, string][] = [
|
|
6
9
|
'var(--tw-gradient-from)',
|
|
7
10
|
'var(--tw-gradient-to)',
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
|
|
17
|
-
export let
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
/** Apply color stops top-to-bottom (true) or left-to-right (false) */
|
|
14
|
+
export let vertical = false;
|
|
15
|
+
export let x1 = '0%';
|
|
16
|
+
export let y1 = '0%';
|
|
17
|
+
export let x2 = vertical ? '0%' : '100%';
|
|
18
|
+
export let y2 = vertical ? '100%' : '0%';
|
|
19
|
+
|
|
20
|
+
export let rotate: number | undefined = undefined;
|
|
21
|
+
|
|
22
|
+
/** Define the coordinate system for attributes (i.e. gradientUnits) */
|
|
23
|
+
export let units: 'objectBoundingBox' | 'userSpaceOnUse' = 'objectBoundingBox';
|
|
18
24
|
</script>
|
|
19
25
|
|
|
20
26
|
<defs>
|
|
@@ -1,29 +1,72 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/*
|
|
3
|
+
TODO:
|
|
4
|
+
- [ ] Show path progressively show / animated in on load. Also fix sliding in from left side (at last in from bottom)
|
|
5
|
+
- [ ] Support link types
|
|
6
|
+
- [ ] https://airbnb.io/visx/linktypes
|
|
7
|
+
- [ ] https://github.com/airbnb/visx/tree/master/packages/visx-shape/src/shapes/link
|
|
8
|
+
- [ ] https://observablehq.com/@nitaku/corner-connectors
|
|
9
|
+
- [ ] Straight
|
|
10
|
+
- [ ] Square
|
|
11
|
+
- [ ] Beveled
|
|
12
|
+
- [ ] Rounded
|
|
13
|
+
- [ ] Investigate: https://observablehq.com/@fil/sankey-link-paths
|
|
14
|
+
- [ ] Use for annotations - https://github.com/techniq/layerchart/issues/11
|
|
15
|
+
*/
|
|
16
|
+
import type { ComponentProps } from 'svelte';
|
|
17
|
+
import type { tweened as tweenedStore } from 'svelte/motion';
|
|
18
|
+
import { link as d3Link, curveBumpX, curveBumpY } from 'd3-shape';
|
|
19
|
+
import { interpolatePath } from 'd3-interpolate-path';
|
|
20
|
+
|
|
21
|
+
import { motionStore } from '../stores/motionStore.js';
|
|
22
|
+
import { uniqueId } from '@layerstack/utils';
|
|
23
|
+
|
|
24
|
+
import Marker from './Marker.svelte';
|
|
25
|
+
|
|
26
|
+
// Override what is used from context
|
|
27
|
+
export let data: any = undefined; // TODO: Update Type
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Update source and target accessors to be compatible with d3-sankey. see: https://github.com/d3/d3-sankey#sankeyLinkHorizontal
|
|
31
|
+
*/
|
|
32
|
+
export let sankey = false;
|
|
33
|
+
export let source = sankey ? (d: any) => [d.source.x1, d.y0] : (d: any) => d.source;
|
|
34
|
+
export let target = sankey ? (d: any) => [d.target.x0, d.y1] : (d: any) => d.target;
|
|
35
|
+
|
|
36
|
+
/** Convenient property to swap x/y accessor logic */
|
|
37
|
+
export let orientation: 'vertical' | 'horizontal' = sankey ? 'horizontal' : 'vertical';
|
|
38
|
+
export let x = (d: any) => (sankey ? d[0] : orientation === 'horizontal' ? d.y : d.x);
|
|
39
|
+
export let y = (d: any) => (sankey ? d[1] : orientation === 'horizontal' ? d.x : d.y);
|
|
40
|
+
export let curve = orientation === 'horizontal' ? curveBumpX : curveBumpY;
|
|
41
|
+
|
|
42
|
+
/** Marker to attach to start, mid, and end points of path */
|
|
43
|
+
export let marker: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
44
|
+
undefined;
|
|
45
|
+
/** Marker to attach to start point of path */
|
|
46
|
+
export let markerStart: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
47
|
+
marker;
|
|
48
|
+
/** Marker to attach to all mid points of path */
|
|
49
|
+
export let markerMid: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
50
|
+
marker;
|
|
51
|
+
/** Marker to attach to end point of path */
|
|
52
|
+
export let markerEnd: ComponentProps<Marker>['type'] | ComponentProps<Marker> | undefined =
|
|
53
|
+
marker;
|
|
54
|
+
|
|
55
|
+
$: markerStartId = markerStart || $$slots['markerStart'] ? uniqueId('marker-') : '';
|
|
56
|
+
$: markerMidId = markerMid || $$slots['markerMid'] ? uniqueId('marker-') : '';
|
|
57
|
+
$: markerEndId = markerEnd || $$slots['markerEnd'] ? uniqueId('marker-') : '';
|
|
58
|
+
|
|
59
|
+
export let tweened: boolean | Parameters<typeof tweenedStore>[1] = undefined;
|
|
60
|
+
// @ts-expect-error
|
|
61
|
+
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
62
|
+
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
63
|
+
|
|
64
|
+
$: {
|
|
22
65
|
orientation; // subscribe to orientation changes to update link
|
|
23
66
|
const link = d3Link(curve).source(source).target(target).x(x).y(y);
|
|
24
67
|
const d = link(data) ?? '';
|
|
25
68
|
tweened_d.set(d);
|
|
26
|
-
}
|
|
69
|
+
}
|
|
27
70
|
</script>
|
|
28
71
|
|
|
29
72
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
@@ -32,6 +75,9 @@ $: {
|
|
|
32
75
|
class="path-link"
|
|
33
76
|
d={$tweened_d}
|
|
34
77
|
fill="none"
|
|
78
|
+
marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
|
|
79
|
+
marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
|
|
80
|
+
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
35
81
|
on:click
|
|
36
82
|
on:pointerover
|
|
37
83
|
on:pointermove
|
|
@@ -39,3 +85,29 @@ $: {
|
|
|
39
85
|
on:pointerleave
|
|
40
86
|
{...$$restProps}
|
|
41
87
|
/>
|
|
88
|
+
|
|
89
|
+
<slot name="markerStart" id={markerStartId}>
|
|
90
|
+
{#if markerStart}
|
|
91
|
+
<Marker
|
|
92
|
+
id={markerStartId}
|
|
93
|
+
type={typeof markerStart === 'string' ? markerStart : undefined}
|
|
94
|
+
{...typeof markerStart === 'object' ? markerStart : null}
|
|
95
|
+
/>
|
|
96
|
+
{/if}
|
|
97
|
+
</slot>
|
|
98
|
+
|
|
99
|
+
<slot name="markerMid" id={markerMidId}>
|
|
100
|
+
<Marker
|
|
101
|
+
id={markerMidId}
|
|
102
|
+
type={typeof markerMid === 'string' ? markerMid : undefined}
|
|
103
|
+
{...typeof markerMid === 'object' ? markerMid : null}
|
|
104
|
+
/>
|
|
105
|
+
</slot>
|
|
106
|
+
|
|
107
|
+
<slot name="markerEnd" id={markerEndId}>
|
|
108
|
+
<Marker
|
|
109
|
+
id={markerEndId}
|
|
110
|
+
type={typeof markerEnd === 'string' ? markerEnd : undefined}
|
|
111
|
+
{...typeof markerEnd === 'object' ? markerEnd : null}
|
|
112
|
+
/>
|
|
113
|
+
</slot>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
2
3
|
import type { tweened as tweenedStore } from 'svelte/motion';
|
|
4
|
+
import Marker from './Marker.svelte';
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: {
|
|
5
7
|
[x: string]: any;
|
|
@@ -11,6 +13,10 @@ declare const __propDef: {
|
|
|
11
13
|
x?: ((d: any) => any) | undefined;
|
|
12
14
|
y?: ((d: any) => any) | undefined;
|
|
13
15
|
curve?: import("d3-shape").CurveFactory | undefined;
|
|
16
|
+
marker?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
17
|
+
markerStart?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
18
|
+
markerMid?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
19
|
+
markerEnd?: ComponentProps<Marker>["type"] | ComponentProps<Marker> | undefined;
|
|
14
20
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
15
21
|
};
|
|
16
22
|
events: {
|
|
@@ -22,7 +28,17 @@ declare const __propDef: {
|
|
|
22
28
|
} & {
|
|
23
29
|
[evt: string]: CustomEvent<any>;
|
|
24
30
|
};
|
|
25
|
-
slots: {
|
|
31
|
+
slots: {
|
|
32
|
+
markerStart: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
markerMid: {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
markerEnd: {
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
26
42
|
};
|
|
27
43
|
export type LinkProps = typeof __propDef.props;
|
|
28
44
|
export type LinkEvents = typeof __propDef.events;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cls } from '@layerstack/tailwind';
|
|
3
|
+
import { uniqueId } from '@layerstack/utils';
|
|
4
|
+
|
|
5
|
+
/** Defined the type of a default marker, or define your own in the slot */
|
|
6
|
+
export let type: 'arrow' | 'triangle' | 'line' | 'circle' | 'circle-stroke' | 'dot' | undefined =
|
|
7
|
+
undefined;
|
|
8
|
+
|
|
9
|
+
/** Unique id for marker */
|
|
10
|
+
export let id: string = uniqueId('marker-');
|
|
11
|
+
|
|
12
|
+
/** A number used to determine the size of the bounding box the marker content. */
|
|
13
|
+
export let size = 10;
|
|
14
|
+
|
|
15
|
+
/** The width of the marker viewport */
|
|
16
|
+
export let markerWidth: string | number = size;
|
|
17
|
+
|
|
18
|
+
/** The height of the marker viewport */
|
|
19
|
+
export let markerHeight: string | number = size;
|
|
20
|
+
|
|
21
|
+
/** Set the coordinate system for the markerWidth, markerHeight, and `<marker>` contents */
|
|
22
|
+
export let markerUnits: 'userSpaceOnUse' | 'strokeWidth' = 'userSpaceOnUse';
|
|
23
|
+
|
|
24
|
+
/** The orientation of the marker relative to the shape it is attached to */
|
|
25
|
+
export let orient: 'auto' | 'auto-start-reverse' | number = 'auto-start-reverse';
|
|
26
|
+
|
|
27
|
+
/** The x coordinate for the reference point of the marker */
|
|
28
|
+
export let refX: string | number = ['arrow', 'triangle'].includes(type ?? '') ? 9 : 5;
|
|
29
|
+
|
|
30
|
+
/** The y coordinate for the reference point of the maker */
|
|
31
|
+
export let refY: string | number = 5;
|
|
32
|
+
|
|
33
|
+
/** The bound of the SVG viewport for the current SVG fragment */
|
|
34
|
+
export let viewBox = '0 0 10 10';
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<defs>
|
|
38
|
+
<marker
|
|
39
|
+
{id}
|
|
40
|
+
{markerWidth}
|
|
41
|
+
{markerHeight}
|
|
42
|
+
{markerUnits}
|
|
43
|
+
{orient}
|
|
44
|
+
{refX}
|
|
45
|
+
{refY}
|
|
46
|
+
{viewBox}
|
|
47
|
+
{...$$restProps}
|
|
48
|
+
class={cls(
|
|
49
|
+
'overflow-visible',
|
|
50
|
+
// stroke
|
|
51
|
+
$$props.stroke == null &&
|
|
52
|
+
(['arrow', 'circle-stroke', 'line'].includes(type ?? '')
|
|
53
|
+
? 'stroke-[context-stroke]'
|
|
54
|
+
: type === 'circle'
|
|
55
|
+
? 'stroke-surface-100'
|
|
56
|
+
: 'stroke-none'),
|
|
57
|
+
// extra stroke attrs
|
|
58
|
+
'[stroke-linecap:round] [stroke-linejoin:round]',
|
|
59
|
+
//fill
|
|
60
|
+
$$props.fill == null &&
|
|
61
|
+
(['triangle', 'dot', 'circle'].includes(type ?? '')
|
|
62
|
+
? 'fill-[context-stroke]'
|
|
63
|
+
: type === 'circle-stroke'
|
|
64
|
+
? 'fill-surface-100'
|
|
65
|
+
: 'fill-none'),
|
|
66
|
+
$$props.class
|
|
67
|
+
)}
|
|
68
|
+
>
|
|
69
|
+
<slot>
|
|
70
|
+
{#if type === 'triangle'}
|
|
71
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
|
72
|
+
{:else if type === 'arrow'}
|
|
73
|
+
<polyline points="0 0, 10 5, 0 10" />
|
|
74
|
+
{:else if type === 'circle' || type === 'circle-stroke' || type === 'dot'}
|
|
75
|
+
<circle cx={5} cy={5} r={5} />
|
|
76
|
+
{:else if type === 'line'}
|
|
77
|
+
<polyline points="5 0, 5 10" />
|
|
78
|
+
{/if}
|
|
79
|
+
</slot>
|
|
80
|
+
</marker>
|
|
81
|
+
</defs>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
type?: "arrow" | "triangle" | "line" | "circle" | "circle-stroke" | "dot" | undefined;
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
size?: number | undefined;
|
|
8
|
+
markerWidth?: (string | number) | undefined;
|
|
9
|
+
markerHeight?: (string | number) | undefined;
|
|
10
|
+
markerUnits?: ("userSpaceOnUse" | "strokeWidth") | undefined;
|
|
11
|
+
orient?: ("auto" | "auto-start-reverse" | number) | undefined;
|
|
12
|
+
refX?: (string | number) | undefined;
|
|
13
|
+
refY?: (string | number) | undefined;
|
|
14
|
+
viewBox?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {
|
|
20
|
+
default: {};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type MarkerProps = typeof __propDef.props;
|
|
24
|
+
export type MarkerEvents = typeof __propDef.events;
|
|
25
|
+
export type MarkerSlots = typeof __propDef.slots;
|
|
26
|
+
export default class Marker extends SvelteComponentTyped<MarkerProps, MarkerEvents, MarkerSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
$:
|
|
16
|
-
$:
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { timeWeek, timeYear } from 'd3-time';
|
|
3
|
+
import { endOfMonth } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
export let date: Date;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Size of cell. If `number`, sets width/height as same. If array, sets [width,height]. If undefined, is based on Chart width/height
|
|
9
|
+
*/
|
|
10
|
+
export let cellSize: number | [number, number];
|
|
11
|
+
|
|
12
|
+
$: [cellWidth, cellHeight] = Array.isArray(cellSize) ? cellSize : [cellSize, cellSize];
|
|
13
|
+
|
|
14
|
+
// start of month
|
|
15
|
+
$: startDayOfWeek = date.getDay();
|
|
16
|
+
$: startWeek = timeWeek.count(timeYear(date), date);
|
|
17
|
+
|
|
18
|
+
// end of month
|
|
19
|
+
$: monthEnd = endOfMonth(date);
|
|
20
|
+
$: endDayOfWeek = monthEnd.getDay();
|
|
21
|
+
$: endWeek = timeWeek.count(timeYear(monthEnd), monthEnd);
|
|
22
|
+
|
|
23
|
+
$: pathData = `
|
|
17
24
|
M${(startWeek + 1) * cellWidth},${startDayOfWeek * cellHeight}
|
|
18
25
|
H${startWeek * cellWidth} V${cellHeight * 7}
|
|
19
26
|
H${endWeek * cellWidth} V${(endDayOfWeek + 1) * cellHeight}
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Id of
|
|
6
|
-
export let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let
|
|
24
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { uniqueId } from '@layerstack/utils';
|
|
4
|
+
|
|
5
|
+
/** Id of path to move object along */
|
|
6
|
+
export let pathId: string = uniqueId('motionPathId-');
|
|
7
|
+
|
|
8
|
+
/** Id of object to move along path */
|
|
9
|
+
export let objectId: string = uniqueId('motionObjectId-');
|
|
10
|
+
|
|
11
|
+
/** Duration of the animation */
|
|
12
|
+
export let duration: string;
|
|
13
|
+
|
|
14
|
+
/** Number of times the animation will occur */
|
|
15
|
+
export let repeatCount: number | 'indefinite' | undefined = undefined;
|
|
16
|
+
|
|
17
|
+
/** Final state of the animation. Freeze (last frame) or remove (first frame)
|
|
18
|
+
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
|
|
19
|
+
* */
|
|
20
|
+
export let fill: 'freeze' | 'remove' = 'freeze';
|
|
21
|
+
|
|
22
|
+
/** Rotation applied to the element animated along a path, usually to make it pointing in the direction of the animation */
|
|
23
|
+
export let rotate: number | 'auto' | 'auto-reverse' | undefined = undefined;
|
|
24
|
+
|
|
25
|
+
// TODO: Investigate `calcMode:spline`, `keyTimes`, and `keySplines` to work with `svelte/easing`
|
|
26
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/calcMode
|
|
27
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/keyTimes
|
|
28
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/keySplines
|
|
29
|
+
// https://medium.com/javarevisited/animate-your-scalable-vector-graphics-svg-56f5800cd34b
|
|
30
|
+
|
|
31
|
+
// Restart animation anytime the component is remounted (otherwise it only ever plays once)
|
|
32
|
+
let animateEl: SVGAnimateMotionElement;
|
|
33
|
+
onMount(() => {
|
|
25
34
|
animateEl.beginElement();
|
|
26
|
-
});
|
|
35
|
+
});
|
|
27
36
|
</script>
|
|
28
37
|
|
|
29
38
|
<defs>
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { pack as d3Pack } from 'd3-hierarchy';
|
|
3
|
+
import { chartContext } from './ChartContext.svelte';
|
|
4
|
+
|
|
5
|
+
const { data, width, height } = chartContext();
|
|
6
|
+
|
|
7
|
+
export let size: [number, number] | undefined = undefined;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* see: https://github.com/d3/d3-hierarchy#pack_padding
|
|
11
|
+
*/
|
|
12
|
+
export let padding: number | undefined = undefined;
|
|
13
|
+
|
|
14
|
+
let pack: ReturnType<typeof d3Pack>;
|
|
15
|
+
$: {
|
|
11
16
|
pack = d3Pack().size(size ?? [$width, $height]);
|
|
17
|
+
|
|
12
18
|
if (padding) {
|
|
13
|
-
|
|
19
|
+
pack.padding(padding);
|
|
14
20
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
$: packData = pack($data);
|
|
18
25
|
</script>
|
|
19
26
|
|
|
20
27
|
<slot nodes={packData.descendants()} />
|