layerchart 2.0.0-next.44 → 2.0.0-next.45
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/LICENSE +1 -1
- package/dist/components/AnnotationLine.svelte +1 -1
- package/dist/components/AnnotationPoint.svelte +1 -1
- package/dist/components/AnnotationRange.svelte +16 -15
- package/dist/components/Arc.svelte +10 -10
- package/dist/components/Arc.svelte.d.ts +4 -4
- package/dist/components/Arc.svelte.test.d.ts +1 -0
- package/dist/components/Arc.svelte.test.js +868 -0
- package/dist/components/Area.svelte +9 -7
- package/dist/components/Axis.svelte +2 -1
- package/dist/components/Axis.svelte.d.ts +1 -0
- package/dist/components/Bar.svelte +3 -3
- package/dist/components/Bars.svelte +1 -1
- package/dist/components/Blur.svelte +3 -3
- package/dist/components/Bounds.svelte +1 -1
- package/dist/components/BrushContext.svelte +1 -1
- package/dist/components/Calendar.svelte +2 -2
- package/dist/components/Calendar.svelte.d.ts +1 -1
- package/dist/components/Chart.svelte +63 -137
- package/dist/components/Chart.svelte.d.ts +23 -88
- package/dist/components/ChartClipPath.svelte +1 -1
- package/dist/components/Circle.svelte +17 -8
- package/dist/components/Circle.svelte.d.ts +3 -0
- package/dist/components/ClipPath.svelte +4 -4
- package/dist/components/Connector.svelte +4 -4
- package/dist/components/Connector.svelte.d.ts +3 -3
- package/dist/components/Ellipse.svelte +7 -7
- package/dist/components/Frame.svelte +1 -1
- package/dist/components/GeoContext.svelte +4 -20
- package/dist/components/GeoContext.svelte.d.ts +2 -6
- package/dist/components/GeoEdgeFade.svelte +1 -1
- package/dist/components/GeoPath.svelte +42 -107
- package/dist/components/GeoPath.svelte.d.ts +5 -4
- package/dist/components/GeoPoint.svelte +5 -5
- package/dist/components/GeoSpline.svelte +2 -14
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/GeoTile.svelte +7 -6
- package/dist/components/GeoVisible.svelte +1 -1
- package/dist/components/Graticule.svelte +4 -7
- package/dist/components/Graticule.svelte.d.ts +2 -1
- package/dist/components/Grid.svelte +1 -1
- package/dist/components/Group.svelte +8 -8
- package/dist/components/Highlight.svelte +18 -16
- package/dist/components/Hull.svelte +2 -2
- package/dist/components/Labels.svelte +1 -1
- package/dist/components/Legend.svelte +1 -1
- package/dist/components/Line.svelte +9 -7
- package/dist/components/LinearGradient.svelte +8 -7
- package/dist/components/MonthPath.svelte +5 -11
- package/dist/components/MonthPath.svelte.d.ts +2 -2
- package/dist/components/Pack.svelte +4 -6
- package/dist/components/Pack.svelte.d.ts +2 -4
- package/dist/components/Partition.svelte +4 -3
- package/dist/components/Partition.svelte.d.ts +2 -1
- package/dist/components/Path.svelte +344 -0
- package/dist/components/Path.svelte.d.ts +72 -0
- package/dist/components/Pattern.svelte +6 -6
- package/dist/components/Pie.svelte +2 -2
- package/dist/components/Pie.svelte.d.ts +1 -1
- package/dist/components/Point.svelte +1 -1
- package/dist/components/Points.svelte +1 -1
- package/dist/components/Polygon.svelte +8 -6
- package/dist/components/RadialGradient.svelte +7 -7
- package/dist/components/Rect.svelte +32 -10
- package/dist/components/Rect.svelte.d.ts +4 -1
- package/dist/components/Rule.svelte +1 -1
- package/dist/components/Sankey.svelte +1 -1
- package/dist/components/Spline.svelte +13 -337
- package/dist/components/Spline.svelte.d.ts +10 -73
- package/dist/components/Text.svelte +9 -7
- package/dist/components/Threshold.svelte +3 -3
- package/dist/components/TransformContext.svelte +10 -143
- package/dist/components/TransformControls.svelte +2 -2
- package/dist/components/TransformControls.svelte.d.ts +1 -1
- package/dist/components/Tree.svelte +4 -3
- package/dist/components/Tree.svelte.d.ts +2 -1
- package/dist/components/Treemap.svelte +4 -3
- package/dist/components/Treemap.svelte.d.ts +2 -1
- package/dist/components/Voronoi.svelte +5 -5
- package/dist/components/charts/ArcChart.svelte +14 -6
- package/dist/components/charts/ArcChart.svelte.d.ts +1 -1
- package/dist/components/charts/AreaChart.svelte +12 -6
- package/dist/components/charts/BarChart.svelte +12 -6
- package/dist/components/charts/DefaultTooltip.svelte +1 -1
- package/dist/components/charts/LineChart.svelte +12 -6
- package/dist/components/charts/PieChart.svelte +14 -6
- package/dist/components/charts/PieChart.svelte.d.ts +1 -1
- package/dist/components/charts/ScatterChart.svelte +11 -9
- package/dist/components/charts/types.d.ts +7 -6
- package/dist/components/index.d.ts +14 -12
- package/dist/components/index.js +14 -12
- package/dist/components/{layout → layers}/Canvas.svelte +13 -60
- package/dist/components/{layout → layers}/Canvas.svelte.d.ts +2 -32
- package/dist/components/{layout → layers}/Html.svelte +18 -3
- package/dist/components/{layout → layers}/Html.svelte.d.ts +7 -0
- package/dist/components/layers/Layer.svelte +85 -0
- package/dist/components/{layout → layers}/Layer.svelte.d.ts +7 -3
- package/dist/components/{layout → layers}/Svg.svelte +18 -3
- package/dist/components/{layout → layers}/Svg.svelte.d.ts +7 -0
- package/dist/components/{layout → layers}/WebGL.svelte +1 -1
- package/dist/components/{layout → layers}/WebGL.svelte.d.ts +3 -3
- package/dist/components/tests/TestHarness.svelte +76 -0
- package/dist/components/tests/TestHarness.svelte.d.ts +19 -0
- package/dist/components/tooltip/Tooltip.svelte +3 -3
- package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContext.svelte +13 -45
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +2 -14
- package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
- package/dist/components/tooltip/tooltipMetaContext.js +2 -2
- package/dist/contexts/canvas.d.ts +33 -0
- package/dist/contexts/canvas.js +14 -0
- package/dist/contexts/chart.d.ts +84 -0
- package/dist/contexts/chart.js +10 -0
- package/dist/contexts/geo.d.ts +6 -0
- package/dist/contexts/geo.js +12 -0
- package/dist/contexts/index.d.ts +6 -0
- package/dist/contexts/index.js +6 -0
- package/dist/contexts/layer.d.ts +3 -0
- package/dist/contexts/layer.js +8 -0
- package/dist/contexts/settings.d.ts +4 -0
- package/dist/contexts/settings.js +10 -0
- package/dist/contexts/tooltip.d.ts +15 -0
- package/dist/contexts/tooltip.js +8 -0
- package/dist/contexts/transform.d.ts +95 -0
- package/dist/contexts/transform.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/states/settings.svelte.d.ts +12 -0
- package/dist/states/settings.svelte.js +10 -0
- package/dist/states/transform.svelte.d.ts +9 -0
- package/dist/states/transform.svelte.js +31 -0
- package/dist/utils/arcText.svelte.d.ts +1 -1
- package/dist/utils/canvas.d.ts +7 -3
- package/dist/utils/canvas.js +78 -11
- package/dist/utils/common.d.ts +8 -1
- package/dist/utils/common.js +9 -10
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/motion.svelte.js +0 -1
- package/dist/utils/rect.svelte.d.ts +1 -1
- package/dist/utils/rect.svelte.js +17 -9
- package/dist/utils/string.d.ts +3 -1
- package/package.json +32 -54
- package/README.md +0 -41
- package/dist/components/layout/Layer.svelte +0 -41
- package/dist/docs/Blockquote.svelte +0 -17
- package/dist/docs/Blockquote.svelte.d.ts +0 -5
- package/dist/docs/Code.svelte +0 -80
- package/dist/docs/Code.svelte.d.ts +0 -14
- package/dist/docs/ConnectorSweepMenuField.svelte +0 -17
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +0 -7
- package/dist/docs/ConnectorTypeMenuField.svelte +0 -17
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +0 -7
- package/dist/docs/CurveMenuField.svelte +0 -44
- package/dist/docs/CurveMenuField.svelte.d.ts +0 -9
- package/dist/docs/GeoDebug.svelte +0 -60
- package/dist/docs/GeoDebug.svelte.d.ts +0 -4
- package/dist/docs/Header1.svelte +0 -16
- package/dist/docs/Header1.svelte.d.ts +0 -5
- package/dist/docs/Json.svelte +0 -36
- package/dist/docs/Json.svelte.d.ts +0 -10
- package/dist/docs/Layout.svelte +0 -21
- package/dist/docs/Layout.svelte.d.ts +0 -8
- package/dist/docs/Link.svelte +0 -9
- package/dist/docs/Link.svelte.d.ts +0 -5
- package/dist/docs/PathDataMenuField.svelte +0 -78
- package/dist/docs/PathDataMenuField.svelte.d.ts +0 -9
- package/dist/docs/Preview.svelte +0 -104
- package/dist/docs/Preview.svelte.d.ts +0 -13
- package/dist/docs/TilesetField.svelte +0 -136
- package/dist/docs/TilesetField.svelte.d.ts +0 -6
- package/dist/docs/TransformDebug.svelte +0 -22
- package/dist/docs/TransformDebug.svelte.d.ts +0 -20
- package/dist/docs/ViewSourceButton.svelte +0 -53
- package/dist/docs/ViewSourceButton.svelte.d.ts +0 -11
- /package/dist/{utils → contexts}/legendPayload.d.ts +0 -0
- /package/dist/{utils → contexts}/legendPayload.js +0 -0
|
@@ -180,10 +180,10 @@
|
|
|
180
180
|
|
|
181
181
|
<script lang="ts">
|
|
182
182
|
import { cls } from '@layerstack/tailwind';
|
|
183
|
-
import { merge } from '
|
|
183
|
+
import { merge } from '@layerstack/utils';
|
|
184
184
|
|
|
185
|
-
import {
|
|
186
|
-
import { registerCanvasComponent } from './
|
|
185
|
+
import { getLayerContext } from '../contexts/layer.js';
|
|
186
|
+
import { registerCanvasComponent } from './layers/Canvas.svelte';
|
|
187
187
|
import { getStringWidth, truncateText, type TruncateTextOptions } from '../utils/string.js';
|
|
188
188
|
import { getComputedStyles, renderText, type ComputedStylesOptions } from '../utils/canvas.js';
|
|
189
189
|
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
...restProps
|
|
228
228
|
}: TextProps = $props();
|
|
229
229
|
|
|
230
|
-
const
|
|
230
|
+
const layerCtx = getLayerContext();
|
|
231
231
|
|
|
232
232
|
let ref = $state<SVGTextElement>();
|
|
233
233
|
let svgRef = $state<SVGElement>();
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
const fillKey = createKey(() => fill);
|
|
447
447
|
const strokeKey = createKey(() => stroke);
|
|
448
448
|
|
|
449
|
-
if (
|
|
449
|
+
if (layerCtx === 'canvas') {
|
|
450
450
|
registerCanvasComponent({
|
|
451
451
|
name: 'Text',
|
|
452
452
|
render,
|
|
@@ -469,7 +469,7 @@
|
|
|
469
469
|
}
|
|
470
470
|
</script>
|
|
471
471
|
|
|
472
|
-
{#if
|
|
472
|
+
{#if layerCtx === 'svg'}
|
|
473
473
|
<!-- `overflow: visible` allow contents to be shown outside element -->
|
|
474
474
|
<!-- `paint-order: stroke` supports stroke outlining text -->
|
|
475
475
|
<svg x={dx} y={dy} {...svgProps} class={['lc-text-svg', svgProps?.class]} bind:this={svgRef}>
|
|
@@ -529,7 +529,7 @@
|
|
|
529
529
|
</text>
|
|
530
530
|
{/if}
|
|
531
531
|
</svg>
|
|
532
|
-
{:else if
|
|
532
|
+
{:else if layerCtx === 'html'}
|
|
533
533
|
{@const translateX = textAnchor === 'middle' ? '-50%' : textAnchor === 'end' ? '-100%' : '0%'}
|
|
534
534
|
{@const translateY =
|
|
535
535
|
verticalAnchor === 'middle' ? '-50%' : verticalAnchor === 'end' ? '-100%' : '0%'}
|
|
@@ -547,6 +547,8 @@
|
|
|
547
547
|
? 'bottom'
|
|
548
548
|
: 'top'}
|
|
549
549
|
{textAnchor === 'middle' ? 'center' : textAnchor === 'end' ? 'right' : 'left'}"
|
|
550
|
+
style:white-space="pre-wrap"
|
|
551
|
+
style:line-height={lineHeight}
|
|
550
552
|
class={['lc-text', className]}
|
|
551
553
|
>
|
|
552
554
|
{textValue}
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
- https://github.com/airbnb/visx/issues/245
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
|
-
import { min } from 'd3-array';
|
|
43
|
+
import { min, max } from 'd3-array';
|
|
44
44
|
|
|
45
45
|
import Area from './Area.svelte';
|
|
46
46
|
import ClipPath from './ClipPath.svelte';
|
|
47
|
-
import { getChartContext } from '
|
|
47
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
48
48
|
|
|
49
49
|
const ctx = getChartContext();
|
|
50
50
|
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
{#key curve}
|
|
56
56
|
<ClipPath>
|
|
57
57
|
{#snippet clip()}
|
|
58
|
-
<Area y0={(d) => ctx.y(d)[
|
|
58
|
+
<Area y0={(d) => ctx.y(d)[1]} y1={(d) => max(ctx.yDomain)} {curve} {defined} />
|
|
59
59
|
{/snippet}
|
|
60
60
|
{@render above?.({ curve, defined })}
|
|
61
61
|
</ClipPath>
|
|
@@ -1,145 +1,12 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type TransformContextValue = {
|
|
11
|
-
/**
|
|
12
|
-
* The current transform mode.
|
|
13
|
-
*
|
|
14
|
-
* - `canvas`: The transform is applied to the canvas element.
|
|
15
|
-
* - `manual`: The transform is applied manually.
|
|
16
|
-
* - `none`: No transform is applied.
|
|
17
|
-
*/
|
|
18
|
-
mode: TransformMode;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The current scale of the transform.
|
|
22
|
-
*/
|
|
23
|
-
scale: number;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Set the scale of the transform
|
|
27
|
-
* @param value - the scale value to set
|
|
28
|
-
* @param options - motion options to apply to the transform (defaults to the motion options passed to the component)
|
|
29
|
-
*/
|
|
30
|
-
setScale(value: number, options?: MotionProp): void;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The current translate of the transform.
|
|
34
|
-
*/
|
|
35
|
-
translate: { x: number; y: number };
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Set the translate of the transform
|
|
39
|
-
* @param point - the point to translate to
|
|
40
|
-
* @param options - motion options to apply to the transform (defaults to the motion options passed to the component)
|
|
41
|
-
*/
|
|
42
|
-
setTranslate(point: { x: number; y: number }, options?: MotionProp): void;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Whether the transform is currently being moved
|
|
46
|
-
*/
|
|
47
|
-
moving: boolean;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Whether the transform is currently being dragged
|
|
51
|
-
*/
|
|
52
|
-
dragging: boolean;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The scroll mode of the transform.
|
|
56
|
-
*
|
|
57
|
-
* - `scale`: Scrolling will zoom in/out the canvas.
|
|
58
|
-
* - `translate`: Scrolling will pan the canvas.
|
|
59
|
-
* - `none`: No scroll mode is applied.
|
|
60
|
-
*/
|
|
61
|
-
scrollMode: TransformScrollMode;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Set the scroll mode of the transform
|
|
65
|
-
*
|
|
66
|
-
* @param mode - the scroll mode to set
|
|
67
|
-
*/
|
|
68
|
-
setScrollMode(mode: TransformScrollMode): void;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Reset the transform to its initial state
|
|
72
|
-
*/
|
|
73
|
-
reset(): void;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Zoom in the transform
|
|
77
|
-
*/
|
|
78
|
-
zoomIn(): void;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Zoom out the transform
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
zoomOut(): void;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Translate the transform to the center of the canvas
|
|
88
|
-
*/
|
|
89
|
-
translateCenter(): void;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Zoom to a specific point in the canvas
|
|
93
|
-
*
|
|
94
|
-
* @param center - The point (in chart coordinates) that should become the new
|
|
95
|
-
* center of the view after zooming.
|
|
96
|
-
*
|
|
97
|
-
* @param rect - A rectangular region (in chart coordinates) that the view should scale to fit.
|
|
98
|
-
* If omitted, the scale defaults to 1 (no zoom).
|
|
99
|
-
*/
|
|
100
|
-
zoomTo(center: { x: number; y: number }, rect?: { width: number; height: number }): void;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const _TransformContext = new Context<TransformContextValue>('TransformContext');
|
|
104
|
-
|
|
105
|
-
function createDefaultTransformContext() {
|
|
106
|
-
let defaultTranslate = $state(DEFAULT_TRANSLATE);
|
|
107
|
-
let defaultScale = $state(DEFAULT_SCALE);
|
|
108
|
-
|
|
109
|
-
const defaultContext: TransformContextValue = {
|
|
110
|
-
mode: 'none',
|
|
111
|
-
get scale() {
|
|
112
|
-
return defaultScale;
|
|
113
|
-
},
|
|
114
|
-
setScale: (value: number) => {
|
|
115
|
-
defaultScale = value;
|
|
116
|
-
},
|
|
117
|
-
get translate() {
|
|
118
|
-
return defaultTranslate;
|
|
119
|
-
},
|
|
120
|
-
setTranslate: (value: { x: 0; y: 0 }) => {
|
|
121
|
-
defaultTranslate = value;
|
|
122
|
-
},
|
|
123
|
-
moving: false,
|
|
124
|
-
dragging: false,
|
|
125
|
-
scrollMode: 'none',
|
|
126
|
-
setScrollMode: () => {},
|
|
127
|
-
reset: () => {},
|
|
128
|
-
zoomIn: () => {},
|
|
129
|
-
zoomOut: () => {},
|
|
130
|
-
translateCenter: () => {},
|
|
131
|
-
zoomTo: () => {},
|
|
132
|
-
};
|
|
133
|
-
return defaultContext;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function getTransformContext() {
|
|
137
|
-
return _TransformContext.getOr(createDefaultTransformContext());
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function setTransformContext(transform: TransformContextValue) {
|
|
141
|
-
return _TransformContext.set(transform);
|
|
142
|
-
}
|
|
3
|
+
import { setTransformContext, type TransformContextValue } from '../contexts/transform.js';
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_SCALE,
|
|
6
|
+
DEFAULT_TRANSLATE,
|
|
7
|
+
type TransformMode,
|
|
8
|
+
type TransformScrollMode,
|
|
9
|
+
} from '../states/transform.svelte.js';
|
|
143
10
|
|
|
144
11
|
type TransformContextPropsWithoutHTML = {
|
|
145
12
|
mode?: TransformMode;
|
|
@@ -211,11 +78,11 @@
|
|
|
211
78
|
</script>
|
|
212
79
|
|
|
213
80
|
<script lang="ts">
|
|
81
|
+
import type { Snippet } from 'svelte';
|
|
214
82
|
import { localPoint } from '@layerstack/utils';
|
|
215
|
-
import {
|
|
83
|
+
import { watch } from 'runed';
|
|
216
84
|
import type { Without } from '../utils/types.js';
|
|
217
|
-
import { getChartContext } from '
|
|
218
|
-
import type { Snippet } from 'svelte';
|
|
85
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
219
86
|
import {
|
|
220
87
|
createControlledMotion,
|
|
221
88
|
createMotionTracker,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import type { Placement } from './types.js';
|
|
3
4
|
|
|
4
5
|
type Actions = 'zoomIn' | 'zoomOut' | 'center' | 'reset' | 'scrollMode';
|
|
@@ -42,9 +43,8 @@
|
|
|
42
43
|
import LucideZoomIn from '~icons/lucide/zoom-in';
|
|
43
44
|
import LucideZoomOut from '~icons/lucide/zoom-out';
|
|
44
45
|
|
|
45
|
-
import { getTransformContext } from '
|
|
46
|
+
import { getTransformContext } from '../contexts/transform.js';
|
|
46
47
|
import type { Without } from '../utils/types.js';
|
|
47
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
48
48
|
|
|
49
49
|
let {
|
|
50
50
|
placement = 'top-right',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
1
2
|
import type { Placement } from './types.js';
|
|
2
3
|
type Actions = 'zoomIn' | 'zoomOut' | 'center' | 'reset' | 'scrollMode';
|
|
3
4
|
export type TransformControlsPropsWithoutHTML = {
|
|
@@ -22,7 +23,6 @@ export type TransformControlsProps = TransformControlsPropsWithoutHTML & Without
|
|
|
22
23
|
import { type ComponentProps } from 'svelte';
|
|
23
24
|
import { Button } from 'svelte-ux';
|
|
24
25
|
import type { Without } from '../utils/types.js';
|
|
25
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
26
26
|
declare const TransformControls: import("svelte").Component<TransformControlsProps, {}, "">;
|
|
27
27
|
type TransformControls = ReturnType<typeof TransformControls>;
|
|
28
28
|
export default TransformControls;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
export type TreeProps<T> = {
|
|
3
|
+
/** d3 hierarchy node */
|
|
4
|
+
hierarchy: HierarchyNode<T>;
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Sets this tree layout’s node size to the specified two-element array of numbers `[width, height]`.
|
|
5
8
|
* If unset, layout size is used instead. When a node size is specified, the root node is always
|
|
@@ -14,8 +17,6 @@
|
|
|
14
17
|
*/
|
|
15
18
|
separation?: (a: HierarchyPointNode<any>, b: HierarchyPointNode<any>) => number;
|
|
16
19
|
|
|
17
|
-
hierarchy?: HierarchyNode<T>;
|
|
18
|
-
|
|
19
20
|
/**
|
|
20
21
|
* Orientation of the tree layout.
|
|
21
22
|
*
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
type HierarchyNode,
|
|
36
37
|
} from 'd3-hierarchy';
|
|
37
38
|
import type { Snippet } from 'svelte';
|
|
38
|
-
import { getChartContext } from '
|
|
39
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
39
40
|
|
|
40
41
|
let {
|
|
41
42
|
nodeSize,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type TreeProps<T> = {
|
|
2
|
+
/** d3 hierarchy node */
|
|
3
|
+
hierarchy: HierarchyNode<T>;
|
|
2
4
|
/**
|
|
3
5
|
* Sets this tree layout’s node size to the specified two-element array of numbers `[width, height]`.
|
|
4
6
|
* If unset, layout size is used instead. When a node size is specified, the root node is always
|
|
@@ -11,7 +13,6 @@ export type TreeProps<T> = {
|
|
|
11
13
|
* see: https://github.com/d3/d3-hierarchy#tree_separation
|
|
12
14
|
*/
|
|
13
15
|
separation?: (a: HierarchyPointNode<any>, b: HierarchyPointNode<any>) => number;
|
|
14
|
-
hierarchy?: HierarchyNode<T>;
|
|
15
16
|
/**
|
|
16
17
|
* Orientation of the tree layout.
|
|
17
18
|
*
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
export type TreemapProps<T> = {
|
|
3
|
+
/** d3 hierarchy node */
|
|
4
|
+
hierarchy: HierarchyNode<T>;
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* The tile function to use for the treemap layout.
|
|
5
8
|
*
|
|
@@ -66,8 +69,6 @@
|
|
|
66
69
|
*/
|
|
67
70
|
maintainAspectRatio?: boolean;
|
|
68
71
|
|
|
69
|
-
hierarchy?: HierarchyNode<T>;
|
|
70
|
-
|
|
71
72
|
children?: Snippet<[{ nodes: HierarchyRectangularNode<T>[] }]>;
|
|
72
73
|
};
|
|
73
74
|
</script>
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
} from 'd3-hierarchy';
|
|
87
88
|
|
|
88
89
|
import { aspectTile } from '../utils/treemap.js';
|
|
89
|
-
import { getChartContext } from '
|
|
90
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
90
91
|
import type { Snippet } from 'svelte';
|
|
91
92
|
|
|
92
93
|
let {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type TreemapProps<T> = {
|
|
2
|
+
/** d3 hierarchy node */
|
|
3
|
+
hierarchy: HierarchyNode<T>;
|
|
2
4
|
/**
|
|
3
5
|
* The tile function to use for the treemap layout.
|
|
4
6
|
*
|
|
@@ -51,7 +53,6 @@ export type TreemapProps<T> = {
|
|
|
51
53
|
* @default false
|
|
52
54
|
*/
|
|
53
55
|
maintainAspectRatio?: boolean;
|
|
54
|
-
hierarchy?: HierarchyNode<T>;
|
|
55
56
|
children?: Snippet<[{
|
|
56
57
|
nodes: HierarchyRectangularNode<T>[];
|
|
57
58
|
}]>;
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
|
|
67
67
|
import GeoPath from './GeoPath.svelte';
|
|
68
68
|
import Group, { type GroupProps } from './Group.svelte';
|
|
69
|
-
import
|
|
70
|
-
import { getChartContext } from '
|
|
71
|
-
import { getGeoContext } from '
|
|
69
|
+
import Path from './Path.svelte';
|
|
70
|
+
import { getChartContext } from '../contexts/chart.js';
|
|
71
|
+
import { getGeoContext } from '../contexts/geo.js';
|
|
72
72
|
import CircleClipPath from './CircleClipPath.svelte';
|
|
73
73
|
|
|
74
74
|
let {
|
|
@@ -147,10 +147,10 @@
|
|
|
147
147
|
{@const voronoi = Delaunay.from(points).voronoi([0, 0, boundWidth, boundHeight])}
|
|
148
148
|
{#each points as point, i}
|
|
149
149
|
{@const pathData = voronoi.renderCell(i)}
|
|
150
|
-
<!-- Wait to render
|
|
150
|
+
<!-- Wait to render Path until pathData is available to fix path artifacts from injected tweened points in Path -->
|
|
151
151
|
{#if pathData}
|
|
152
152
|
<CircleClipPath cx={point[0]} cy={point[1]} r={r ?? 0} disabled={disableClip}>
|
|
153
|
-
<
|
|
153
|
+
<Path
|
|
154
154
|
{pathData}
|
|
155
155
|
class={['lc-voronoi-path', classes.path]}
|
|
156
156
|
onclick={(e) => onclick?.(e, { data: point.data, point })}
|
|
@@ -25,12 +25,14 @@
|
|
|
25
25
|
| 'marks'
|
|
26
26
|
| 'onTooltipClick'
|
|
27
27
|
| 'profile'
|
|
28
|
-
| '
|
|
28
|
+
| 'layer'
|
|
29
29
|
| 'series'
|
|
30
30
|
| 'tooltip'
|
|
31
31
|
| 'cRange'
|
|
32
32
|
| 'padding'
|
|
33
33
|
| 'context'
|
|
34
|
+
| 'width'
|
|
35
|
+
| 'height'
|
|
34
36
|
> &
|
|
35
37
|
Pick<
|
|
36
38
|
ArcPropsWithoutHTML,
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
import Arc, { type ArcPropsWithoutHTML } from '../Arc.svelte';
|
|
129
131
|
import Chart from '../Chart.svelte';
|
|
130
132
|
import Group from '../Group.svelte';
|
|
131
|
-
import Layer from '../
|
|
133
|
+
import Layer from '../layers/Layer.svelte';
|
|
132
134
|
import Legend from '../Legend.svelte';
|
|
133
135
|
import * as Tooltip from '../tooltip/index.js';
|
|
134
136
|
|
|
@@ -150,6 +152,9 @@
|
|
|
150
152
|
import { createLegendProps } from './utils.svelte.js';
|
|
151
153
|
import { setTooltipMetaContext } from '../tooltip/tooltipMetaContext.js';
|
|
152
154
|
import { getColorIfDefined } from '../../utils/color.js';
|
|
155
|
+
import { getSettings } from '../../contexts/settings.js';
|
|
156
|
+
|
|
157
|
+
const settings = getSettings();
|
|
153
158
|
|
|
154
159
|
let {
|
|
155
160
|
data = [],
|
|
@@ -172,9 +177,9 @@
|
|
|
172
177
|
/** Event dispatched with current tooltip data */
|
|
173
178
|
onTooltipClick = () => {},
|
|
174
179
|
props = {},
|
|
175
|
-
|
|
180
|
+
layer: layerProp,
|
|
176
181
|
profile = false,
|
|
177
|
-
debug
|
|
182
|
+
debug: debugProp,
|
|
178
183
|
tooltip = true,
|
|
179
184
|
children: childrenProp,
|
|
180
185
|
aboveContext,
|
|
@@ -193,6 +198,9 @@
|
|
|
193
198
|
...restProps
|
|
194
199
|
}: ArcChartProps<TData> = $props();
|
|
195
200
|
|
|
201
|
+
const layer = $derived(layerProp ?? settings.layer);
|
|
202
|
+
const debug = $derived(debugProp ?? settings.debug);
|
|
203
|
+
|
|
196
204
|
const center = $derived(centerProp ?? placement === 'center');
|
|
197
205
|
|
|
198
206
|
const c = $derived(cProp ?? key);
|
|
@@ -380,8 +388,8 @@
|
|
|
380
388
|
{@render belowContext?.(snippetProps)}
|
|
381
389
|
|
|
382
390
|
<Layer
|
|
383
|
-
type={
|
|
384
|
-
{...asAny(
|
|
391
|
+
type={layer}
|
|
392
|
+
{...asAny(layer === 'canvas' ? props.canvas : props.svg)}
|
|
385
393
|
{center}
|
|
386
394
|
{debug}
|
|
387
395
|
>
|
|
@@ -7,7 +7,7 @@ export type ArcChartExtraSnippetProps<TData> = {
|
|
|
7
7
|
getArcProps: (s: SeriesData<TData, typeof Arc>, i: number) => ComponentProps<typeof Arc>;
|
|
8
8
|
};
|
|
9
9
|
export type ArcChartPropsObjProp = Pick<SimplifiedChartPropsObject, 'pie' | 'group' | 'arc' | 'legend' | 'canvas' | 'svg' | 'tooltip'>;
|
|
10
|
-
export type ArcChartProps<TData> = Pick<SimplifiedChartProps<TData, typeof Arc, ArcChartExtraSnippetProps<TData>>, 'aboveContext' | 'aboveMarks' | 'belowContext' | 'belowMarks' | 'children' | 'data' | 'debug' | 'legend' | 'marks' | 'onTooltipClick' | 'profile' | '
|
|
10
|
+
export type ArcChartProps<TData> = Pick<SimplifiedChartProps<TData, typeof Arc, ArcChartExtraSnippetProps<TData>>, 'aboveContext' | 'aboveMarks' | 'belowContext' | 'belowMarks' | 'children' | 'data' | 'debug' | 'legend' | 'marks' | 'onTooltipClick' | 'profile' | 'layer' | 'series' | 'tooltip' | 'cRange' | 'padding' | 'context' | 'width' | 'height'> & Pick<ArcPropsWithoutHTML, 'cornerRadius' | 'trackCornerRadius' | 'padAngle' | 'trackPadAngle' | 'trackStartAngle' | 'trackEndAngle' | 'trackInnerRadius' | 'trackOuterRadius' | 'innerRadius' | 'outerRadius' | 'range'> & {
|
|
11
11
|
/**
|
|
12
12
|
* Key accessor
|
|
13
13
|
*
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
import Grid from '../Grid.svelte';
|
|
78
78
|
import Highlight, { type HighlightPointData } from '../Highlight.svelte';
|
|
79
79
|
import Labels from '../Labels.svelte';
|
|
80
|
-
import Layer from '../
|
|
80
|
+
import Layer from '../layers/Layer.svelte';
|
|
81
81
|
import Legend from '../Legend.svelte';
|
|
82
82
|
import Points from '../Points.svelte';
|
|
83
83
|
import Rule from '../Rule.svelte';
|
|
@@ -97,6 +97,9 @@
|
|
|
97
97
|
import { setTooltipMetaContext } from '../tooltip/tooltipMetaContext.js';
|
|
98
98
|
import DefaultTooltip from './DefaultTooltip.svelte';
|
|
99
99
|
import ChartAnnotations from './ChartAnnotations.svelte';
|
|
100
|
+
import { getSettings } from '../../contexts/settings.js';
|
|
101
|
+
|
|
102
|
+
const settings = getSettings();
|
|
100
103
|
|
|
101
104
|
let {
|
|
102
105
|
data = [],
|
|
@@ -119,9 +122,9 @@
|
|
|
119
122
|
onTooltipClick = () => {},
|
|
120
123
|
onPointClick,
|
|
121
124
|
props = {},
|
|
122
|
-
|
|
125
|
+
layer: layerProp,
|
|
123
126
|
profile = false,
|
|
124
|
-
debug
|
|
127
|
+
debug: debugProp,
|
|
125
128
|
children: childrenProp,
|
|
126
129
|
aboveContext,
|
|
127
130
|
belowContext,
|
|
@@ -132,6 +135,9 @@
|
|
|
132
135
|
...restProps
|
|
133
136
|
}: AreaChartProps<TData> = $props();
|
|
134
137
|
|
|
138
|
+
const layer = $derived(layerProp ?? settings.layer);
|
|
139
|
+
const debug = $derived(debugProp ?? settings.debug);
|
|
140
|
+
|
|
135
141
|
const series = $derived(
|
|
136
142
|
seriesProp === undefined
|
|
137
143
|
? [
|
|
@@ -408,7 +414,7 @@
|
|
|
408
414
|
yBaseline={0}
|
|
409
415
|
yNice
|
|
410
416
|
{radial}
|
|
411
|
-
padding={radial ? undefined : defaultChartPadding(axis, legend)}
|
|
417
|
+
padding={radial ? undefined : defaultChartPadding({ axis, legend })}
|
|
412
418
|
{...restProps}
|
|
413
419
|
tooltip={tooltip === false
|
|
414
420
|
? false
|
|
@@ -454,8 +460,8 @@
|
|
|
454
460
|
{:else}
|
|
455
461
|
{@render belowContext?.(snippetProps)}
|
|
456
462
|
<Layer
|
|
457
|
-
type={
|
|
458
|
-
{...asAny(
|
|
463
|
+
type={layer}
|
|
464
|
+
{...asAny(layer === 'canvas' ? props.canvas : props.svg)}
|
|
459
465
|
center={radial}
|
|
460
466
|
{debug}
|
|
461
467
|
>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
import Grid from '../Grid.svelte';
|
|
96
96
|
import Highlight from '../Highlight.svelte';
|
|
97
97
|
import Labels from '../Labels.svelte';
|
|
98
|
-
import Layer from '../
|
|
98
|
+
import Layer from '../layers/Layer.svelte';
|
|
99
99
|
import Legend from '../Legend.svelte';
|
|
100
100
|
import Rule from '../Rule.svelte';
|
|
101
101
|
|
|
@@ -114,6 +114,9 @@
|
|
|
114
114
|
import { setTooltipMetaContext } from '../tooltip/tooltipMetaContext.js';
|
|
115
115
|
import DefaultTooltip from './DefaultTooltip.svelte';
|
|
116
116
|
import ChartAnnotations from './ChartAnnotations.svelte';
|
|
117
|
+
import { getSettings } from '../../contexts/settings.js';
|
|
118
|
+
|
|
119
|
+
const settings = getSettings();
|
|
117
120
|
|
|
118
121
|
let {
|
|
119
122
|
data = [],
|
|
@@ -134,9 +137,9 @@
|
|
|
134
137
|
onTooltipClick = () => {},
|
|
135
138
|
onBarClick = () => {},
|
|
136
139
|
props = {},
|
|
137
|
-
|
|
140
|
+
layer: layerProp,
|
|
138
141
|
profile = false,
|
|
139
|
-
debug
|
|
142
|
+
debug: debugProp,
|
|
140
143
|
xScale: xScaleProp,
|
|
141
144
|
yScale: yScaleProp,
|
|
142
145
|
bandPadding = radial ? 0 : 0.4,
|
|
@@ -157,6 +160,9 @@
|
|
|
157
160
|
...restProps
|
|
158
161
|
}: BarChartProps<TData> = $props();
|
|
159
162
|
|
|
163
|
+
const layer = $derived(layerProp ?? settings.layer);
|
|
164
|
+
const debug = $derived(debugProp ?? settings.debug);
|
|
165
|
+
|
|
160
166
|
const series = $derived(
|
|
161
167
|
seriesProp === undefined
|
|
162
168
|
? [
|
|
@@ -443,7 +449,7 @@
|
|
|
443
449
|
c={isVertical ? yProp : xProp}
|
|
444
450
|
cRange={['var(--color-primary, currentColor)']}
|
|
445
451
|
{radial}
|
|
446
|
-
padding={radial ? undefined : defaultChartPadding(axis, legend)}
|
|
452
|
+
padding={radial ? undefined : defaultChartPadding({ axis, legend })}
|
|
447
453
|
{...restProps}
|
|
448
454
|
tooltip={tooltip === false
|
|
449
455
|
? false
|
|
@@ -489,8 +495,8 @@
|
|
|
489
495
|
{@render belowContext?.(snippetProps)}
|
|
490
496
|
|
|
491
497
|
<Layer
|
|
492
|
-
type={
|
|
493
|
-
{...asAny(
|
|
498
|
+
type={layer}
|
|
499
|
+
{...asAny(layer === 'canvas' ? props.canvas : props.svg)}
|
|
494
500
|
center={radial}
|
|
495
501
|
{debug}
|
|
496
502
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
// Shared tooltip logic across simplified chart components
|
|
3
3
|
import { sum } from 'd3-array';
|
|
4
|
-
import { getChartContext } from '
|
|
4
|
+
import { getChartContext } from '../../contexts/chart.js';
|
|
5
5
|
import * as Tooltip from '../tooltip/index.js';
|
|
6
6
|
import type { SimplifiedChartPropsObject } from './types.js';
|
|
7
7
|
import type { SeriesState } from '../../states/series.svelte.js';
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
import Grid from '../Grid.svelte';
|
|
85
85
|
import Highlight, { type HighlightPointData } from '../Highlight.svelte';
|
|
86
86
|
import Labels from '../Labels.svelte';
|
|
87
|
-
import Layer from '../
|
|
87
|
+
import Layer from '../layers/Layer.svelte';
|
|
88
88
|
import Legend from '../Legend.svelte';
|
|
89
89
|
import Points from '../Points.svelte';
|
|
90
90
|
import Rule from '../Rule.svelte';
|
|
@@ -104,6 +104,9 @@
|
|
|
104
104
|
import DefaultTooltip from './DefaultTooltip.svelte';
|
|
105
105
|
import ChartAnnotations from './ChartAnnotations.svelte';
|
|
106
106
|
import { isScaleTime } from '../../utils/scales.svelte.js';
|
|
107
|
+
import { getSettings } from '../../contexts/settings.js';
|
|
108
|
+
|
|
109
|
+
const settings = getSettings();
|
|
107
110
|
|
|
108
111
|
let {
|
|
109
112
|
data = [],
|
|
@@ -126,9 +129,9 @@
|
|
|
126
129
|
onTooltipClick = () => {},
|
|
127
130
|
onPointClick,
|
|
128
131
|
props = {},
|
|
129
|
-
|
|
132
|
+
layer: layerProp,
|
|
130
133
|
profile = false,
|
|
131
|
-
debug
|
|
134
|
+
debug: debugProp,
|
|
132
135
|
tooltip = true,
|
|
133
136
|
children: childrenProp,
|
|
134
137
|
aboveContext,
|
|
@@ -143,6 +146,9 @@
|
|
|
143
146
|
...restProps
|
|
144
147
|
}: LineChartProps<TData> = $props();
|
|
145
148
|
|
|
149
|
+
const layer = $derived(layerProp ?? settings.layer);
|
|
150
|
+
const debug = $derived(debugProp ?? settings.debug);
|
|
151
|
+
|
|
146
152
|
const isVertical = $derived(orientation === 'vertical');
|
|
147
153
|
|
|
148
154
|
const series = $derived(
|
|
@@ -327,7 +333,7 @@
|
|
|
327
333
|
yBaseline={isVertical || (yScale && isScaleTime(yScale)) ? undefined : 0}
|
|
328
334
|
yNice={orientation === 'horizontal'}
|
|
329
335
|
{radial}
|
|
330
|
-
padding={radial ? undefined : defaultChartPadding(axis, legend)}
|
|
336
|
+
padding={radial ? undefined : defaultChartPadding({ axis, legend })}
|
|
331
337
|
{...restProps}
|
|
332
338
|
tooltip={tooltip === false
|
|
333
339
|
? false
|
|
@@ -373,8 +379,8 @@
|
|
|
373
379
|
{@render belowContext?.(snippetProps)}
|
|
374
380
|
|
|
375
381
|
<Layer
|
|
376
|
-
type={
|
|
377
|
-
{...asAny(
|
|
382
|
+
type={layer}
|
|
383
|
+
{...asAny(layer === 'canvas' ? props.canvas : props.svg)}
|
|
378
384
|
center={radial}
|
|
379
385
|
{debug}
|
|
380
386
|
>
|