layerchart 2.0.0-next.4 → 2.0.0-next.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AnnotationLine.svelte +15 -2
- package/dist/components/AnnotationPoint.svelte +29 -11
- package/dist/components/AnnotationRange.svelte +18 -4
- package/dist/components/Arc.svelte +5 -5
- package/dist/components/Area.svelte +10 -2
- package/dist/components/Axis.svelte +175 -58
- package/dist/components/Axis.svelte.d.ts +23 -6
- package/dist/components/Bar.svelte +20 -15
- package/dist/components/Bar.svelte.d.ts +2 -2
- package/dist/components/Bars.svelte +4 -4
- package/dist/components/Blur.svelte +7 -6
- package/dist/components/Blur.svelte.d.ts +2 -5
- package/dist/components/BrushContext.svelte +45 -45
- package/dist/components/Calendar.svelte +31 -10
- package/dist/components/Calendar.svelte.d.ts +2 -1
- package/dist/components/Chart.svelte +76 -27
- package/dist/components/Chart.svelte.d.ts +26 -8
- package/dist/components/ChartClipPath.svelte +1 -1
- package/dist/components/Circle.svelte +44 -3
- package/dist/components/CircleClipPath.svelte +8 -1
- package/dist/components/ClipPath.svelte +1 -2
- package/dist/components/ColorRamp.svelte +1 -1
- package/dist/components/ComputedStyles.svelte +9 -2
- package/dist/components/Connector.svelte +3 -3
- package/dist/components/Connector.svelte.d.ts +1 -1
- package/dist/components/Ellipse.svelte +228 -0
- package/dist/components/Ellipse.svelte.d.ts +64 -0
- package/dist/components/ForceSimulation.svelte +184 -50
- package/dist/components/ForceSimulation.svelte.d.ts +95 -21
- package/dist/components/Frame.svelte +1 -1
- package/dist/components/GeoCircle.svelte +1 -1
- package/dist/components/GeoEdgeFade.svelte +1 -1
- package/dist/components/GeoPath.svelte +30 -8
- package/dist/components/GeoPoint.svelte +4 -5
- package/dist/components/GeoSpline.svelte +5 -5
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/GeoTile.svelte +1 -1
- package/dist/components/Graticule.svelte +5 -5
- package/dist/components/Grid.svelte +60 -63
- package/dist/components/Group.svelte +13 -8
- package/dist/components/Group.svelte.d.ts +10 -3
- package/dist/components/Highlight.svelte +55 -28
- package/dist/components/Highlight.svelte.d.ts +4 -0
- package/dist/components/Hull.svelte +12 -5
- package/dist/components/Labels.svelte +24 -13
- package/dist/components/Labels.svelte.d.ts +12 -5
- package/dist/components/Legend.svelte +143 -70
- package/dist/components/Legend.svelte.d.ts +12 -8
- package/dist/components/Line.svelte +40 -3
- package/dist/components/LinearGradient.svelte +35 -4
- package/dist/components/Link.svelte +1 -1
- package/dist/components/Marker.svelte +37 -26
- package/dist/components/MonthPath.svelte +26 -12
- package/dist/components/MonthPath.svelte.d.ts +4 -3
- package/dist/components/MotionPath.svelte +1 -1
- package/dist/components/Pack.svelte.d.ts +10 -3
- package/dist/components/Partition.svelte.d.ts +10 -3
- package/dist/components/Pattern.svelte +5 -5
- package/dist/components/Pie.svelte +1 -2
- package/dist/components/Points.svelte +11 -72
- package/dist/components/Points.svelte.d.ts +1 -8
- package/dist/components/Polygon.svelte +309 -0
- package/dist/components/Polygon.svelte.d.ts +115 -0
- package/dist/components/RadialGradient.svelte +4 -6
- package/dist/components/Rect.svelte +55 -5
- package/dist/components/Rect.svelte.d.ts +2 -2
- package/dist/components/RectClipPath.svelte +4 -3
- package/dist/components/RectClipPath.svelte.d.ts +2 -2
- package/dist/components/Rule.svelte +167 -77
- package/dist/components/Rule.svelte.d.ts +7 -2
- package/dist/components/Spline.svelte +59 -28
- package/dist/components/Spline.svelte.d.ts +12 -4
- package/dist/components/Text.svelte +121 -73
- package/dist/components/Text.svelte.d.ts +6 -0
- package/dist/components/TileImage.svelte +19 -4
- package/dist/components/TransformContext.svelte +9 -3
- package/dist/components/TransformControls.svelte +89 -38
- package/dist/components/Tree.svelte.d.ts +10 -3
- package/dist/components/Treemap.svelte +63 -26
- package/dist/components/Treemap.svelte.d.ts +21 -14
- package/dist/components/Voronoi.svelte +12 -13
- package/dist/components/charts/ArcChart.svelte +43 -71
- package/dist/components/charts/ArcChart.svelte.d.ts +10 -3
- package/dist/components/charts/AreaChart.svelte +29 -59
- package/dist/components/charts/AreaChart.svelte.d.ts +10 -3
- package/dist/components/charts/BarChart.svelte +79 -71
- package/dist/components/charts/BarChart.svelte.d.ts +10 -3
- package/dist/components/charts/DefaultTooltip.svelte +3 -3
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +1 -1
- package/dist/components/charts/LineChart.svelte +69 -75
- package/dist/components/charts/LineChart.svelte.d.ts +21 -8
- package/dist/components/charts/PieChart.svelte +44 -71
- package/dist/components/charts/PieChart.svelte.d.ts +10 -3
- package/dist/components/charts/ScatterChart.svelte +10 -39
- package/dist/components/charts/ScatterChart.svelte.d.ts +10 -3
- package/dist/components/charts/utils.svelte.d.ts +1 -19
- package/dist/components/charts/utils.svelte.js +7 -35
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +5 -1
- package/dist/components/layout/Canvas.svelte +96 -69
- package/dist/components/layout/Canvas.svelte.d.ts +6 -0
- package/dist/components/layout/Html.svelte +15 -9
- package/dist/components/layout/Layer.svelte +6 -4
- package/dist/components/layout/Layer.svelte.d.ts +6 -4
- package/dist/components/layout/Svg.svelte +19 -11
- package/dist/components/layout/WebGL.svelte +26 -6
- package/dist/components/layout/WebGL.svelte.d.ts +5 -2
- package/dist/components/tooltip/Tooltip.svelte +65 -27
- package/dist/components/tooltip/Tooltip.svelte.d.ts +10 -3
- package/dist/components/tooltip/TooltipContext.svelte +167 -54
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +19 -5
- package/dist/components/tooltip/TooltipHeader.svelte +32 -18
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipItem.svelte +46 -37
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipList.svelte +12 -10
- package/dist/components/tooltip/TooltipSeparator.svelte +18 -10
- package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
- package/dist/docs/Blockquote.svelte +6 -4
- package/dist/docs/Blockquote.svelte.d.ts +4 -19
- package/dist/docs/Code.svelte +70 -28
- package/dist/docs/Code.svelte.d.ts +9 -24
- package/dist/docs/Header1.svelte +4 -2
- package/dist/docs/Header1.svelte.d.ts +4 -28
- package/dist/docs/Json.svelte +11 -3
- package/dist/docs/Json.svelte.d.ts +9 -21
- package/dist/docs/Layout.svelte +10 -7
- package/dist/docs/Layout.svelte.d.ts +4 -19
- package/dist/docs/Link.svelte +7 -3
- package/dist/docs/Link.svelte.d.ts +4 -38
- package/dist/docs/Preview.svelte +22 -23
- package/dist/docs/Preview.svelte.d.ts +5 -6
- package/dist/docs/TilesetField.svelte +20 -19
- package/dist/docs/TilesetField.svelte.d.ts +5 -22
- package/dist/docs/ViewSourceButton.svelte +10 -7
- package/dist/docs/ViewSourceButton.svelte.d.ts +7 -21
- package/dist/states/series.svelte.d.ts +30 -0
- package/dist/states/series.svelte.js +54 -0
- package/dist/styles/daisyui-5.css +6 -0
- package/dist/styles/shadcn-svelte.css +11 -0
- package/dist/styles/skeleton-3.css +15 -0
- package/dist/utils/arcText.svelte.js +4 -4
- package/dist/utils/array.d.ts +11 -0
- package/dist/utils/array.js +23 -0
- package/dist/utils/array.test.d.ts +1 -0
- package/dist/utils/array.test.js +200 -0
- package/dist/utils/attributes.d.ts +3 -13
- package/dist/utils/attributes.js +4 -18
- package/dist/utils/canvas.d.ts +77 -0
- package/dist/utils/canvas.js +105 -41
- package/dist/utils/common.d.ts +9 -0
- package/dist/utils/common.js +18 -1
- package/dist/utils/common.test.js +26 -1
- package/dist/utils/genData.d.ts +22 -8
- package/dist/utils/genData.js +34 -14
- package/dist/utils/graph/dagre.d.ts +4 -4
- package/dist/utils/graph/dagre.js +5 -7
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/math.d.ts +17 -0
- package/dist/utils/math.js +17 -0
- package/dist/utils/path.d.ts +10 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/rect.svelte.d.ts +2 -2
- package/dist/utils/rect.svelte.js +73 -1
- package/dist/utils/scales.svelte.d.ts +9 -3
- package/dist/utils/scales.svelte.js +47 -4
- package/dist/utils/shape.d.ts +43 -0
- package/dist/utils/shape.js +59 -0
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.d.ts +49 -0
- package/dist/utils/string.js +4 -2
- package/dist/utils/ticks.d.ts +15 -4
- package/dist/utils/ticks.js +140 -159
- package/dist/utils/ticks.test.js +16 -26
- package/dist/utils/treemap.d.ts +1 -1
- package/dist/utils/types.d.ts +15 -2
- package/package.json +35 -35
- package/dist/utils/object.js +0 -2
|
@@ -1,44 +1,95 @@
|
|
|
1
|
-
import { type Force, type Simulation, type SimulationNodeDatum } from 'd3-force';
|
|
1
|
+
import { type Force, type Simulation, type SimulationLinkDatum, type SimulationNodeDatum } from 'd3-force';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
type Forces = Record<string, Force<
|
|
3
|
+
export type Forces<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = Record<string, Force<NodeDatum, LinkDatum>>;
|
|
4
|
+
export type Data<TNode = any, TLink = any> = {
|
|
5
|
+
nodes: TNode[];
|
|
6
|
+
links?: TLink[];
|
|
7
|
+
};
|
|
4
8
|
export type LinkPosition = {
|
|
5
9
|
x1: number;
|
|
6
10
|
y1: number;
|
|
7
11
|
x2: number;
|
|
8
12
|
y2: number;
|
|
9
13
|
};
|
|
10
|
-
export type
|
|
14
|
+
export type OnStartEvent<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = {
|
|
15
|
+
alpha: number;
|
|
16
|
+
alphaTarget: number;
|
|
17
|
+
simulation: Simulation<NodeDatum, LinkDatum>;
|
|
18
|
+
};
|
|
19
|
+
export type OnTickEvent<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = {
|
|
20
|
+
alpha: number;
|
|
21
|
+
alphaTarget: number;
|
|
22
|
+
nodes: NodeDatum[];
|
|
23
|
+
links: LinkDatum[];
|
|
24
|
+
simulation: Simulation<NodeDatum, LinkDatum>;
|
|
25
|
+
};
|
|
26
|
+
export type OnEndEvent<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = {
|
|
27
|
+
alpha: number;
|
|
28
|
+
alphaTarget: number;
|
|
29
|
+
simulation: Simulation<NodeDatum, LinkDatum>;
|
|
30
|
+
};
|
|
31
|
+
export type OnNodesChangeEvent<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = {
|
|
32
|
+
alpha: number;
|
|
33
|
+
alphaTarget: number;
|
|
34
|
+
nodes: NodeDatum[];
|
|
35
|
+
links: LinkDatum[];
|
|
36
|
+
simulation: Simulation<NodeDatum, LinkDatum>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Default initial alpha value of the simulation.
|
|
40
|
+
*/
|
|
41
|
+
export declare const DEFAULT_ALPHA: number;
|
|
42
|
+
/**
|
|
43
|
+
* Default target alpha value for the simulation.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DEFAULT_ALPHA_TARGET: number;
|
|
46
|
+
/**
|
|
47
|
+
* Default alpha decay rate per tick.
|
|
48
|
+
*
|
|
49
|
+
* Formula: `1 - Math.pow(0.001, 1 / 300)`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const DEFAULT_ALPHA_DECAY: number;
|
|
52
|
+
/**
|
|
53
|
+
* Default minimum alpha value at which simulation stops.
|
|
54
|
+
*/
|
|
55
|
+
export declare const DEFAULT_ALPHA_MIN: number;
|
|
56
|
+
/**
|
|
57
|
+
* Default velocity decay factor applied to nodes each tick.
|
|
58
|
+
*/
|
|
59
|
+
export declare const DEFAULT_VELOCITY_DECAY: number;
|
|
60
|
+
export type ForceSimulationProps<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = {
|
|
11
61
|
/**
|
|
12
62
|
* Force simulation parameters
|
|
13
63
|
*/
|
|
14
|
-
forces: Forces
|
|
64
|
+
forces: Forces<NodeDatum, LinkDatum>;
|
|
15
65
|
/**
|
|
16
|
-
* An
|
|
66
|
+
* An object with arrays of nodes and links,
|
|
67
|
+
* to be used for position calculation.
|
|
17
68
|
*/
|
|
18
|
-
|
|
69
|
+
data: Data<NodeDatum, LinkDatum>;
|
|
19
70
|
/**
|
|
20
71
|
* Current alpha value of the simulation
|
|
21
|
-
* @default
|
|
72
|
+
* @default DEFAULT_ALPHA
|
|
22
73
|
*/
|
|
23
74
|
alpha?: number;
|
|
24
75
|
/**
|
|
25
76
|
* Target alpha value for the simulation
|
|
26
|
-
* @default
|
|
77
|
+
* @default DEFAULT_ALPHA_TARGET
|
|
27
78
|
*/
|
|
28
79
|
alphaTarget?: number;
|
|
29
80
|
/**
|
|
30
81
|
* Alpha decay rate per tick
|
|
31
|
-
* @default
|
|
82
|
+
* @default DEFAULT_ALPHA_DECAY
|
|
32
83
|
*/
|
|
33
84
|
alphaDecay?: number;
|
|
34
85
|
/**
|
|
35
86
|
* Minimum alpha value at which simulation stops
|
|
36
|
-
* @default
|
|
87
|
+
* @default DEFAULT_ALPHA_MIN
|
|
37
88
|
*/
|
|
38
89
|
alphaMin?: number;
|
|
39
90
|
/**
|
|
40
91
|
* Velocity decay factor applied to nodes each tick
|
|
41
|
-
* @default
|
|
92
|
+
* @default DEFAULT_VELOCITY_DECAY
|
|
42
93
|
*/
|
|
43
94
|
velocityDecay?: number;
|
|
44
95
|
/**
|
|
@@ -59,26 +110,49 @@ export type ForceSimulationProps = {
|
|
|
59
110
|
/**
|
|
60
111
|
* Callback function triggered when simulation starts
|
|
61
112
|
*/
|
|
62
|
-
onStart?: () => void;
|
|
113
|
+
onStart?: (e: OnStartEvent<NodeDatum, LinkDatum | undefined>) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Callback function triggered right before nodes get passed to the simulation
|
|
116
|
+
*/
|
|
117
|
+
onNodesChange?: (e: OnNodesChangeEvent<NodeDatum, LinkDatum | undefined>) => void;
|
|
63
118
|
/**
|
|
64
119
|
* Callback function triggered on each simulation tick
|
|
65
120
|
*/
|
|
66
|
-
onTick?: (e:
|
|
67
|
-
alpha: number;
|
|
68
|
-
alphaTarget: number;
|
|
69
|
-
}) => void;
|
|
121
|
+
onTick?: (e: OnTickEvent<NodeDatum, LinkDatum | undefined>) => void;
|
|
70
122
|
/**
|
|
71
123
|
* Callback function triggered when simulation ends
|
|
72
124
|
*/
|
|
73
|
-
onEnd?: () => void;
|
|
125
|
+
onEnd?: (e: OnEndEvent<NodeDatum, LinkDatum | undefined>) => void;
|
|
74
126
|
children?: Snippet<[
|
|
75
127
|
{
|
|
76
|
-
nodes:
|
|
77
|
-
|
|
128
|
+
nodes: NodeDatum[];
|
|
129
|
+
links: LinkDatum[];
|
|
78
130
|
linkPositions: LinkPosition[];
|
|
131
|
+
simulation: Simulation<NodeDatum, LinkDatum>;
|
|
79
132
|
}
|
|
80
133
|
]>;
|
|
81
134
|
};
|
|
82
|
-
declare
|
|
83
|
-
|
|
135
|
+
declare function $$render<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined>(): {
|
|
136
|
+
props: ForceSimulationProps<NodeDatum, LinkDatum>;
|
|
137
|
+
exports: {};
|
|
138
|
+
bindings: "alpha";
|
|
139
|
+
slots: {};
|
|
140
|
+
events: {};
|
|
141
|
+
};
|
|
142
|
+
declare class __sveltets_Render<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> {
|
|
143
|
+
props(): ReturnType<typeof $$render<NodeDatum, LinkDatum>>['props'];
|
|
144
|
+
events(): ReturnType<typeof $$render<NodeDatum, LinkDatum>>['events'];
|
|
145
|
+
slots(): ReturnType<typeof $$render<NodeDatum, LinkDatum>>['slots'];
|
|
146
|
+
bindings(): "alpha";
|
|
147
|
+
exports(): {};
|
|
148
|
+
}
|
|
149
|
+
interface $$IsomorphicComponent {
|
|
150
|
+
new <NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['props']>, ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['events']>, ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['slots']>> & {
|
|
151
|
+
$$bindings?: ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['bindings']>;
|
|
152
|
+
} & ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['exports']>;
|
|
153
|
+
<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined>(internal: unknown, props: ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['props']> & {}): ReturnType<__sveltets_Render<NodeDatum, LinkDatum>['exports']>;
|
|
154
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
155
|
+
}
|
|
156
|
+
declare const ForceSimulation: $$IsomorphicComponent;
|
|
157
|
+
type ForceSimulation<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> = InstanceType<typeof ForceSimulation<NodeDatum, LinkDatum>>;
|
|
84
158
|
export default ForceSimulation;
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
width={ctx.width + (full ? (ctx.padding?.left ?? 0) + (ctx.padding?.right ?? 0) : 0)}
|
|
38
38
|
height={ctx.height + (full ? (ctx.padding?.top ?? 0) + (ctx.padding?.bottom ?? 0) : 0)}
|
|
39
39
|
bind:ref
|
|
40
|
-
{...extractLayerProps(restProps, 'frame')}
|
|
40
|
+
{...extractLayerProps(restProps, 'lc-frame')}
|
|
41
41
|
/>
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
const opacity = $derived(opacityProp ?? clamper(fade(distance)));
|
|
57
57
|
</script>
|
|
58
58
|
|
|
59
|
-
<Group {opacity} bind:ref {...extractLayerProps(restProps, 'geo-edge-fade')}>
|
|
59
|
+
<Group {opacity} bind:ref {...extractLayerProps(restProps, 'lc-geo-edge-fade')}>
|
|
60
60
|
{@render children?.()}
|
|
61
61
|
</Group>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { TooltipContextValue } from './tooltip/TooltipContext.svelte';
|
|
6
6
|
import { curveLinearClosed, type CurveFactory, type CurveFactoryLineOnly } from 'd3-shape';
|
|
7
7
|
import {
|
|
8
|
+
geoPath as d3GeoPath,
|
|
8
9
|
geoTransform as d3geoTransform,
|
|
9
10
|
type GeoIdentityTransform,
|
|
10
11
|
type GeoPermissibleObjects,
|
|
@@ -65,7 +66,6 @@
|
|
|
65
66
|
</script>
|
|
66
67
|
|
|
67
68
|
<script lang="ts">
|
|
68
|
-
import { cls } from '@layerstack/tailwind';
|
|
69
69
|
import { merge } from 'lodash-es';
|
|
70
70
|
|
|
71
71
|
import { getRenderContext } from './Chart.svelte';
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
import { geoCurvePath } from '../utils/geo.js';
|
|
74
74
|
import { getGeoContext } from './GeoContext.svelte';
|
|
75
75
|
import { createKey } from '../utils/key.svelte.js';
|
|
76
|
-
import { layerClass } from '../utils/attributes.js';
|
|
77
76
|
|
|
78
77
|
let {
|
|
79
78
|
fill,
|
|
@@ -105,6 +104,10 @@
|
|
|
105
104
|
const geoPath = $derived.by(() => {
|
|
106
105
|
geojson;
|
|
107
106
|
if (!projection) return;
|
|
107
|
+
// Only use geoCurvePath for custom curves (performance impact)
|
|
108
|
+
if (curve === curveLinearClosed) {
|
|
109
|
+
return d3GeoPath(projection);
|
|
110
|
+
}
|
|
108
111
|
return geoCurvePath(projection, curve);
|
|
109
112
|
});
|
|
110
113
|
|
|
@@ -157,16 +160,18 @@
|
|
|
157
160
|
name: 'GeoPath',
|
|
158
161
|
render,
|
|
159
162
|
events: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
// Only register events if they are defined (so they are not registered with hit canvas unnecessarily)
|
|
164
|
+
click: onclick ? _onClick : undefined,
|
|
165
|
+
pointerenter: restProps.onpointerenter || tooltipContext ? _onPointerEnter : undefined,
|
|
166
|
+
pointermove: restProps.onpointermove || tooltipContext ? _onPointerMove : undefined,
|
|
167
|
+
pointerleave: restProps.onpointerleave || tooltipContext ? _onPointerLeave : undefined,
|
|
164
168
|
pointerdown: restProps.onpointerdown,
|
|
165
169
|
touchmove: restProps.ontouchmove,
|
|
166
170
|
},
|
|
167
171
|
deps: () => [
|
|
168
|
-
geojson,
|
|
169
172
|
projection,
|
|
173
|
+
geojson,
|
|
174
|
+
curve,
|
|
170
175
|
fillKey.current,
|
|
171
176
|
strokeKey.current,
|
|
172
177
|
strokeWidth,
|
|
@@ -192,6 +197,23 @@
|
|
|
192
197
|
onpointerenter={_onPointerEnter}
|
|
193
198
|
onpointermove={_onPointerMove}
|
|
194
199
|
onpointerleave={_onPointerLeave}
|
|
195
|
-
class={
|
|
200
|
+
class={['lc-geo-path', className]}
|
|
196
201
|
/>
|
|
197
202
|
{/if}
|
|
203
|
+
|
|
204
|
+
<style>
|
|
205
|
+
@layer base {
|
|
206
|
+
:global(:where(.lc-geo-path)) {
|
|
207
|
+
--fill-color: transparent;
|
|
208
|
+
--stroke-color: initial;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* Svg | Canvas layers */
|
|
212
|
+
:global(:where(.lc-layout-svg .lc-geo-path, svg.lc-geo-path):not([fill])) {
|
|
213
|
+
fill: var(--fill-color);
|
|
214
|
+
}
|
|
215
|
+
:global(:where(.lc-layout-svg .lc-geo-path, svg.lc-geo-path):not([stroke])) {
|
|
216
|
+
stroke: var(--stroke-color);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
</style>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import
|
|
4
|
-
import Circle, { type CircleProps, type CirclePropsWithoutHTML } from './Circle.svelte';
|
|
3
|
+
import Circle, { type CircleProps } from './Circle.svelte';
|
|
5
4
|
import type { Without } from '../utils/types.js';
|
|
6
5
|
|
|
7
6
|
export type GeoPointPropsWithoutHTML = {
|
|
@@ -54,11 +53,11 @@
|
|
|
54
53
|
|
|
55
54
|
{#if renderContext === 'svg'}
|
|
56
55
|
{#if children}
|
|
57
|
-
<Group {x} {y} {...extractLayerProps(restProps, 'geo-point-group')}>
|
|
56
|
+
<Group {x} {y} {...extractLayerProps(restProps, 'lc-geo-point-group')}>
|
|
58
57
|
{@render children({ x, y })}
|
|
59
58
|
</Group>
|
|
60
59
|
{:else}
|
|
61
|
-
<Circle cx={x} cy={y} {...extractLayerProps(restProps, 'geo-point')} />
|
|
60
|
+
<Circle cx={x} cy={y} {...extractLayerProps(restProps, 'lc-geo-point')} />
|
|
62
61
|
{/if}
|
|
63
62
|
{/if}
|
|
64
63
|
|
|
@@ -69,6 +68,6 @@
|
|
|
69
68
|
{@render children({ x, y })}
|
|
70
69
|
<!-- </Group> -->
|
|
71
70
|
{:else}
|
|
72
|
-
<Circle cx={x} cy={y} {...extractLayerProps(restProps, 'geo-point')} />
|
|
71
|
+
<Circle cx={x} cy={y} {...extractLayerProps(restProps, 'lc-geo-point')} />
|
|
73
72
|
{/if}
|
|
74
73
|
{/if}
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
link,
|
|
43
43
|
loft = 1.0,
|
|
44
44
|
curve = curveNatural,
|
|
45
|
-
|
|
45
|
+
pathRef: pathRefProp = $bindable(),
|
|
46
46
|
...restProps
|
|
47
47
|
}: GeoSplineProps = $props();
|
|
48
48
|
|
|
49
|
-
let
|
|
49
|
+
let pathRef = $state<SVGPathElement>();
|
|
50
50
|
$effect.pre(() => {
|
|
51
|
-
|
|
51
|
+
pathRefProp = pathRef;
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
const geoCtx = getGeoContext();
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
</script>
|
|
77
77
|
|
|
78
78
|
<Spline
|
|
79
|
-
bind:
|
|
79
|
+
bind:pathRef
|
|
80
80
|
data={[source, middle, target]}
|
|
81
81
|
x={(d) => d[0]}
|
|
82
82
|
y={(d) => d[1]}
|
|
83
83
|
{curve}
|
|
84
|
-
{...extractLayerProps(restProps, 'geo-spline')}
|
|
84
|
+
{...extractLayerProps(restProps, 'lc-geo-spline')}
|
|
85
85
|
/>
|
|
@@ -27,6 +27,6 @@ export type GeoSplinePropsWithoutHTML = {
|
|
|
27
27
|
curve?: CurveFactory | CurveFactoryLineOnly;
|
|
28
28
|
};
|
|
29
29
|
export type GeoSplineProps = GeoSplinePropsWithoutHTML & Without<SplineProps, GeoSplinePropsWithoutHTML>;
|
|
30
|
-
declare const GeoSpline: import("svelte").Component<GeoSplineProps, {}, "
|
|
30
|
+
declare const GeoSpline: import("svelte").Component<GeoSplineProps, {}, "pathRef">;
|
|
31
31
|
type GeoSpline = ReturnType<typeof GeoSpline>;
|
|
32
32
|
export default GeoSpline;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<script lang="ts">
|
|
17
17
|
import { geoGraticule } from 'd3-geo';
|
|
18
|
-
import { extractLayerProps
|
|
18
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
19
19
|
import Group from './Group.svelte';
|
|
20
20
|
|
|
21
21
|
let { lines, outline, step = [10, 10], ...restProps }: GraticuleProps = $props();
|
|
@@ -27,22 +27,22 @@
|
|
|
27
27
|
});
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
|
-
<Group class=
|
|
30
|
+
<Group class="lc-graticule-g">
|
|
31
31
|
<!-- TODO: Any reason to still render the single `MultiLineString` path if using `lines` and/or `outline` -->
|
|
32
32
|
{#if !lines && !outline}
|
|
33
|
-
<GeoPath geojson={graticule()} {...extractLayerProps(restProps, 'graticule-geo-path')} />
|
|
33
|
+
<GeoPath geojson={graticule()} {...extractLayerProps(restProps, 'lc-graticule-geo-path')} />
|
|
34
34
|
{/if}
|
|
35
35
|
|
|
36
36
|
{#if lines}
|
|
37
37
|
{#each graticule.lines() as line}
|
|
38
|
-
<GeoPath geojson={line} {...extractLayerProps(lines, 'graticule-geo-line')} />
|
|
38
|
+
<GeoPath geojson={line} {...extractLayerProps(lines, 'lc-graticule-geo-line')} />
|
|
39
39
|
{/each}
|
|
40
40
|
{/if}
|
|
41
41
|
|
|
42
42
|
{#if outline}
|
|
43
43
|
<GeoPath
|
|
44
44
|
geojson={graticule.outline()}
|
|
45
|
-
{...extractLayerProps(outline, 'graticule-geo-outline')}
|
|
45
|
+
{...extractLayerProps(outline, 'lc-graticule-geo-outline')}
|
|
46
46
|
/>
|
|
47
47
|
{/if}
|
|
48
48
|
</Group>
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
import Rule from './Rule.svelte';
|
|
99
99
|
import Spline from './Spline.svelte';
|
|
100
100
|
import { getChartContext } from './Chart.svelte';
|
|
101
|
-
import { extractLayerProps
|
|
102
|
-
import {
|
|
101
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
102
|
+
import { autoTickVals, type TicksConfig } from '../utils/ticks.js';
|
|
103
103
|
|
|
104
104
|
const ctx = getChartContext();
|
|
105
105
|
|
|
@@ -131,8 +131,8 @@
|
|
|
131
131
|
|
|
132
132
|
const transitionIn = $derived((transitionInProp ?? tweenConfig?.options) ? fade : () => ({}));
|
|
133
133
|
|
|
134
|
-
const xTickVals = $derived(
|
|
135
|
-
const yTickVals = $derived(
|
|
134
|
+
const xTickVals = $derived(autoTickVals(ctx.xScale, xTicks));
|
|
135
|
+
const yTickVals = $derived(autoTickVals(ctx.yScale, yTicks));
|
|
136
136
|
|
|
137
137
|
const xBandOffset = $derived(
|
|
138
138
|
isScaleBand(ctx.xScale)
|
|
@@ -151,11 +151,11 @@
|
|
|
151
151
|
);
|
|
152
152
|
</script>
|
|
153
153
|
|
|
154
|
-
<Group bind:ref class={cls(
|
|
154
|
+
<Group bind:ref class={cls('lc-grid', classes.root, className)} {...restProps}>
|
|
155
155
|
{#if x}
|
|
156
|
-
{@const splineProps = extractLayerProps(x, 'grid-x-line')}
|
|
156
|
+
{@const splineProps = extractLayerProps(x, 'lc-grid-x-line')}
|
|
157
157
|
|
|
158
|
-
<Group {transitionIn} {transitionInParams} class=
|
|
158
|
+
<Group {transitionIn} {transitionInParams} class="lc-grid-x">
|
|
159
159
|
{#each xTickVals as x (x)}
|
|
160
160
|
{#if ctx.radial}
|
|
161
161
|
{@const [x1, y1] = pointRadial(ctx.xScale(x), ctx.yRange[0])}
|
|
@@ -167,12 +167,7 @@
|
|
|
167
167
|
{y2}
|
|
168
168
|
motion={tweenConfig}
|
|
169
169
|
{...splineProps}
|
|
170
|
-
class={cls(
|
|
171
|
-
layerClass('grid-x-radial-line'),
|
|
172
|
-
'stroke-surface-content/10',
|
|
173
|
-
classes.line,
|
|
174
|
-
splineProps?.class
|
|
175
|
-
)}
|
|
170
|
+
class={cls('lc-grid-x-radial-line', classes.line, splineProps?.class)}
|
|
176
171
|
/>
|
|
177
172
|
{:else}
|
|
178
173
|
<Rule
|
|
@@ -180,37 +175,28 @@
|
|
|
180
175
|
xOffset={xBandOffset}
|
|
181
176
|
{motion}
|
|
182
177
|
{...splineProps}
|
|
183
|
-
class={cls(
|
|
184
|
-
layerClass('grid-x-rule'),
|
|
185
|
-
'stroke-surface-content/10',
|
|
186
|
-
classes.line,
|
|
187
|
-
splineProps?.class
|
|
188
|
-
)}
|
|
178
|
+
class={cls('lc-grid-x-rule', classes.line, splineProps?.class)}
|
|
189
179
|
/>
|
|
190
180
|
{/if}
|
|
191
181
|
{/each}
|
|
192
182
|
|
|
193
183
|
<!-- Add extra rule after last band -->
|
|
194
184
|
{#if isScaleBand(ctx.xScale) && bandAlign === 'between' && !ctx.radial && xTickVals.length}
|
|
185
|
+
{@const x = ctx.xScale(xTickVals[xTickVals.length - 1])! + ctx.xScale.step() + xBandOffset}
|
|
195
186
|
<Rule
|
|
196
187
|
x={xTickVals[xTickVals.length - 1]}
|
|
197
188
|
xOffset={ctx.xScale.step() + xBandOffset}
|
|
198
189
|
{motion}
|
|
199
190
|
{...splineProps}
|
|
200
|
-
class={cls(
|
|
201
|
-
layerClass('grid-x-end-rule'),
|
|
202
|
-
'stroke-surface-content/10',
|
|
203
|
-
classes.line,
|
|
204
|
-
splineProps?.class
|
|
205
|
-
)}
|
|
191
|
+
class={cls('lc-grid-x-end-rule', classes.line, splineProps?.class)}
|
|
206
192
|
/>
|
|
207
193
|
{/if}
|
|
208
194
|
</Group>
|
|
209
195
|
{/if}
|
|
210
196
|
|
|
211
197
|
{#if y}
|
|
212
|
-
{@const splineProps = extractLayerProps(y, 'grid-y-line')}
|
|
213
|
-
<Group {transitionIn} {transitionInParams} class=
|
|
198
|
+
{@const splineProps = extractLayerProps(y, 'lc-grid-y-line')}
|
|
199
|
+
<Group {transitionIn} {transitionInParams} class="lc-grid-y">
|
|
214
200
|
{#each yTickVals as y (y)}
|
|
215
201
|
{#if ctx.radial}
|
|
216
202
|
{#if radialY === 'circle'}
|
|
@@ -218,12 +204,7 @@
|
|
|
218
204
|
r={ctx.yScale(y) + yBandOffset}
|
|
219
205
|
{motion}
|
|
220
206
|
{...splineProps}
|
|
221
|
-
class={cls(
|
|
222
|
-
layerClass('grid-y-radial-circle'),
|
|
223
|
-
'fill-none stroke-surface-content/10',
|
|
224
|
-
classes.line,
|
|
225
|
-
splineProps?.class
|
|
226
|
-
)}
|
|
207
|
+
class={cls('lc-grid-y-radial-circle', classes.line, splineProps?.class)}
|
|
227
208
|
/>
|
|
228
209
|
{:else}
|
|
229
210
|
<Spline
|
|
@@ -233,26 +214,18 @@
|
|
|
233
214
|
motion={tweenConfig}
|
|
234
215
|
curve={curveLinearClosed}
|
|
235
216
|
{...splineProps}
|
|
236
|
-
class={cls(
|
|
237
|
-
layerClass('grid-y-radial-line'),
|
|
238
|
-
'stroke-surface-content/10',
|
|
239
|
-
classes.line,
|
|
240
|
-
splineProps?.class
|
|
241
|
-
)}
|
|
217
|
+
class={cls('lc-grid-y-radial-line', classes.line, splineProps?.class)}
|
|
242
218
|
/>
|
|
243
219
|
{/if}
|
|
244
220
|
{:else}
|
|
245
|
-
<
|
|
246
|
-
{
|
|
247
|
-
|
|
221
|
+
<Line
|
|
222
|
+
x1={ctx.xRange[0]}
|
|
223
|
+
y1={ctx.yScale(y) + yBandOffset}
|
|
224
|
+
x2={ctx.xRange[1]}
|
|
225
|
+
y2={ctx.yScale(y) + yBandOffset}
|
|
248
226
|
{motion}
|
|
249
227
|
{...splineProps}
|
|
250
|
-
class={cls(
|
|
251
|
-
layerClass('grid-y-rule'),
|
|
252
|
-
'stroke-surface-content/10',
|
|
253
|
-
classes.line,
|
|
254
|
-
splineProps?.class
|
|
255
|
-
)}
|
|
228
|
+
class={cls('lc-grid-y-rule', classes.line, splineProps?.class)}
|
|
256
229
|
/>
|
|
257
230
|
{/if}
|
|
258
231
|
{/each}
|
|
@@ -264,28 +237,52 @@
|
|
|
264
237
|
r={ctx.yScale(yTickVals[yTickVals.length - 1])! + ctx.yScale.step() + yBandOffset}
|
|
265
238
|
{motion}
|
|
266
239
|
{...splineProps}
|
|
267
|
-
class={cls(
|
|
268
|
-
layerClass('grid-y-radial-circle'),
|
|
269
|
-
'fill-none stroke-surface-content/10',
|
|
270
|
-
classes.line,
|
|
271
|
-
splineProps?.class
|
|
272
|
-
)}
|
|
240
|
+
class={cls('lc-grid-y-radial-circle', classes.line, splineProps?.class)}
|
|
273
241
|
/>
|
|
274
242
|
{:else}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
243
|
+
{@const y =
|
|
244
|
+
ctx.yScale(yTickVals[yTickVals.length - 1])! + ctx.yScale.step() + yBandOffset}
|
|
245
|
+
<Line
|
|
246
|
+
x1={ctx.xRange[0]}
|
|
247
|
+
y1={y}
|
|
248
|
+
x2={ctx.xRange[1]}
|
|
249
|
+
y2={y}
|
|
278
250
|
{motion}
|
|
279
251
|
{...splineProps}
|
|
280
|
-
class={cls(
|
|
281
|
-
layerClass('grid-y-end-rule'),
|
|
282
|
-
'stroke-surface-content/10',
|
|
283
|
-
classes.line,
|
|
284
|
-
splineProps?.class
|
|
285
|
-
)}
|
|
252
|
+
class={cls('lc-grid-y-end-rule', classes.line, splineProps?.class)}
|
|
286
253
|
/>
|
|
287
254
|
{/if}
|
|
288
255
|
{/if}
|
|
289
256
|
</Group>
|
|
290
257
|
{/if}
|
|
291
258
|
</Group>
|
|
259
|
+
|
|
260
|
+
<style>
|
|
261
|
+
@layer components {
|
|
262
|
+
:global(
|
|
263
|
+
:where(
|
|
264
|
+
.lc-grid-x-rule,
|
|
265
|
+
.lc-grid-x-end-rule,
|
|
266
|
+
.lc-grid-x-radial-line,
|
|
267
|
+
.lc-grid-y-rule,
|
|
268
|
+
.lc-grid-y-end-rule,
|
|
269
|
+
.lc-grid-y-radial-line
|
|
270
|
+
)
|
|
271
|
+
) {
|
|
272
|
+
--stroke-color: color-mix(
|
|
273
|
+
in oklab,
|
|
274
|
+
var(--color-surface-content, currentColor) 10%,
|
|
275
|
+
transparent
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
:global(:where(.lc-grid-y-radial-circle)) {
|
|
280
|
+
--fill-color: none;
|
|
281
|
+
--stroke-color: color-mix(
|
|
282
|
+
in oklab,
|
|
283
|
+
var(--color-surface-content, currentColor) 10%,
|
|
284
|
+
transparent
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
</style>
|
|
@@ -83,13 +83,10 @@
|
|
|
83
83
|
import { fade } from 'svelte/transition';
|
|
84
84
|
import { cubicIn } from 'svelte/easing';
|
|
85
85
|
|
|
86
|
-
import { cls } from '@layerstack/tailwind';
|
|
87
|
-
|
|
88
86
|
import { getRenderContext } from './Chart.svelte';
|
|
89
87
|
import { registerCanvasComponent } from './layout/Canvas.svelte';
|
|
90
88
|
|
|
91
89
|
import { getChartContext } from './Chart.svelte';
|
|
92
|
-
import { layerClass } from '../utils/attributes.js';
|
|
93
90
|
|
|
94
91
|
const ctx = getChartContext();
|
|
95
92
|
|
|
@@ -100,7 +97,7 @@
|
|
|
100
97
|
initialY: initialYProp,
|
|
101
98
|
center = false,
|
|
102
99
|
preventTouchMove = false,
|
|
103
|
-
opacity =
|
|
100
|
+
opacity = undefined,
|
|
104
101
|
motion,
|
|
105
102
|
transitionIn: transitionInProp,
|
|
106
103
|
transitionInParams: transitionInParamsProp,
|
|
@@ -144,7 +141,7 @@
|
|
|
144
141
|
name: 'Group',
|
|
145
142
|
render: (ctx) => {
|
|
146
143
|
const currentGlobalAlpha = ctx.globalAlpha;
|
|
147
|
-
ctx.globalAlpha = opacity;
|
|
144
|
+
ctx.globalAlpha = opacity ?? 1;
|
|
148
145
|
|
|
149
146
|
ctx.translate(motionX.current ?? 0, motionY.current ?? 0);
|
|
150
147
|
|
|
@@ -178,7 +175,7 @@
|
|
|
178
175
|
{:else if renderCtx === 'svg'}
|
|
179
176
|
<g
|
|
180
177
|
style:transform
|
|
181
|
-
class={
|
|
178
|
+
class={['lc-group-g', className]}
|
|
182
179
|
in:transitionIn={transitionInParams}
|
|
183
180
|
{opacity}
|
|
184
181
|
{...restProps}
|
|
@@ -187,16 +184,24 @@
|
|
|
187
184
|
>
|
|
188
185
|
{@render children?.()}
|
|
189
186
|
</g>
|
|
190
|
-
{:else}
|
|
187
|
+
{:else if renderCtx === 'html'}
|
|
191
188
|
<div
|
|
192
189
|
bind:this={ref}
|
|
193
190
|
style:transform
|
|
194
191
|
style:opacity
|
|
195
192
|
in:transitionIn={transitionInParams}
|
|
196
193
|
{...restProps}
|
|
197
|
-
class={
|
|
194
|
+
class={['lc-group-div', className]}
|
|
198
195
|
ontouchmove={handleTouchMove}
|
|
199
196
|
>
|
|
200
197
|
{@render children?.()}
|
|
201
198
|
</div>
|
|
202
199
|
{/if}
|
|
200
|
+
|
|
201
|
+
<style>
|
|
202
|
+
@layer base {
|
|
203
|
+
:where(.lc-group-div) {
|
|
204
|
+
position: absolute;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
</style>
|