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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
import { type MotionProp } from '../utils/motion.svelte.js';
|
|
4
|
+
export type TextPropsWithoutHTML = {
|
|
5
|
+
/**
|
|
6
|
+
* text value
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
value?: string | number;
|
|
10
|
+
/**
|
|
11
|
+
* The fill color of the text
|
|
12
|
+
*/
|
|
13
|
+
fill?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum width to occupy (approximate as words are not split)
|
|
16
|
+
*/
|
|
17
|
+
width?: number;
|
|
18
|
+
/**
|
|
19
|
+
* x position of the text
|
|
20
|
+
*
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
x?: string | number;
|
|
24
|
+
/**
|
|
25
|
+
* Initial x position of the text
|
|
26
|
+
*
|
|
27
|
+
* @default x
|
|
28
|
+
*/
|
|
29
|
+
initialX?: string | number;
|
|
30
|
+
/**
|
|
31
|
+
* y position of the text
|
|
32
|
+
*
|
|
33
|
+
* @default 0
|
|
34
|
+
*/
|
|
35
|
+
y?: string | number;
|
|
36
|
+
/**
|
|
37
|
+
* Initial y position of the text
|
|
38
|
+
*
|
|
39
|
+
* @default y
|
|
40
|
+
*/
|
|
41
|
+
initialY?: string | number;
|
|
42
|
+
/**
|
|
43
|
+
* dx offset of the text
|
|
44
|
+
*
|
|
45
|
+
* @default 0
|
|
46
|
+
*/
|
|
47
|
+
dx?: string | number;
|
|
48
|
+
/**
|
|
49
|
+
* dy offset of the text
|
|
50
|
+
*
|
|
51
|
+
* @default 0
|
|
52
|
+
*/
|
|
53
|
+
dy?: string | number;
|
|
54
|
+
/**
|
|
55
|
+
* Desired "line height" of the text, implemented as y offsets
|
|
56
|
+
*
|
|
57
|
+
* @default "1em"
|
|
58
|
+
*/
|
|
59
|
+
lineHeight?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Cap height of the text
|
|
62
|
+
* @default '0.71em'
|
|
63
|
+
*/
|
|
64
|
+
capHeight?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Whether to scale the fontSize to accommodate the specified width
|
|
67
|
+
*
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
scaleToFit?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Horizontal text anchor
|
|
73
|
+
*
|
|
74
|
+
* @default 'start'
|
|
75
|
+
*/
|
|
76
|
+
textAnchor?: 'start' | 'middle' | 'end' | 'inherit';
|
|
77
|
+
/**
|
|
78
|
+
* Vertical text anchor
|
|
79
|
+
*
|
|
80
|
+
* @default 'end'
|
|
81
|
+
*/
|
|
82
|
+
verticalAnchor?: 'start' | 'middle' | 'end' | 'inherit';
|
|
83
|
+
/**
|
|
84
|
+
* Rotational angle of the text
|
|
85
|
+
*/
|
|
86
|
+
rotate?: number;
|
|
87
|
+
/**
|
|
88
|
+
* A bindable reference to the wrapping `<svg>` element.
|
|
89
|
+
*
|
|
90
|
+
* @bindable
|
|
91
|
+
*/
|
|
92
|
+
svgRef?: SVGElement;
|
|
93
|
+
/**
|
|
94
|
+
* Props to pass to the wrapping `<svg>` element.
|
|
95
|
+
*/
|
|
96
|
+
svgProps?: Omit<SVGAttributes<SVGElement>, 'children'>;
|
|
97
|
+
/**
|
|
98
|
+
* A bindable reference to the inner `<text>` element
|
|
99
|
+
*
|
|
100
|
+
* @bindable
|
|
101
|
+
*/
|
|
102
|
+
ref?: SVGTextElement;
|
|
103
|
+
motion?: MotionProp;
|
|
104
|
+
/**
|
|
105
|
+
* Whether to enable text truncation
|
|
106
|
+
*/
|
|
107
|
+
truncate?: boolean | TruncateTextOptions;
|
|
108
|
+
/**
|
|
109
|
+
* A unique identifier for the SVG path element.
|
|
110
|
+
* One is generated by default if not provided.
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
pathId?: string;
|
|
114
|
+
/**
|
|
115
|
+
* The path to render the text along.
|
|
116
|
+
*/
|
|
117
|
+
path?: string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Specify the offset for the start of the text along the path.
|
|
120
|
+
* Can be a percentage ('50%') or a length value.
|
|
121
|
+
*
|
|
122
|
+
* @default '0%'
|
|
123
|
+
*/
|
|
124
|
+
startOffset?: string | number;
|
|
125
|
+
} & CommonStyleProps;
|
|
126
|
+
export type TextProps = TextPropsWithoutHTML & Without<SVGAttributes<SVGTextElement>, TextPropsWithoutHTML>;
|
|
127
|
+
import { type TruncateTextOptions } from '../utils/string.js';
|
|
128
|
+
declare const Text: import("svelte").Component<TextProps, {}, "ref" | "svgRef">;
|
|
129
|
+
type Text = ReturnType<typeof Text>;
|
|
130
|
+
export default Text;
|
|
@@ -1,40 +1,72 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
3
|
+
import type { CurveFactory } from 'd3-shape';
|
|
4
|
+
export type ThresholdSnippetProps = {
|
|
5
|
+
curve?: CurveFactory;
|
|
6
|
+
defined?: ComponentProps<typeof Area>['defined'];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ThresholdProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The curve factory to use for the area.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
curve?: CurveFactory;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Function to determine if a point is defined.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
defined?: ComponentProps<typeof Area>['defined'];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Content to render above the threshold area.
|
|
24
|
+
*/
|
|
25
|
+
above?: Snippet<[ThresholdSnippetProps]>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Content to render below the threshold area.
|
|
29
|
+
*/
|
|
30
|
+
below?: Snippet<[ThresholdSnippetProps]>;
|
|
31
|
+
|
|
32
|
+
children?: Snippet<[ThresholdSnippetProps]>;
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
35
|
+
|
|
1
36
|
<script lang="ts">
|
|
2
37
|
/*
|
|
3
38
|
See also:
|
|
4
39
|
- https://observablehq.com/@d3/difference-chart
|
|
5
40
|
- https://github.com/airbnb/visx/issues/245
|
|
6
41
|
*/
|
|
7
|
-
|
|
8
|
-
import type { CurveFactory } from 'd3-shape';
|
|
42
|
+
|
|
9
43
|
import { min } from 'd3-array';
|
|
10
44
|
|
|
11
|
-
import { chartContext } from './ChartContext.svelte';
|
|
12
45
|
import Area from './Area.svelte';
|
|
13
46
|
import ClipPath from './ClipPath.svelte';
|
|
47
|
+
import { getChartContext } from './Chart.svelte';
|
|
14
48
|
|
|
15
|
-
const
|
|
49
|
+
const ctx = getChartContext();
|
|
16
50
|
|
|
17
|
-
|
|
18
|
-
export let defined: ComponentProps<Area>['defined'] | undefined = undefined;
|
|
51
|
+
let { curve, defined, below, above, children }: ThresholdProps = $props();
|
|
19
52
|
</script>
|
|
20
53
|
|
|
21
54
|
<!-- Recreate on curve change as otherwise is 1 state change behind for some reason -->
|
|
22
55
|
{#key curve}
|
|
23
56
|
<ClipPath>
|
|
24
|
-
|
|
25
|
-
<Area y0={(d) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<slot name="above" {curve} {defined} />
|
|
57
|
+
{#snippet clip()}
|
|
58
|
+
<Area y0={(d) => ctx.y(d)[0]} y1={(d) => min(ctx.yDomain)} {curve} {defined} />
|
|
59
|
+
{/snippet}
|
|
60
|
+
{@render above?.({ curve, defined })}
|
|
29
61
|
</ClipPath>
|
|
30
62
|
|
|
31
63
|
<ClipPath>
|
|
32
|
-
|
|
33
|
-
<Area y0={(d) => min(
|
|
34
|
-
|
|
64
|
+
{#snippet clip()}
|
|
65
|
+
<Area y0={(d) => min(ctx.yDomain)} y1={(d) => ctx.y(d)[1]} {curve} {defined} />
|
|
66
|
+
{/snippet}
|
|
35
67
|
|
|
36
|
-
|
|
68
|
+
{@render below?.({ curve, defined })}
|
|
37
69
|
</ClipPath>
|
|
38
70
|
|
|
39
|
-
|
|
71
|
+
{@render children?.({ curve, defined })}
|
|
40
72
|
{/key}
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ComponentProps } from 'svelte';
|
|
1
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
3
2
|
import type { CurveFactory } from 'd3-shape';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
export type ThresholdSnippetProps = {
|
|
4
|
+
curve?: CurveFactory;
|
|
5
|
+
defined?: ComponentProps<typeof Area>['defined'];
|
|
6
|
+
};
|
|
7
|
+
export type ThresholdProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The curve factory to use for the area.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
curve?: CurveFactory;
|
|
13
|
+
/**
|
|
14
|
+
* Function to determine if a point is defined.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
defined?: ComponentProps<typeof Area>['defined'];
|
|
18
|
+
/**
|
|
19
|
+
* Content to render above the threshold area.
|
|
20
|
+
*/
|
|
21
|
+
above?: Snippet<[ThresholdSnippetProps]>;
|
|
22
|
+
/**
|
|
23
|
+
* Content to render below the threshold area.
|
|
24
|
+
*/
|
|
25
|
+
below?: Snippet<[ThresholdSnippetProps]>;
|
|
26
|
+
children?: Snippet<[ThresholdSnippetProps]>;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export default
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
28
|
+
import Area from './Area.svelte';
|
|
29
|
+
declare const Threshold: import("svelte").Component<ThresholdProps, {}, "">;
|
|
30
|
+
type Threshold = ReturnType<typeof Threshold>;
|
|
31
|
+
export default Threshold;
|
|
@@ -1,35 +1,98 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Without } from '../utils/types.js';
|
|
3
|
+
|
|
2
4
|
let tileCache = new Map<string, Promise<string>>();
|
|
5
|
+
|
|
6
|
+
export type TileImagePropsWithoutHTML = {
|
|
7
|
+
/**
|
|
8
|
+
* x position of the tile
|
|
9
|
+
*/
|
|
10
|
+
x: number;
|
|
11
|
+
/**
|
|
12
|
+
* y position of the tile
|
|
13
|
+
*/
|
|
14
|
+
y: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* z position of the tile
|
|
18
|
+
*/
|
|
19
|
+
z: number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* translate x
|
|
23
|
+
*/
|
|
24
|
+
tx: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* translate y
|
|
28
|
+
|
|
29
|
+
*/
|
|
30
|
+
ty: number;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* scale of the tile
|
|
34
|
+
*/
|
|
35
|
+
scale: number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Whether to disable cache
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
disableCache?: boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether to enable debug mode
|
|
46
|
+
*
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
debug?: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* URL function to get the tile image
|
|
53
|
+
*/
|
|
54
|
+
url: (x: number, y: number, z: number) => string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type TileImageProps = TileImagePropsWithoutHTML &
|
|
58
|
+
Omit<Without<SVGAttributes<SVGImageElement>, TileImagePropsWithoutHTML>, 'href'>;
|
|
3
59
|
</script>
|
|
4
60
|
|
|
5
61
|
<script lang="ts">
|
|
6
|
-
import
|
|
62
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
7
63
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** translate x */
|
|
12
|
-
export let tx: number;
|
|
13
|
-
/** translate y */
|
|
14
|
-
export let ty: number;
|
|
15
|
-
export let scale: number;
|
|
16
|
-
|
|
17
|
-
export let disableCache = false;
|
|
18
|
-
export let debug = false;
|
|
64
|
+
import Text from './Text.svelte';
|
|
65
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
66
|
+
import { onMount } from 'svelte';
|
|
19
67
|
|
|
20
|
-
|
|
68
|
+
let {
|
|
69
|
+
x,
|
|
70
|
+
y,
|
|
71
|
+
z,
|
|
72
|
+
tx,
|
|
73
|
+
ty,
|
|
74
|
+
scale,
|
|
75
|
+
disableCache = false,
|
|
76
|
+
debug = false,
|
|
77
|
+
url,
|
|
78
|
+
...restProps
|
|
79
|
+
}: TileImageProps = $props();
|
|
21
80
|
|
|
22
81
|
// if disable cache, set href immediately, otherwise set from cache / dataUri
|
|
23
|
-
let href = disableCache ? url(x, y, z) : '';
|
|
82
|
+
let href = $state(disableCache ? url(x, y, z) : '');
|
|
83
|
+
|
|
24
84
|
function loadImage(url: string) {
|
|
25
85
|
// const key = [x, y, z].join('-');
|
|
26
86
|
const key = url;
|
|
27
87
|
|
|
28
88
|
if (tileCache.has(key)) {
|
|
29
|
-
tileCache
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
89
|
+
tileCache
|
|
90
|
+
.get(key)
|
|
91
|
+
?.then((dataUri) => {
|
|
92
|
+
// console.log('from cache', { x, y, z });
|
|
93
|
+
href = dataUri;
|
|
94
|
+
})
|
|
95
|
+
.catch(() => {});
|
|
33
96
|
} else {
|
|
34
97
|
const promise = new Promise<string>((resolve, reject) => {
|
|
35
98
|
const img = new Image();
|
|
@@ -58,21 +121,31 @@
|
|
|
58
121
|
}
|
|
59
122
|
}
|
|
60
123
|
|
|
61
|
-
|
|
62
|
-
|
|
124
|
+
$effect(() => {
|
|
125
|
+
if (disableCache) return;
|
|
63
126
|
loadImage(url(x, y, z));
|
|
64
|
-
}
|
|
127
|
+
});
|
|
65
128
|
</script>
|
|
66
129
|
|
|
67
130
|
<!-- To avoid aliasing artifacts (thin white lines) between tiles, two layers of tiles are drawn, with the lower layer’s tiles enlarged by one pixel -->
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
131
|
+
{#key href}
|
|
132
|
+
<image
|
|
133
|
+
{href}
|
|
134
|
+
x={(x + tx) * scale - 0.5}
|
|
135
|
+
y={(y + ty) * scale - 0.5}
|
|
136
|
+
width={scale + 1}
|
|
137
|
+
height={scale + 1}
|
|
138
|
+
{...extractLayerProps(restProps, 'tile-image-lower')}
|
|
139
|
+
/>
|
|
140
|
+
<image
|
|
141
|
+
{href}
|
|
142
|
+
x={(x + tx) * scale}
|
|
143
|
+
y={(y + ty) * scale}
|
|
144
|
+
width={scale}
|
|
145
|
+
height={scale}
|
|
146
|
+
{...extractLayerProps(restProps, 'tile-image')}
|
|
147
|
+
/>
|
|
148
|
+
{/key}
|
|
76
149
|
{#if debug}
|
|
77
150
|
<rect
|
|
78
151
|
x={(x + tx) * scale}
|
|
@@ -1,24 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import type { Without } from '../utils/types.js';
|
|
2
|
+
export type TileImagePropsWithoutHTML = {
|
|
3
|
+
/**
|
|
4
|
+
* x position of the tile
|
|
5
|
+
*/
|
|
6
|
+
x: number;
|
|
7
|
+
/**
|
|
8
|
+
* y position of the tile
|
|
9
|
+
*/
|
|
10
|
+
y: number;
|
|
11
|
+
/**
|
|
12
|
+
* z position of the tile
|
|
13
|
+
*/
|
|
14
|
+
z: number;
|
|
15
|
+
/**
|
|
16
|
+
* translate x
|
|
17
|
+
*/
|
|
18
|
+
tx: number;
|
|
19
|
+
/**
|
|
20
|
+
* translate y
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
ty: number;
|
|
24
|
+
/**
|
|
25
|
+
* scale of the tile
|
|
26
|
+
*/
|
|
27
|
+
scale: number;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to disable cache
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
disableCache?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to enable debug mode
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
debug?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* URL function to get the tile image
|
|
42
|
+
*/
|
|
43
|
+
url: (x: number, y: number, z: number) => string;
|
|
18
44
|
};
|
|
19
|
-
export type TileImageProps =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export {};
|
|
45
|
+
export type TileImageProps = TileImagePropsWithoutHTML & Omit<Without<SVGAttributes<SVGImageElement>, TileImagePropsWithoutHTML>, 'href'>;
|
|
46
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
47
|
+
declare const TileImage: import("svelte").Component<TileImageProps, {}, "">;
|
|
48
|
+
type TileImage = ReturnType<typeof TileImage>;
|
|
49
|
+
export default TileImage;
|