layerchart 2.0.0-next.1 → 2.0.0-next.3
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/actions/movable.d.ts +28 -0
- package/dist/actions/movable.js +91 -0
- package/dist/components/AnnotationLine.svelte +143 -0
- package/dist/components/AnnotationLine.svelte.d.ts +30 -0
- package/dist/components/AnnotationPoint.svelte +119 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +34 -0
- package/dist/components/AnnotationRange.svelte +147 -0
- package/dist/components/AnnotationRange.svelte.d.ts +40 -0
- package/dist/components/Arc.svelte +344 -151
- package/dist/components/Arc.svelte.d.ts +138 -0
- package/dist/components/Area.svelte +165 -149
- package/dist/components/Area.svelte.d.ts +45 -0
- package/dist/components/Axis.svelte +283 -180
- package/dist/components/Axis.svelte.d.ts +117 -0
- package/dist/components/Bar.svelte +166 -107
- package/dist/components/Bar.svelte.d.ts +51 -0
- package/dist/components/Bars.svelte +56 -67
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +42 -12
- package/dist/components/Blur.svelte.d.ts +23 -21
- package/dist/components/Bounds.svelte +49 -19
- package/dist/components/Bounds.svelte.d.ts +24 -50
- package/dist/components/BrushContext.svelte +296 -168
- package/dist/components/BrushContext.svelte.d.ts +97 -65
- package/dist/components/Calendar.svelte +116 -59
- package/dist/components/Calendar.svelte.d.ts +50 -31
- package/dist/components/Chart.svelte +1289 -398
- package/dist/components/Chart.svelte.d.ts +535 -410
- package/dist/components/ChartClipPath.svelte +37 -15
- package/dist/components/ChartClipPath.svelte.d.ts +21 -19
- package/dist/components/Circle.svelte +124 -85
- package/dist/components/Circle.svelte.d.ts +52 -0
- package/dist/components/CircleClipPath.svelte +76 -16
- package/dist/components/CircleClipPath.svelte.d.ts +46 -0
- package/dist/components/ClipPath.svelte +71 -21
- package/dist/components/ClipPath.svelte.d.ts +40 -27
- package/dist/components/ColorRamp.svelte +75 -9
- package/dist/components/ColorRamp.svelte.d.ts +37 -19
- package/dist/components/ComputedStyles.svelte +17 -5
- package/dist/components/ComputedStyles.svelte.d.ts +11 -19
- package/dist/components/Connector.svelte +149 -0
- package/dist/components/Connector.svelte.d.ts +51 -0
- package/dist/components/Dagre.svelte +211 -122
- package/dist/components/Dagre.svelte.d.ts +119 -56
- package/dist/components/ForceSimulation.svelte +215 -90
- package/dist/components/ForceSimulation.svelte.d.ts +82 -35
- package/dist/components/Frame.svelte +33 -13
- package/dist/components/Frame.svelte.d.ts +13 -17
- package/dist/components/GeoCircle.svelte +29 -16
- package/dist/components/GeoCircle.svelte.d.ts +22 -24
- package/dist/components/GeoContext.svelte +113 -72
- package/dist/components/GeoContext.svelte.d.ts +49 -41
- package/dist/components/GeoEdgeFade.svelte +49 -13
- package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
- package/dist/components/GeoPath.svelte +157 -127
- package/dist/components/GeoPath.svelte.d.ts +48 -36
- package/dist/components/GeoPoint.svelte +52 -20
- package/dist/components/GeoPoint.svelte.d.ts +25 -22
- package/dist/components/GeoSpline.svelte +75 -26
- package/dist/components/GeoSpline.svelte.d.ts +29 -20
- package/dist/components/GeoTile.svelte +100 -49
- package/dist/components/GeoTile.svelte.d.ts +38 -23
- package/dist/components/GeoVisible.svelte +17 -9
- package/dist/components/GeoVisible.svelte.d.ts +10 -18
- package/dist/components/Graticule.svelte +30 -14
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +230 -117
- package/dist/components/Grid.svelte.d.ts +71 -0
- package/dist/components/Group.svelte +173 -106
- package/dist/components/Group.svelte.d.ts +81 -0
- package/dist/components/Highlight.svelte +410 -308
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +97 -46
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +127 -47
- package/dist/components/Labels.svelte.d.ts +70 -27
- package/dist/components/Legend.svelte +374 -190
- package/dist/components/Legend.svelte.d.ts +95 -44
- package/dist/components/Line.svelte +163 -125
- package/dist/components/Line.svelte.d.ts +75 -0
- package/dist/components/LinearGradient.svelte +153 -78
- package/dist/components/LinearGradient.svelte.d.ts +66 -31
- package/dist/components/Link.svelte +160 -104
- package/dist/components/Link.svelte.d.ts +54 -0
- package/dist/components/Marker.svelte +100 -39
- package/dist/components/Marker.svelte.d.ts +59 -27
- package/dist/components/MarkerWrapper.svelte +35 -0
- package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
- package/dist/components/MonthPath.svelte +65 -20
- package/dist/components/MonthPath.svelte.d.ts +23 -17
- package/dist/components/MotionPath.svelte +80 -24
- package/dist/components/MotionPath.svelte.d.ts +46 -27
- package/dist/components/Pack.svelte +53 -17
- package/dist/components/Pack.svelte.d.ts +42 -21
- package/dist/components/Partition.svelte +64 -22
- package/dist/components/Partition.svelte.d.ts +49 -26
- package/dist/components/Pattern.svelte +297 -11
- package/dist/components/Pattern.svelte.d.ts +103 -19
- package/dist/components/Pie.svelte +122 -76
- package/dist/components/Pie.svelte.d.ts +65 -51
- package/dist/components/Point.svelte +20 -9
- package/dist/components/Point.svelte.d.ts +16 -20
- package/dist/components/Points.svelte +148 -137
- package/dist/components/Points.svelte.d.ts +45 -34
- package/dist/components/RadialGradient.svelte +143 -70
- package/dist/components/RadialGradient.svelte.d.ts +69 -31
- package/dist/components/Rect.svelte +121 -102
- package/dist/components/Rect.svelte.d.ts +36 -0
- package/dist/components/RectClipPath.svelte +82 -18
- package/dist/components/RectClipPath.svelte.d.ts +55 -0
- package/dist/components/Rule.svelte +107 -63
- package/dist/components/Rule.svelte.d.ts +40 -19
- package/dist/components/Sankey.svelte +132 -55
- package/dist/components/Sankey.svelte.d.ts +61 -31
- package/dist/components/Spline.svelte +281 -218
- package/dist/components/Spline.svelte.d.ts +95 -0
- package/dist/components/Text.svelte +437 -176
- package/dist/components/Text.svelte.d.ts +130 -0
- package/dist/components/Threshold.svelte +48 -16
- package/dist/components/Threshold.svelte.d.ts +29 -31
- package/dist/components/TileImage.svelte +103 -30
- package/dist/components/TileImage.svelte.d.ts +48 -23
- package/dist/components/TransformContext.svelte +365 -171
- package/dist/components/TransformControls.svelte +50 -26
- package/dist/components/TransformControls.svelte.d.ts +27 -19
- package/dist/components/Tree.svelte +74 -33
- package/dist/components/Tree.svelte.d.ts +42 -30
- package/dist/components/Treemap.svelte +119 -42
- package/dist/components/Treemap.svelte.d.ts +75 -27
- package/dist/components/Voronoi.svelte +108 -76
- package/dist/components/Voronoi.svelte.d.ts +40 -41
- package/dist/components/charts/ArcChart.svelte +464 -0
- package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
- package/dist/components/charts/AreaChart.svelte +450 -393
- package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
- package/dist/components/charts/BarChart.svelte +454 -389
- package/dist/components/charts/BarChart.svelte.d.ts +76 -0
- package/dist/components/charts/ChartAnnotations.svelte +37 -0
- package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
- package/dist/components/charts/DefaultTooltip.svelte +60 -0
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
- package/dist/components/charts/LineChart.svelte +369 -314
- package/dist/components/charts/LineChart.svelte.d.ts +53 -0
- package/dist/components/charts/PieChart.svelte +458 -316
- package/dist/components/charts/PieChart.svelte.d.ts +137 -353
- package/dist/components/charts/ScatterChart.svelte +334 -296
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
- package/dist/components/charts/index.d.ts +8 -0
- package/dist/components/charts/index.js +7 -0
- package/dist/components/charts/types.d.ts +253 -0
- package/dist/components/charts/utils.svelte.d.ts +30 -0
- package/dist/components/charts/utils.svelte.js +55 -0
- package/dist/components/index.d.ts +76 -4
- package/dist/components/index.js +76 -5
- package/dist/components/layout/Canvas.svelte +321 -155
- package/dist/components/layout/Canvas.svelte.d.ts +104 -55
- package/dist/components/layout/Html.svelte +82 -42
- package/dist/components/layout/Html.svelte.d.ts +39 -28
- package/dist/components/layout/Layer.svelte +39 -0
- package/dist/components/layout/Layer.svelte.d.ts +17 -0
- package/dist/components/layout/Svg.svelte +122 -70
- package/dist/components/layout/Svg.svelte.d.ts +53 -34
- package/dist/components/layout/WebGL.svelte +135 -0
- package/dist/components/layout/WebGL.svelte.d.ts +50 -0
- package/dist/components/tooltip/Tooltip.svelte +246 -78
- package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
- package/dist/components/tooltip/TooltipContext.svelte +409 -271
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
- package/dist/components/tooltip/TooltipHeader.svelte +100 -11
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
- package/dist/components/tooltip/TooltipItem.svelte +167 -27
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
- package/dist/components/tooltip/TooltipList.svelte +22 -3
- package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
- package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
- package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +6 -0
- package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
- package/dist/components/tooltip/tooltipMetaContext.js +139 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/components/types.js +1 -0
- package/dist/docs/Blockquote.svelte.d.ts +18 -14
- package/dist/docs/Code.svelte.d.ts +26 -22
- package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
- package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
- package/dist/docs/CurveMenuField.svelte +14 -3
- package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
- package/dist/docs/GeoDebug.svelte +47 -42
- package/dist/docs/GeoDebug.svelte.d.ts +4 -16
- package/dist/docs/Header1.svelte.d.ts +27 -16
- package/dist/docs/Json.svelte.d.ts +20 -16
- package/dist/docs/Layout.svelte.d.ts +18 -13
- package/dist/docs/Link.svelte.d.ts +33 -21
- package/dist/docs/PathDataMenuField.svelte +14 -10
- package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
- package/dist/docs/Preview.svelte +20 -7
- package/dist/docs/Preview.svelte.d.ts +12 -22
- package/dist/docs/TilesetField.svelte.d.ts +21 -17
- package/dist/docs/TransformDebug.svelte +5 -6
- package/dist/docs/TransformDebug.svelte.d.ts +18 -14
- package/dist/docs/ViewSourceButton.svelte.d.ts +21 -17
- package/dist/types/d3-shape-extentions.d.ts +7 -0
- package/dist/utils/afterTick.d.ts +5 -0
- package/dist/utils/afterTick.js +8 -0
- package/dist/utils/arcText.svelte.d.ts +57 -0
- package/dist/utils/arcText.svelte.js +262 -0
- package/dist/utils/array.d.ts +9 -1
- package/dist/utils/array.js +13 -0
- package/dist/utils/attributes.d.ts +29 -0
- package/dist/utils/attributes.js +40 -0
- package/dist/utils/canvas.js +47 -10
- package/dist/utils/chart.d.ts +78 -0
- package/dist/utils/chart.js +512 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +8 -0
- package/dist/utils/common.d.ts +3 -5
- package/dist/utils/common.js +3 -2
- package/dist/utils/connectorUtils.d.ts +21 -0
- package/dist/utils/connectorUtils.js +111 -0
- package/dist/utils/createId.d.ts +7 -0
- package/dist/utils/createId.js +9 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +84 -0
- package/dist/utils/filterObject.d.ts +9 -0
- package/dist/utils/filterObject.js +12 -0
- package/dist/utils/graph/dagre.d.ts +34 -0
- package/dist/utils/graph/dagre.js +78 -0
- package/dist/utils/graph/dagre.test.d.ts +1 -0
- package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
- package/dist/utils/graph/sankey.d.ts +28 -0
- package/dist/utils/{graph.js → graph/sankey.js} +13 -41
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/key.svelte.d.ts +3 -0
- package/dist/utils/key.svelte.js +11 -0
- package/dist/utils/legendPayload.d.ts +7 -0
- package/dist/utils/legendPayload.js +8 -0
- package/dist/utils/motion.svelte.d.ts +140 -0
- package/dist/utils/motion.svelte.js +180 -0
- package/dist/utils/motion.test.d.ts +1 -0
- package/dist/utils/motion.test.js +213 -0
- package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
- package/dist/utils/rect.svelte.js +105 -0
- package/dist/utils/scales.svelte.d.ts +90 -0
- package/dist/utils/{scales.js → scales.svelte.js} +100 -39
- package/dist/utils/stack.d.ts +2 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.js +87 -0
- package/dist/utils/ticks.d.ts +8 -2
- package/dist/utils/ticks.js +28 -0
- package/dist/utils/ticks.test.d.ts +1 -0
- package/dist/utils/ticks.test.js +67 -0
- package/dist/utils/types.d.ts +81 -0
- package/package.json +21 -19
- package/dist/components/ChartContext.svelte +0 -295
- package/dist/components/ChartContext.svelte.d.ts +0 -139
- package/dist/components/TransformContext.svelte.d.ts +0 -158
- package/dist/stores/motionStore.d.ts +0 -30
- package/dist/stores/motionStore.js +0 -62
- package/dist/utils/graph.d.ts +0 -37
- package/dist/utils/rect.js +0 -107
- package/dist/utils/scales.d.ts +0 -66
- /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
|
@@ -1,25 +1,89 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import Rect, { type RectPropsWithoutHTML } from './Rect.svelte';
|
|
3
|
+
import type { Without } from '../utils/types.js';
|
|
4
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
export type BaseRectClipPathPropsWithoutHTML = {
|
|
8
|
+
/**
|
|
9
|
+
* A unique id for the clipPath.
|
|
10
|
+
*/
|
|
11
|
+
id?: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The x position of the clipPath.
|
|
15
|
+
*
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
x?: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The y position of the clipPath.
|
|
22
|
+
*
|
|
23
|
+
* @default 0
|
|
24
|
+
*/
|
|
25
|
+
y?: number;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The width of the clipPath.
|
|
29
|
+
*
|
|
30
|
+
* @required
|
|
31
|
+
*/
|
|
32
|
+
width: number;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The height of the clipPath.
|
|
36
|
+
*
|
|
37
|
+
* @required
|
|
38
|
+
*/
|
|
39
|
+
height: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether to disable clipping (show all).
|
|
43
|
+
*
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
disabled?: boolean;
|
|
7
47
|
|
|
8
|
-
|
|
9
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The default children snippet which provides
|
|
50
|
+
* the id and url for the clipPath.
|
|
51
|
+
*/
|
|
52
|
+
children?: Snippet<[{ id: string; url: string }]>;
|
|
53
|
+
|
|
54
|
+
motion?: MotionProp<'x' | 'y' | 'width' | 'height'>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type RectClipPathPropsWithoutHTML = BaseRectClipPathPropsWithoutHTML &
|
|
58
|
+
Without<RectPropsWithoutHTML, BaseRectClipPathPropsWithoutHTML>;
|
|
59
|
+
|
|
60
|
+
export type RectClipPathProps = RectClipPathPropsWithoutHTML &
|
|
61
|
+
Without<SVGAttributes<SVGElement>, RectClipPathPropsWithoutHTML>;
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<script lang="ts">
|
|
65
|
+
import ClipPath from './ClipPath.svelte';
|
|
66
|
+
import { createId } from '../utils/createId.js';
|
|
67
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
68
|
+
import type { MotionProp } from '../utils/motion.svelte.js';
|
|
10
69
|
|
|
11
|
-
|
|
12
|
-
export let y: number = 0;
|
|
13
|
-
export let width: number;
|
|
14
|
-
export let height: number;
|
|
15
|
-
export let spring: ComponentProps<Rect>['spring'] = undefined;
|
|
16
|
-
export let tweened: ComponentProps<Rect>['tweened'] = undefined;
|
|
70
|
+
const uid = $props.id();
|
|
17
71
|
|
|
18
|
-
|
|
19
|
-
|
|
72
|
+
let {
|
|
73
|
+
id = createId('clipPath-', uid),
|
|
74
|
+
x = 0,
|
|
75
|
+
y = 0,
|
|
76
|
+
disabled = false,
|
|
77
|
+
children: childrenProp,
|
|
78
|
+
...restProps
|
|
79
|
+
}: RectClipPathProps = $props();
|
|
20
80
|
</script>
|
|
21
81
|
|
|
22
|
-
<ClipPath {id} {disabled}
|
|
23
|
-
|
|
24
|
-
|
|
82
|
+
<ClipPath {id} {disabled}>
|
|
83
|
+
{#snippet clip()}
|
|
84
|
+
<Rect {x} {y} {...extractLayerProps(restProps, 'clip-path-rect')} />
|
|
85
|
+
{/snippet}
|
|
86
|
+
{#snippet children({ url })}
|
|
87
|
+
{@render childrenProp?.({ id, url })}
|
|
88
|
+
{/snippet}
|
|
25
89
|
</ClipPath>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type RectPropsWithoutHTML } from './Rect.svelte';
|
|
2
|
+
import type { Without } from '../utils/types.js';
|
|
3
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
export type BaseRectClipPathPropsWithoutHTML = {
|
|
6
|
+
/**
|
|
7
|
+
* A unique id for the clipPath.
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The x position of the clipPath.
|
|
12
|
+
*
|
|
13
|
+
* @default 0
|
|
14
|
+
*/
|
|
15
|
+
x?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The y position of the clipPath.
|
|
18
|
+
*
|
|
19
|
+
* @default 0
|
|
20
|
+
*/
|
|
21
|
+
y?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The width of the clipPath.
|
|
24
|
+
*
|
|
25
|
+
* @required
|
|
26
|
+
*/
|
|
27
|
+
width: number;
|
|
28
|
+
/**
|
|
29
|
+
* The height of the clipPath.
|
|
30
|
+
*
|
|
31
|
+
* @required
|
|
32
|
+
*/
|
|
33
|
+
height: number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to disable clipping (show all).
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The default children snippet which provides
|
|
42
|
+
* the id and url for the clipPath.
|
|
43
|
+
*/
|
|
44
|
+
children?: Snippet<[{
|
|
45
|
+
id: string;
|
|
46
|
+
url: string;
|
|
47
|
+
}]>;
|
|
48
|
+
motion?: MotionProp<'x' | 'y' | 'width' | 'height'>;
|
|
49
|
+
};
|
|
50
|
+
export type RectClipPathPropsWithoutHTML = BaseRectClipPathPropsWithoutHTML & Without<RectPropsWithoutHTML, BaseRectClipPathPropsWithoutHTML>;
|
|
51
|
+
export type RectClipPathProps = RectClipPathPropsWithoutHTML & Without<SVGAttributes<SVGElement>, RectClipPathPropsWithoutHTML>;
|
|
52
|
+
import type { MotionProp } from '../utils/motion.svelte.js';
|
|
53
|
+
declare const RectClipPath: import("svelte").Component<RectClipPathProps, {}, "">;
|
|
54
|
+
type RectClipPath = ReturnType<typeof RectClipPath>;
|
|
55
|
+
export default RectClipPath;
|
|
@@ -1,42 +1,78 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Without } from '../utils/types.js';
|
|
3
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
export type BaseRulePropsWithoutHTML = {
|
|
6
|
+
/**
|
|
7
|
+
* Create a vertical `x` line
|
|
8
|
+
* - If true or 'left', will draw at chart left (xRange[0])
|
|
9
|
+
* - If 'right', will draw at chart right (xRange[1])
|
|
10
|
+
* - Use `0` for baseline (yScale(0))
|
|
11
|
+
* - Use number | Date value for annotation (yScale(value))
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
x?: number | Date | boolean | 'left' | 'right';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Pixel offset to apply to `x` coordinate
|
|
19
|
+
*
|
|
20
|
+
* @default 0
|
|
21
|
+
*/
|
|
22
|
+
xOffset?: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a horizontal `y` line
|
|
26
|
+
* - If true or 'bottom', will draw at chart bottom (yRange[0])
|
|
27
|
+
* - If 'top', will draw at chart top (yRange[1])
|
|
28
|
+
* - Use `0` for baseline (xScale(0))
|
|
29
|
+
* - Use number | Date value for annotation (xScale(value))
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
y?: number | Date | boolean | 'top' | 'bottom';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Pixel offset to apply to `y` coordinate
|
|
37
|
+
* @default 0
|
|
38
|
+
*/
|
|
39
|
+
yOffset?: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type RulePropsWithoutHTML = BaseRulePropsWithoutHTML &
|
|
43
|
+
Without<Partial<LinePropsWithoutHTML>, BaseRulePropsWithoutHTML>;
|
|
44
|
+
|
|
45
|
+
export type RuleProps = RulePropsWithoutHTML &
|
|
46
|
+
Without<SVGAttributes<SVGElement>, RulePropsWithoutHTML>;
|
|
47
|
+
</script>
|
|
48
|
+
|
|
1
49
|
<script lang="ts">
|
|
2
50
|
import { extent } from 'd3-array';
|
|
3
51
|
import { pointRadial } from 'd3-shape';
|
|
4
52
|
import { cls } from '@layerstack/tailwind';
|
|
5
53
|
|
|
6
|
-
import { chartContext } from './ChartContext.svelte';
|
|
7
54
|
import Circle from './Circle.svelte';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* - If true or 'bottom', will draw at chart bottom (yRange[0])
|
|
30
|
-
* - If 'top', will draw at chart top (yRange[1])
|
|
31
|
-
* - Use `0` for baseline (xScale(0))
|
|
32
|
-
* - Use number | Date value for annotation (xScale(value))
|
|
33
|
-
*/
|
|
34
|
-
export let y: number | Date | boolean | 'top' | 'bottom' = false;
|
|
35
|
-
|
|
36
|
-
/** Pixel offset to apply to `y` coordinate */
|
|
37
|
-
export let yOffset = 0;
|
|
38
|
-
|
|
39
|
-
$: showRule = (value: typeof x | typeof y, axis: 'x' | 'y') => {
|
|
55
|
+
import Group from './Group.svelte';
|
|
56
|
+
import Line, { type LinePropsWithoutHTML } from './Line.svelte';
|
|
57
|
+
import { getChartContext } from './Chart.svelte';
|
|
58
|
+
import { layerClass } from '../utils/attributes.js';
|
|
59
|
+
|
|
60
|
+
let {
|
|
61
|
+
x = false,
|
|
62
|
+
xOffset = 0,
|
|
63
|
+
y = false,
|
|
64
|
+
yOffset = 0,
|
|
65
|
+
class: className,
|
|
66
|
+
children,
|
|
67
|
+
...restProps
|
|
68
|
+
}: RuleProps = $props();
|
|
69
|
+
|
|
70
|
+
const ctx = getChartContext();
|
|
71
|
+
|
|
72
|
+
const xRangeMinMax = $derived(extent<number | Date>(ctx.xRange));
|
|
73
|
+
const yRangeMinMax = $derived(extent<number | Date>(ctx.yRange));
|
|
74
|
+
|
|
75
|
+
function showRule(value: typeof x | typeof y, axis: 'x' | 'y') {
|
|
40
76
|
switch (typeof value) {
|
|
41
77
|
case 'boolean':
|
|
42
78
|
return value;
|
|
@@ -44,70 +80,78 @@
|
|
|
44
80
|
return true;
|
|
45
81
|
default:
|
|
46
82
|
if (axis === 'x') {
|
|
47
|
-
return
|
|
83
|
+
return ctx.xScale(value) >= xRangeMinMax[0]! && ctx.xScale(value) <= xRangeMinMax[1]!;
|
|
48
84
|
} else {
|
|
49
|
-
return
|
|
85
|
+
return ctx.yScale(value) >= yRangeMinMax[0]! && ctx.yScale(value) <= yRangeMinMax[1]!;
|
|
50
86
|
}
|
|
51
87
|
}
|
|
52
|
-
}
|
|
88
|
+
}
|
|
53
89
|
</script>
|
|
54
90
|
|
|
55
|
-
<
|
|
91
|
+
<Group class={layerClass('rule-g')}>
|
|
56
92
|
{#if showRule(x, 'x')}
|
|
57
93
|
{@const xCoord =
|
|
58
|
-
x === true || x === 'left'
|
|
94
|
+
x === true || x === 'left'
|
|
95
|
+
? xRangeMinMax[0]
|
|
96
|
+
: x === 'right'
|
|
97
|
+
? xRangeMinMax[1]
|
|
98
|
+
: ctx.xScale(x) + xOffset}
|
|
59
99
|
|
|
60
|
-
{#if
|
|
61
|
-
{@const [x1, y1] = pointRadial(xCoord, Number(
|
|
62
|
-
{@const [x2, y2] = pointRadial(xCoord, Number(
|
|
100
|
+
{#if ctx.radial}
|
|
101
|
+
{@const [x1, y1] = pointRadial(xCoord, Number(yRangeMinMax[0]))}
|
|
102
|
+
{@const [x2, y2] = pointRadial(xCoord, Number(yRangeMinMax[1]))}
|
|
63
103
|
|
|
64
104
|
<Line
|
|
105
|
+
{...restProps}
|
|
65
106
|
{x1}
|
|
66
107
|
{y1}
|
|
67
108
|
{x2}
|
|
68
109
|
{y2}
|
|
69
|
-
{
|
|
70
|
-
class={cls('stroke-surface-content/10', $$props.class)}
|
|
110
|
+
class={cls(layerClass('rule-x-radial-line'), 'stroke-surface-content/10', className)}
|
|
71
111
|
/>
|
|
72
112
|
{:else}
|
|
73
113
|
<Line
|
|
114
|
+
{...restProps}
|
|
74
115
|
x1={xCoord}
|
|
75
116
|
x2={xCoord}
|
|
76
|
-
y1={
|
|
77
|
-
y2={
|
|
78
|
-
{
|
|
79
|
-
class={cls('stroke-surface-content/50', $$props.class)}
|
|
117
|
+
y1={ctx.yRange[0] || 0}
|
|
118
|
+
y2={ctx.yRange[1] || 0}
|
|
119
|
+
class={cls(layerClass('rule-x-line'), 'stroke-surface-content/50', className)}
|
|
80
120
|
/>
|
|
81
121
|
{/if}
|
|
82
122
|
{/if}
|
|
83
123
|
|
|
84
124
|
{#if showRule(y, 'y')}
|
|
85
|
-
{#if
|
|
125
|
+
{#if ctx.radial}
|
|
86
126
|
<Circle
|
|
87
127
|
r={y === true || y === 'bottom'
|
|
88
|
-
?
|
|
128
|
+
? yRangeMinMax[1]
|
|
89
129
|
: y === 'top'
|
|
90
|
-
?
|
|
91
|
-
:
|
|
92
|
-
class={cls(
|
|
130
|
+
? yRangeMinMax[0]
|
|
131
|
+
: ctx.yScale(y) + yOffset}
|
|
132
|
+
class={cls(
|
|
133
|
+
layerClass('rule-y-radial-circle'),
|
|
134
|
+
'fill-none stroke-surface-content/50',
|
|
135
|
+
className
|
|
136
|
+
)}
|
|
93
137
|
/>
|
|
94
138
|
{:else}
|
|
95
139
|
<Line
|
|
96
|
-
|
|
97
|
-
|
|
140
|
+
{...restProps}
|
|
141
|
+
x1={ctx.xRange[0] || 0}
|
|
142
|
+
x2={ctx.xRange[1] || 0}
|
|
98
143
|
y1={y === true || y === 'bottom'
|
|
99
|
-
?
|
|
144
|
+
? yRangeMinMax[1]
|
|
100
145
|
: y === 'top'
|
|
101
|
-
?
|
|
102
|
-
:
|
|
146
|
+
? yRangeMinMax[0]
|
|
147
|
+
: ctx.yScale(y) + yOffset}
|
|
103
148
|
y2={y === true || y === 'bottom'
|
|
104
|
-
?
|
|
149
|
+
? yRangeMinMax[1]
|
|
105
150
|
: y === 'top'
|
|
106
|
-
?
|
|
107
|
-
:
|
|
108
|
-
{
|
|
109
|
-
class={cls('stroke-surface-content/50', $$props.class)}
|
|
151
|
+
? yRangeMinMax[0]
|
|
152
|
+
: ctx.yScale(y) + yOffset}
|
|
153
|
+
class={cls(layerClass('rule-y-line'), 'stroke-surface-content/50', className)}
|
|
110
154
|
/>
|
|
111
155
|
{/if}
|
|
112
156
|
{/if}
|
|
113
|
-
</
|
|
157
|
+
</Group>
|
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { Without } from '../utils/types.js';
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
export type BaseRulePropsWithoutHTML = {
|
|
4
|
+
/**
|
|
5
|
+
* Create a vertical `x` line
|
|
6
|
+
* - If true or 'left', will draw at chart left (xRange[0])
|
|
7
|
+
* - If 'right', will draw at chart right (xRange[1])
|
|
8
|
+
* - Use `0` for baseline (yScale(0))
|
|
9
|
+
* - Use number | Date value for annotation (yScale(value))
|
|
10
|
+
*
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
x?: number | Date | boolean | 'left' | 'right';
|
|
14
|
+
/**
|
|
15
|
+
* Pixel offset to apply to `x` coordinate
|
|
16
|
+
*
|
|
17
|
+
* @default 0
|
|
18
|
+
*/
|
|
19
|
+
xOffset?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Create a horizontal `y` line
|
|
22
|
+
* - If true or 'bottom', will draw at chart bottom (yRange[0])
|
|
23
|
+
* - If 'top', will draw at chart top (yRange[1])
|
|
24
|
+
* - Use `0` for baseline (xScale(0))
|
|
25
|
+
* - Use number | Date value for annotation (xScale(value))
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
y?: number | Date | boolean | 'top' | 'bottom';
|
|
30
|
+
/**
|
|
31
|
+
* Pixel offset to apply to `y` coordinate
|
|
32
|
+
* @default 0
|
|
33
|
+
*/
|
|
34
|
+
yOffset?: number;
|
|
14
35
|
};
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
36
|
+
export type RulePropsWithoutHTML = BaseRulePropsWithoutHTML & Without<Partial<LinePropsWithoutHTML>, BaseRulePropsWithoutHTML>;
|
|
37
|
+
export type RuleProps = RulePropsWithoutHTML & Without<SVGAttributes<SVGElement>, RulePropsWithoutHTML>;
|
|
38
|
+
import { type LinePropsWithoutHTML } from './Line.svelte';
|
|
39
|
+
declare const Rule: import("svelte").Component<RuleProps, {}, "">;
|
|
40
|
+
type Rule = ReturnType<typeof Rule>;
|
|
41
|
+
export default Rule;
|
|
@@ -1,3 +1,81 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type NodeExtraProperties = Record<string, any>;
|
|
5
|
+
|
|
6
|
+
export type SankeyProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The function to get the nodes from the data.
|
|
9
|
+
* @default (d: any) => d.nodes
|
|
10
|
+
*/
|
|
11
|
+
nodes?: (d: any) => any;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The function to get the node ID from the node data.
|
|
15
|
+
*
|
|
16
|
+
* @default (d: any) => d.index
|
|
17
|
+
*/
|
|
18
|
+
nodeId?: (d: any) => any;
|
|
19
|
+
/**
|
|
20
|
+
* @see https://github.com/d3/d3-sankey#alignments
|
|
21
|
+
*
|
|
22
|
+
* @default sankeyJustify
|
|
23
|
+
*/
|
|
24
|
+
nodeAlign?:
|
|
25
|
+
| ((node: SankeyNode<any, any>, n: number) => number)
|
|
26
|
+
| 'left'
|
|
27
|
+
| 'right'
|
|
28
|
+
| 'center'
|
|
29
|
+
| 'justify';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The width of the nodes.
|
|
33
|
+
*
|
|
34
|
+
* @default 4
|
|
35
|
+
*/
|
|
36
|
+
nodeWidth?: number;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The padding between nodes.
|
|
40
|
+
*
|
|
41
|
+
* @default 10
|
|
42
|
+
*/
|
|
43
|
+
nodePadding?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The function to sort the nodes.
|
|
47
|
+
*/
|
|
48
|
+
nodeSort?: (a: SankeyNode<any, any>, b: SankeyNode<any, any>) => number | undefined;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The function to get the links from the data.
|
|
52
|
+
*
|
|
53
|
+
* @default (d: any) => d.links
|
|
54
|
+
*/
|
|
55
|
+
links?: (d: any) => any;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The function to sort the links.
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
linkSort?: (a: SankeyLink<any, any>, b: SankeyLink<any, any>) => number | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A function to be called when the data is updated.
|
|
65
|
+
*/
|
|
66
|
+
onUpdate?: (data: SankeyGraph<{}, {}>) => void;
|
|
67
|
+
|
|
68
|
+
children?: Snippet<
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
nodes: SankeyNode<NodeExtraProperties, any>[];
|
|
72
|
+
links: SankeyNode<NodeExtraProperties, any>[];
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
>;
|
|
76
|
+
};
|
|
77
|
+
</script>
|
|
78
|
+
|
|
1
79
|
<script lang="ts">
|
|
2
80
|
// https://github.com/d3/d3-sankey
|
|
3
81
|
import {
|
|
@@ -8,62 +86,61 @@
|
|
|
8
86
|
sankeyJustify,
|
|
9
87
|
type SankeyNode,
|
|
10
88
|
type SankeyLink,
|
|
89
|
+
type SankeyGraph,
|
|
11
90
|
} from 'd3-sankey';
|
|
12
91
|
|
|
13
|
-
import {
|
|
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
|
-
type NodeExtraProperties = Record<string, any>;
|
|
63
|
-
$: _nodes = sankeyData.nodes as SankeyNode<NodeExtraProperties, any>[];
|
|
64
|
-
$: _links = sankeyData.links as SankeyLink<NodeExtraProperties, any>[];
|
|
65
|
-
|
|
66
|
-
$: onupdate?.(sankeyData);
|
|
92
|
+
import { getChartContext } from './Chart.svelte';
|
|
93
|
+
|
|
94
|
+
let {
|
|
95
|
+
nodes: nodesProp = (d: any) => d.nodes,
|
|
96
|
+
nodeId = (d: any) => d.index,
|
|
97
|
+
nodeAlign = sankeyJustify,
|
|
98
|
+
nodeWidth = 4,
|
|
99
|
+
nodePadding = 10,
|
|
100
|
+
nodeSort,
|
|
101
|
+
links: linksProp = (d: any) => d.links,
|
|
102
|
+
linkSort,
|
|
103
|
+
onUpdate,
|
|
104
|
+
children,
|
|
105
|
+
}: SankeyProps = $props();
|
|
106
|
+
|
|
107
|
+
const ctx = getChartContext();
|
|
108
|
+
|
|
109
|
+
const sankeyData = $derived.by(() => {
|
|
110
|
+
if (typeof document === 'undefined') return { nodes: [], links: [] };
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
d3Sankey()
|
|
114
|
+
.size([ctx.width, ctx.height])
|
|
115
|
+
.nodes(nodesProp)
|
|
116
|
+
.nodeId(nodeId)
|
|
117
|
+
.nodeAlign(
|
|
118
|
+
nodeAlign === 'left'
|
|
119
|
+
? sankeyLeft
|
|
120
|
+
: nodeAlign === 'center'
|
|
121
|
+
? sankeyCenter
|
|
122
|
+
: nodeAlign === 'right'
|
|
123
|
+
? sankeyRight
|
|
124
|
+
: nodeAlign === 'justify'
|
|
125
|
+
? sankeyJustify
|
|
126
|
+
: nodeAlign
|
|
127
|
+
)
|
|
128
|
+
.nodeWidth(nodeWidth)
|
|
129
|
+
.nodePadding(nodePadding)
|
|
130
|
+
// @ts-expect-error
|
|
131
|
+
.nodeSort(nodeSort)
|
|
132
|
+
.links(linksProp)
|
|
133
|
+
// @ts-expect-error
|
|
134
|
+
.linkSort(linkSort)(structuredClone(ctx.data))
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
$effect(() => {
|
|
139
|
+
onUpdate?.(sankeyData);
|
|
140
|
+
});
|
|
67
141
|
</script>
|
|
68
142
|
|
|
69
|
-
|
|
143
|
+
{@render children?.({
|
|
144
|
+
nodes: sankeyData.nodes,
|
|
145
|
+
links: sankeyData.links,
|
|
146
|
+
})}
|