layerchart 2.0.0-next.1 → 2.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/movable.d.ts +28 -0
- package/dist/actions/movable.js +91 -0
- package/dist/components/AnnotationLine.svelte +143 -0
- package/dist/components/AnnotationLine.svelte.d.ts +30 -0
- package/dist/components/AnnotationPoint.svelte +119 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +34 -0
- package/dist/components/AnnotationRange.svelte +147 -0
- package/dist/components/AnnotationRange.svelte.d.ts +40 -0
- package/dist/components/Arc.svelte +344 -151
- package/dist/components/Arc.svelte.d.ts +138 -0
- package/dist/components/Area.svelte +165 -149
- package/dist/components/Area.svelte.d.ts +45 -0
- package/dist/components/Axis.svelte +283 -180
- package/dist/components/Axis.svelte.d.ts +117 -0
- package/dist/components/Bar.svelte +166 -107
- package/dist/components/Bar.svelte.d.ts +51 -0
- package/dist/components/Bars.svelte +56 -67
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +42 -12
- package/dist/components/Blur.svelte.d.ts +23 -21
- package/dist/components/Bounds.svelte +49 -19
- package/dist/components/Bounds.svelte.d.ts +24 -50
- package/dist/components/BrushContext.svelte +296 -168
- package/dist/components/BrushContext.svelte.d.ts +97 -65
- package/dist/components/Calendar.svelte +116 -59
- package/dist/components/Calendar.svelte.d.ts +50 -31
- package/dist/components/Chart.svelte +1289 -398
- package/dist/components/Chart.svelte.d.ts +535 -410
- package/dist/components/ChartClipPath.svelte +37 -15
- package/dist/components/ChartClipPath.svelte.d.ts +21 -19
- package/dist/components/Circle.svelte +124 -85
- package/dist/components/Circle.svelte.d.ts +52 -0
- package/dist/components/CircleClipPath.svelte +76 -16
- package/dist/components/CircleClipPath.svelte.d.ts +46 -0
- package/dist/components/ClipPath.svelte +71 -21
- package/dist/components/ClipPath.svelte.d.ts +40 -27
- package/dist/components/ColorRamp.svelte +75 -9
- package/dist/components/ColorRamp.svelte.d.ts +37 -19
- package/dist/components/ComputedStyles.svelte +17 -5
- package/dist/components/ComputedStyles.svelte.d.ts +11 -19
- package/dist/components/Connector.svelte +149 -0
- package/dist/components/Connector.svelte.d.ts +51 -0
- package/dist/components/Dagre.svelte +211 -122
- package/dist/components/Dagre.svelte.d.ts +119 -56
- package/dist/components/ForceSimulation.svelte +215 -90
- package/dist/components/ForceSimulation.svelte.d.ts +82 -35
- package/dist/components/Frame.svelte +33 -13
- package/dist/components/Frame.svelte.d.ts +13 -17
- package/dist/components/GeoCircle.svelte +29 -16
- package/dist/components/GeoCircle.svelte.d.ts +22 -24
- package/dist/components/GeoContext.svelte +113 -72
- package/dist/components/GeoContext.svelte.d.ts +49 -41
- package/dist/components/GeoEdgeFade.svelte +49 -13
- package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
- package/dist/components/GeoPath.svelte +157 -127
- package/dist/components/GeoPath.svelte.d.ts +48 -36
- package/dist/components/GeoPoint.svelte +52 -20
- package/dist/components/GeoPoint.svelte.d.ts +25 -22
- package/dist/components/GeoSpline.svelte +75 -26
- package/dist/components/GeoSpline.svelte.d.ts +29 -20
- package/dist/components/GeoTile.svelte +100 -49
- package/dist/components/GeoTile.svelte.d.ts +38 -23
- package/dist/components/GeoVisible.svelte +17 -9
- package/dist/components/GeoVisible.svelte.d.ts +10 -18
- package/dist/components/Graticule.svelte +30 -14
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +230 -117
- package/dist/components/Grid.svelte.d.ts +71 -0
- package/dist/components/Group.svelte +173 -106
- package/dist/components/Group.svelte.d.ts +81 -0
- package/dist/components/Highlight.svelte +410 -308
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +97 -46
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +127 -47
- package/dist/components/Labels.svelte.d.ts +70 -27
- package/dist/components/Legend.svelte +374 -190
- package/dist/components/Legend.svelte.d.ts +95 -44
- package/dist/components/Line.svelte +163 -125
- package/dist/components/Line.svelte.d.ts +75 -0
- package/dist/components/LinearGradient.svelte +153 -78
- package/dist/components/LinearGradient.svelte.d.ts +66 -31
- package/dist/components/Link.svelte +160 -104
- package/dist/components/Link.svelte.d.ts +54 -0
- package/dist/components/Marker.svelte +100 -39
- package/dist/components/Marker.svelte.d.ts +59 -27
- package/dist/components/MarkerWrapper.svelte +35 -0
- package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
- package/dist/components/MonthPath.svelte +65 -20
- package/dist/components/MonthPath.svelte.d.ts +23 -17
- package/dist/components/MotionPath.svelte +80 -24
- package/dist/components/MotionPath.svelte.d.ts +46 -27
- package/dist/components/Pack.svelte +53 -17
- package/dist/components/Pack.svelte.d.ts +42 -21
- package/dist/components/Partition.svelte +64 -22
- package/dist/components/Partition.svelte.d.ts +49 -26
- package/dist/components/Pattern.svelte +297 -11
- package/dist/components/Pattern.svelte.d.ts +103 -19
- package/dist/components/Pie.svelte +122 -76
- package/dist/components/Pie.svelte.d.ts +65 -51
- package/dist/components/Point.svelte +20 -9
- package/dist/components/Point.svelte.d.ts +16 -20
- package/dist/components/Points.svelte +148 -137
- package/dist/components/Points.svelte.d.ts +45 -34
- package/dist/components/RadialGradient.svelte +143 -70
- package/dist/components/RadialGradient.svelte.d.ts +69 -31
- package/dist/components/Rect.svelte +121 -102
- package/dist/components/Rect.svelte.d.ts +36 -0
- package/dist/components/RectClipPath.svelte +82 -18
- package/dist/components/RectClipPath.svelte.d.ts +55 -0
- package/dist/components/Rule.svelte +107 -63
- package/dist/components/Rule.svelte.d.ts +40 -19
- package/dist/components/Sankey.svelte +132 -55
- package/dist/components/Sankey.svelte.d.ts +61 -31
- package/dist/components/Spline.svelte +281 -218
- package/dist/components/Spline.svelte.d.ts +95 -0
- package/dist/components/Text.svelte +437 -176
- package/dist/components/Text.svelte.d.ts +130 -0
- package/dist/components/Threshold.svelte +48 -16
- package/dist/components/Threshold.svelte.d.ts +29 -31
- package/dist/components/TileImage.svelte +103 -30
- package/dist/components/TileImage.svelte.d.ts +48 -23
- package/dist/components/TransformContext.svelte +365 -171
- package/dist/components/TransformControls.svelte +50 -26
- package/dist/components/TransformControls.svelte.d.ts +27 -19
- package/dist/components/Tree.svelte +74 -33
- package/dist/components/Tree.svelte.d.ts +42 -30
- package/dist/components/Treemap.svelte +119 -42
- package/dist/components/Treemap.svelte.d.ts +75 -27
- package/dist/components/Voronoi.svelte +108 -76
- package/dist/components/Voronoi.svelte.d.ts +40 -41
- package/dist/components/charts/ArcChart.svelte +464 -0
- package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
- package/dist/components/charts/AreaChart.svelte +450 -393
- package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
- package/dist/components/charts/BarChart.svelte +454 -389
- package/dist/components/charts/BarChart.svelte.d.ts +76 -0
- package/dist/components/charts/ChartAnnotations.svelte +37 -0
- package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
- package/dist/components/charts/DefaultTooltip.svelte +60 -0
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
- package/dist/components/charts/LineChart.svelte +369 -314
- package/dist/components/charts/LineChart.svelte.d.ts +53 -0
- package/dist/components/charts/PieChart.svelte +458 -316
- package/dist/components/charts/PieChart.svelte.d.ts +137 -353
- package/dist/components/charts/ScatterChart.svelte +334 -296
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
- package/dist/components/charts/index.d.ts +8 -0
- package/dist/components/charts/index.js +7 -0
- package/dist/components/charts/types.d.ts +253 -0
- package/dist/components/charts/utils.svelte.d.ts +30 -0
- package/dist/components/charts/utils.svelte.js +55 -0
- package/dist/components/index.d.ts +76 -4
- package/dist/components/index.js +76 -5
- package/dist/components/layout/Canvas.svelte +321 -155
- package/dist/components/layout/Canvas.svelte.d.ts +104 -55
- package/dist/components/layout/Html.svelte +82 -42
- package/dist/components/layout/Html.svelte.d.ts +39 -28
- package/dist/components/layout/Layer.svelte +39 -0
- package/dist/components/layout/Layer.svelte.d.ts +17 -0
- package/dist/components/layout/Svg.svelte +122 -70
- package/dist/components/layout/Svg.svelte.d.ts +53 -34
- package/dist/components/layout/WebGL.svelte +135 -0
- package/dist/components/layout/WebGL.svelte.d.ts +50 -0
- package/dist/components/tooltip/Tooltip.svelte +246 -78
- package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
- package/dist/components/tooltip/TooltipContext.svelte +409 -271
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
- package/dist/components/tooltip/TooltipHeader.svelte +100 -11
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
- package/dist/components/tooltip/TooltipItem.svelte +167 -27
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
- package/dist/components/tooltip/TooltipList.svelte +22 -3
- package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
- package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
- package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +6 -0
- package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
- package/dist/components/tooltip/tooltipMetaContext.js +139 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/components/types.js +1 -0
- package/dist/docs/Blockquote.svelte.d.ts +18 -14
- package/dist/docs/Code.svelte.d.ts +26 -22
- package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
- package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
- package/dist/docs/CurveMenuField.svelte +14 -3
- package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
- package/dist/docs/GeoDebug.svelte +47 -42
- package/dist/docs/GeoDebug.svelte.d.ts +4 -16
- package/dist/docs/Header1.svelte.d.ts +27 -16
- package/dist/docs/Json.svelte.d.ts +20 -16
- package/dist/docs/Layout.svelte.d.ts +18 -13
- package/dist/docs/Link.svelte.d.ts +33 -21
- package/dist/docs/PathDataMenuField.svelte +14 -10
- package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
- package/dist/docs/Preview.svelte +20 -7
- package/dist/docs/Preview.svelte.d.ts +12 -22
- package/dist/docs/TilesetField.svelte.d.ts +21 -17
- package/dist/docs/TransformDebug.svelte +5 -6
- package/dist/docs/TransformDebug.svelte.d.ts +18 -14
- package/dist/docs/ViewSourceButton.svelte.d.ts +21 -17
- package/dist/types/d3-shape-extentions.d.ts +7 -0
- package/dist/utils/afterTick.d.ts +5 -0
- package/dist/utils/afterTick.js +8 -0
- package/dist/utils/arcText.svelte.d.ts +57 -0
- package/dist/utils/arcText.svelte.js +262 -0
- package/dist/utils/array.d.ts +9 -1
- package/dist/utils/array.js +13 -0
- package/dist/utils/attributes.d.ts +29 -0
- package/dist/utils/attributes.js +40 -0
- package/dist/utils/canvas.js +47 -10
- package/dist/utils/chart.d.ts +78 -0
- package/dist/utils/chart.js +512 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +8 -0
- package/dist/utils/common.d.ts +3 -5
- package/dist/utils/common.js +3 -2
- package/dist/utils/connectorUtils.d.ts +21 -0
- package/dist/utils/connectorUtils.js +111 -0
- package/dist/utils/createId.d.ts +7 -0
- package/dist/utils/createId.js +9 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +84 -0
- package/dist/utils/filterObject.d.ts +9 -0
- package/dist/utils/filterObject.js +12 -0
- package/dist/utils/graph/dagre.d.ts +34 -0
- package/dist/utils/graph/dagre.js +78 -0
- package/dist/utils/graph/dagre.test.d.ts +1 -0
- package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
- package/dist/utils/graph/sankey.d.ts +28 -0
- package/dist/utils/{graph.js → graph/sankey.js} +13 -41
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/key.svelte.d.ts +3 -0
- package/dist/utils/key.svelte.js +11 -0
- package/dist/utils/legendPayload.d.ts +7 -0
- package/dist/utils/legendPayload.js +8 -0
- package/dist/utils/motion.svelte.d.ts +140 -0
- package/dist/utils/motion.svelte.js +180 -0
- package/dist/utils/motion.test.d.ts +1 -0
- package/dist/utils/motion.test.js +213 -0
- package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
- package/dist/utils/rect.svelte.js +105 -0
- package/dist/utils/scales.svelte.d.ts +90 -0
- package/dist/utils/{scales.js → scales.svelte.js} +100 -39
- package/dist/utils/stack.d.ts +2 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.js +87 -0
- package/dist/utils/ticks.d.ts +8 -2
- package/dist/utils/ticks.js +28 -0
- package/dist/utils/ticks.test.d.ts +1 -0
- package/dist/utils/ticks.test.js +67 -0
- package/dist/utils/types.d.ts +81 -0
- package/package.json +21 -19
- package/dist/components/ChartContext.svelte +0 -295
- package/dist/components/ChartContext.svelte.d.ts +0 -139
- package/dist/components/TransformContext.svelte.d.ts +0 -158
- package/dist/stores/motionStore.d.ts +0 -30
- package/dist/stores/motionStore.js +0 -62
- package/dist/utils/graph.d.ts +0 -37
- package/dist/utils/rect.js +0 -107
- package/dist/utils/scales.d.ts +0 -66
- /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
|
@@ -1,497 +1,1388 @@
|
|
|
1
|
-
<script lang="ts"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { scaleLinear, scaleOrdinal, scaleSqrt } from 'd3-scale';
|
|
3
|
+
import { type Accessor, accessor, chartDataArray } from '../utils/common.js';
|
|
4
|
+
import { printDebug } from '../utils/debug.js';
|
|
5
|
+
import { filterObject } from '../utils/filterObject.js';
|
|
6
|
+
import {
|
|
7
|
+
createScale,
|
|
8
|
+
getRange,
|
|
9
|
+
isScaleBand,
|
|
10
|
+
makeAccessor,
|
|
11
|
+
type AnyScale,
|
|
12
|
+
type DomainType,
|
|
13
|
+
} from '../utils/scales.svelte.js';
|
|
14
|
+
import { Context, useDebounce } from 'runed';
|
|
15
|
+
import type {
|
|
16
|
+
AxisKey,
|
|
17
|
+
BaseRange,
|
|
18
|
+
DataType,
|
|
19
|
+
Extents,
|
|
20
|
+
Nice,
|
|
21
|
+
Padding,
|
|
22
|
+
PaddingArray,
|
|
23
|
+
XRangeWithScale,
|
|
24
|
+
YRangeWithScale,
|
|
25
|
+
} from '../utils/types.js';
|
|
26
|
+
import {
|
|
27
|
+
calcDomain,
|
|
28
|
+
calcScaleExtents,
|
|
29
|
+
createGetter,
|
|
30
|
+
createChartScale,
|
|
31
|
+
} from '../utils/chart.js';
|
|
32
|
+
import { onMount, type ComponentProps, type Snippet } from 'svelte';
|
|
33
|
+
import GeoContext, { type GeoContextValue } from './GeoContext.svelte';
|
|
34
|
+
import TooltipContext, { type TooltipContextValue } from './tooltip/TooltipContext.svelte';
|
|
35
|
+
import { extent, max, min } from 'd3-array';
|
|
36
|
+
import type { HierarchyNode } from 'd3-hierarchy';
|
|
37
|
+
import type { SankeyGraph } from 'd3-sankey';
|
|
38
|
+
import { unique } from '@layerstack/utils';
|
|
39
|
+
import { geoFitObjectTransform } from '../utils/geo.js';
|
|
40
|
+
import TransformContext, { type TransformContextValue } from './TransformContext.svelte';
|
|
41
|
+
import BrushContext, { type BrushContextValue } from './BrushContext.svelte';
|
|
42
|
+
import { layerClass } from '../utils/attributes.js';
|
|
43
|
+
|
|
44
|
+
const defaultPadding = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
45
|
+
|
|
46
|
+
export type ChartResizeDetail = {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
containerWidth: number;
|
|
50
|
+
containerHeight: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type PreservedChartConfig<
|
|
54
|
+
T,
|
|
55
|
+
XScale extends AnyScale = AnyScale,
|
|
56
|
+
YScale extends AnyScale = AnyScale,
|
|
57
|
+
> = Pick<
|
|
58
|
+
ChartPropsWithoutHTML<T, XScale, YScale>,
|
|
59
|
+
| 'x'
|
|
60
|
+
| 'y'
|
|
61
|
+
| 'z'
|
|
62
|
+
| 'r'
|
|
63
|
+
| 'c'
|
|
64
|
+
| 'x1'
|
|
65
|
+
| 'y1'
|
|
66
|
+
| 'xRange'
|
|
67
|
+
| 'yRange'
|
|
68
|
+
| 'cDomain'
|
|
69
|
+
| 'zDomain'
|
|
70
|
+
| 'xDomain'
|
|
71
|
+
| 'yDomain'
|
|
72
|
+
| 'rDomain'
|
|
73
|
+
| 'x1Domain'
|
|
74
|
+
| 'y1Domain'
|
|
75
|
+
| 'zRange'
|
|
76
|
+
| 'rRange'
|
|
77
|
+
| 'cRange'
|
|
78
|
+
| 'x1Range'
|
|
79
|
+
| 'y1Range'
|
|
80
|
+
>;
|
|
81
|
+
|
|
82
|
+
export type ChartContextValue<
|
|
83
|
+
T = any,
|
|
84
|
+
XScale extends AnyScale = AnyScale,
|
|
85
|
+
YScale extends AnyScale = AnyScale,
|
|
86
|
+
> = {
|
|
87
|
+
activeGetters: Record<AxisKey, (d: T) => any>;
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
percentRange: boolean;
|
|
91
|
+
aspectRatio: number;
|
|
92
|
+
containerRef: HTMLElement | undefined;
|
|
93
|
+
containerWidth: number;
|
|
94
|
+
containerHeight: number;
|
|
95
|
+
config: PreservedChartConfig<T, XScale, YScale>;
|
|
96
|
+
x: (d: T) => any;
|
|
97
|
+
y: (d: T) => any;
|
|
98
|
+
z: (d: T) => any;
|
|
99
|
+
r: (d: T) => any;
|
|
100
|
+
x1: (d: T) => any;
|
|
101
|
+
y1: (d: T) => any;
|
|
102
|
+
c: (d: T) => any;
|
|
103
|
+
data: DataType<T>;
|
|
104
|
+
xNice: Nice;
|
|
105
|
+
yNice: Nice;
|
|
106
|
+
zNice: Nice;
|
|
107
|
+
rNice: Nice;
|
|
108
|
+
xDomainSort: boolean;
|
|
109
|
+
yDomainSort: boolean;
|
|
110
|
+
zDomainSort: boolean;
|
|
111
|
+
rDomainSort: boolean;
|
|
112
|
+
xReverse: boolean;
|
|
113
|
+
yReverse: boolean;
|
|
114
|
+
zReverse: boolean;
|
|
115
|
+
rReverse: boolean;
|
|
116
|
+
xPadding: PaddingArray;
|
|
117
|
+
yPadding: PaddingArray;
|
|
118
|
+
zPadding: PaddingArray;
|
|
119
|
+
rPadding: PaddingArray;
|
|
120
|
+
padding: Padding;
|
|
121
|
+
flatData: T[];
|
|
122
|
+
extents: Extents;
|
|
123
|
+
xDomain: number[];
|
|
124
|
+
yDomain: number[];
|
|
125
|
+
zDomain: DomainType;
|
|
126
|
+
rDomain: DomainType;
|
|
127
|
+
cDomain: DomainType;
|
|
128
|
+
x1Domain: DomainType;
|
|
129
|
+
y1Domain: DomainType;
|
|
130
|
+
xRange: any[];
|
|
131
|
+
yRange: any[];
|
|
132
|
+
zRange: any[];
|
|
133
|
+
rRange: any[];
|
|
134
|
+
cRange: readonly string[] | string[] | undefined;
|
|
135
|
+
x1Range: XRangeWithScale<XScale> | undefined;
|
|
136
|
+
y1Range: YRangeWithScale<YScale> | undefined;
|
|
137
|
+
meta: Record<string, any>;
|
|
138
|
+
xScale: AnyScale;
|
|
139
|
+
yScale: AnyScale;
|
|
140
|
+
zScale: AnyScale;
|
|
141
|
+
rScale: AnyScale;
|
|
142
|
+
cScale: AnyScale | null;
|
|
143
|
+
x1Scale: AnyScale | null;
|
|
144
|
+
y1Scale: AnyScale | null;
|
|
145
|
+
yGet: (d: T) => any;
|
|
146
|
+
xGet: (d: T) => any;
|
|
147
|
+
zGet: (d: T) => any;
|
|
148
|
+
rGet: (d: T) => any;
|
|
149
|
+
cGet: (d: T) => any;
|
|
150
|
+
x1Get: (d: T) => any;
|
|
151
|
+
y1Get: (d: T) => any;
|
|
152
|
+
radial: boolean;
|
|
153
|
+
tooltip: TooltipContextValue<T>;
|
|
154
|
+
geo: GeoContextValue;
|
|
155
|
+
brush: BrushContextValue;
|
|
156
|
+
transform: TransformContextValue;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type LayerChartInternalMeta = {
|
|
160
|
+
/**
|
|
161
|
+
* The current chart type.
|
|
162
|
+
* The default is `'default'` which is any chart being composed
|
|
163
|
+
* that isn't a "simplified chart".
|
|
164
|
+
*/
|
|
165
|
+
type:
|
|
166
|
+
| 'default'
|
|
167
|
+
| 'simplified-area'
|
|
168
|
+
| 'simplified-bar'
|
|
169
|
+
| 'simplified-line'
|
|
170
|
+
| 'simplified-pie'
|
|
171
|
+
| 'simplified-scatter';
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const _ChartContext = new Context<ChartContextValue<any, AnyScale, AnyScale>>('ChartContext');
|
|
175
|
+
|
|
176
|
+
export function getChartContext<
|
|
177
|
+
T,
|
|
178
|
+
XScale extends AnyScale = AnyScale,
|
|
179
|
+
YScale extends AnyScale = AnyScale,
|
|
180
|
+
>(): ChartContextValue<T, XScale, YScale> {
|
|
181
|
+
return _ChartContext.getOr({} as ChartContextValue<T, XScale, YScale>);
|
|
11
182
|
}
|
|
12
183
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
184
|
+
export function setChartContext<
|
|
185
|
+
T,
|
|
186
|
+
XScale extends AnyScale = AnyScale,
|
|
187
|
+
YScale extends AnyScale = AnyScale,
|
|
188
|
+
>(context: ChartContextValue<T, XScale, YScale>): ChartContextValue<T, XScale, YScale> {
|
|
189
|
+
// @ts-expect-error - shh
|
|
190
|
+
return _ChartContext.set(context);
|
|
16
191
|
}
|
|
17
|
-
</script>
|
|
18
192
|
|
|
19
|
-
|
|
20
|
-
import { onMount, type ComponentProps } from 'svelte';
|
|
21
|
-
import { LayerCake } from 'layercake';
|
|
22
|
-
import type { HierarchyNode } from 'd3-hierarchy';
|
|
23
|
-
import type { SankeyGraph } from 'd3-sankey';
|
|
24
|
-
import { max, min } from 'd3-array';
|
|
193
|
+
export type RenderContext = 'svg' | 'canvas' | 'html';
|
|
25
194
|
|
|
26
|
-
|
|
27
|
-
import GeoContext from './GeoContext.svelte';
|
|
28
|
-
import TooltipContext from './tooltip/TooltipContext.svelte';
|
|
29
|
-
import TransformContext from './TransformContext.svelte';
|
|
30
|
-
import BrushContext from './BrushContext.svelte';
|
|
195
|
+
const _RenderContext = new Context<RenderContext>('RenderContext');
|
|
31
196
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
197
|
+
export function getRenderContext(): RenderContext {
|
|
198
|
+
return _RenderContext.get();
|
|
199
|
+
}
|
|
35
200
|
|
|
36
|
-
|
|
201
|
+
export function setRenderContext(context: RenderContext): RenderContext {
|
|
202
|
+
return _RenderContext.set(context);
|
|
203
|
+
}
|
|
37
204
|
|
|
38
|
-
|
|
39
|
-
|
|
205
|
+
export type ChartPropsWithoutHTML<
|
|
206
|
+
T,
|
|
207
|
+
XScale extends AnyScale = AnyScale,
|
|
208
|
+
YScale extends AnyScale = AnyScale,
|
|
209
|
+
> = {
|
|
210
|
+
/**
|
|
211
|
+
* Whether this chart should be rendered server side
|
|
212
|
+
*
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
40
215
|
ssr?: boolean;
|
|
41
216
|
|
|
42
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Whether to allow pointer events via CSS.
|
|
219
|
+
* Set this to `false` to set `pointer-events: none;` on all components, disabling
|
|
220
|
+
* all mouse interactions.
|
|
221
|
+
*
|
|
222
|
+
* @default true
|
|
223
|
+
*/
|
|
43
224
|
pointerEvents?: boolean;
|
|
44
225
|
|
|
45
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* Determine the positioning of the wrapper div.
|
|
228
|
+
* Set this to `'absolute'` when you want to stack layers.
|
|
229
|
+
*
|
|
230
|
+
* @default 'relative'
|
|
231
|
+
*/
|
|
46
232
|
position?: string;
|
|
47
233
|
|
|
48
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* If `true`, set all scale ranges to `[0, 100]`.
|
|
236
|
+
* Ranges reversed via `xReverse`, `yReverse`, or `rReverse` props will
|
|
237
|
+
* continue to be reversed as usual.
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
49
240
|
percentRange?: boolean;
|
|
50
241
|
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
242
|
+
/**
|
|
243
|
+
* A bindable reference to the root container element.
|
|
244
|
+
*/
|
|
245
|
+
ref?: HTMLElement;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* If `data` is not a flat array of objects and you want to use any of the scales, set a flat
|
|
249
|
+
* version of the data via the `flatData` prop.
|
|
250
|
+
*/
|
|
251
|
+
data?: T[] | readonly T[] | HierarchyNode<T> | SankeyGraph<any, any>;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* A flat version of data.
|
|
255
|
+
*/
|
|
256
|
+
flatData?: T[] | readonly T[] | HierarchyNode<T> | SankeyGraph<any, any>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The x accessor. The key in each row of data that corresponds to the x-field. This can be a
|
|
260
|
+
* string, an accessor function, a number or an array of any combination of those types. This
|
|
261
|
+
* property gets converted to a function when you access it through the context.
|
|
262
|
+
*/
|
|
263
|
+
x?: Accessor<T>;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The y accessor. The key in each row of data that corresponds to the y-field. This can be a
|
|
267
|
+
* string, an accessor function, a number or an array of any combination of those types. This
|
|
268
|
+
* property gets converted to a function when you access it through the context.
|
|
269
|
+
*/
|
|
270
|
+
y?: Accessor<T>;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The z accessor. The key in each row of data that corresponds to the z-field. This can be a
|
|
274
|
+
* string, an accessor function, a number or an array of any combination of those types. This
|
|
275
|
+
* property gets converted to a function when you access it through the context.
|
|
276
|
+
*/
|
|
277
|
+
z?: Accessor<T>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The r accessor. The key in each row of data that corresponds to the r-field. This can be a
|
|
281
|
+
* string, an accessor function, a number or an array of any combination of those types. This
|
|
282
|
+
* property gets converted to a function when you access it through the context.
|
|
283
|
+
*/
|
|
284
|
+
r?: Accessor<T>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The x1 accessor. The key in each row of data that corresponds to the x1-field. This can be a
|
|
288
|
+
* string, an accessor function, a number or an array of any combination of those types. This
|
|
289
|
+
* property gets converted to a function when you access it through the context.
|
|
290
|
+
*/
|
|
291
|
+
x1?: Accessor<T>;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The y1 accessor. The key in each row of data that corresponds to the y1-field. This can be
|
|
295
|
+
* a string, an accessor function, a number or an array of any combination of those types. This
|
|
296
|
+
* property gets converted to a function when you access it through the context.
|
|
297
|
+
*/
|
|
298
|
+
y1?: Accessor<T>;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The c (color) accessor. The key in each row of data that corresponds to the color. This can
|
|
302
|
+
* be a string or an accessor function. This property gets converted to a function when you
|
|
303
|
+
* access it through the context.
|
|
304
|
+
*/
|
|
305
|
+
c?: Accessor<T>;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Set a min or max. For linear scales, if you want to inherit the value from the data's
|
|
309
|
+
* extent, set that value to `null`. This value can also be an array because sometimes your
|
|
310
|
+
* scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of
|
|
311
|
+
* discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales),
|
|
312
|
+
* useful for color series. Set it to a function that receives the computed domain and lets you
|
|
313
|
+
* return a modified domain, useful for sorting values.
|
|
314
|
+
*/
|
|
86
315
|
xDomain?: DomainType;
|
|
87
|
-
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Set a min or max. For linear scales, if you want to inherit the value from the data's
|
|
319
|
+
* extent, set that value to `null`. This value can also be an array because sometimes your
|
|
320
|
+
* scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of
|
|
321
|
+
* discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales),
|
|
322
|
+
* useful for color series. Set it to a function that receives the computed domain and lets you
|
|
323
|
+
* return a modified domain, useful for sorting values.
|
|
324
|
+
*/
|
|
88
325
|
yDomain?: DomainType;
|
|
89
|
-
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Set a min or max. For linear scales, if you want to inherit the value from the data's
|
|
329
|
+
* extent, set that value to `null`. This value can also be an array because sometimes your
|
|
330
|
+
* scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of
|
|
331
|
+
* discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales),
|
|
332
|
+
* useful for color series. Set it to a function that receives the computed domain and lets you
|
|
333
|
+
* return a modified domain, useful for sorting values.
|
|
334
|
+
*/
|
|
90
335
|
zDomain?: DomainType;
|
|
91
|
-
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Set a min or max. For linear scales, if you want to inherit the value from the data's
|
|
339
|
+
* extent, set that value to `null`. This value can also be an array because sometimes your
|
|
340
|
+
* scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of
|
|
341
|
+
* discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales),
|
|
342
|
+
* useful for color series. Set it to a function that receives the computed domain and lets you
|
|
343
|
+
* return a modified domain, useful for sorting values.
|
|
344
|
+
*/
|
|
92
345
|
rDomain?: DomainType;
|
|
93
|
-
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Set a min or max. For linear scales, if you want to inherit the value from the data's
|
|
349
|
+
* extent, set that value to `null`. This value can also be an array because sometimes your
|
|
350
|
+
* scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of
|
|
351
|
+
* discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales),
|
|
352
|
+
* useful for color series. Set it to a function that receives the computed domain and lets you
|
|
353
|
+
* return a modified domain, useful for sorting values.
|
|
354
|
+
*/
|
|
94
355
|
x1Domain?: DomainType;
|
|
95
|
-
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Set a min or max. For linear scales, if you want to inherit the value from the data's
|
|
359
|
+
* extent, set that value to `null`. This value can also be an array because sometimes your
|
|
360
|
+
* scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of
|
|
361
|
+
* discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales),
|
|
362
|
+
* useful for color series. Set it to a function that receives the computed domain and lets you
|
|
363
|
+
* return a modified domain, useful for sorting values.
|
|
364
|
+
*/
|
|
96
365
|
y1Domain?: DomainType;
|
|
97
|
-
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Set the list of color values.
|
|
369
|
+
*/
|
|
98
370
|
cDomain?: DomainType;
|
|
99
371
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
372
|
+
/**
|
|
373
|
+
* Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the x domain.
|
|
374
|
+
* @default false
|
|
375
|
+
*/
|
|
376
|
+
xNice?: Nice;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the y domain.
|
|
380
|
+
* @default false
|
|
381
|
+
*/
|
|
382
|
+
yNice?: Nice;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the z domain.
|
|
386
|
+
* @default false
|
|
387
|
+
*/
|
|
388
|
+
zNice?: Nice;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the r domain.
|
|
392
|
+
* @default false
|
|
393
|
+
*/
|
|
394
|
+
rNice?: Nice;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Assign a pixel value to add to the min or max of the scale. This will increase the scales
|
|
398
|
+
* domain by the scale unit equivalent of the provided pixels.
|
|
399
|
+
*/
|
|
400
|
+
xPadding?: PaddingArray;
|
|
401
|
+
/**
|
|
402
|
+
* Assign a pixel value to add to the min or max of the scale. This will increase the scales
|
|
403
|
+
* domain by the scale unit equivalent of the provided pixels.
|
|
404
|
+
*/
|
|
405
|
+
yPadding?: PaddingArray;
|
|
406
|
+
/**
|
|
407
|
+
* Assign a pixel value to add to the min or max of the scale. This will increase the scales
|
|
408
|
+
* domain by the scale unit equivalent of the provided pixels.
|
|
409
|
+
*/
|
|
410
|
+
zPadding?: PaddingArray;
|
|
411
|
+
/**
|
|
412
|
+
* Assign a pixel value to add to the min or max of the scale. This will increase the scales
|
|
413
|
+
* domain by the scale unit equivalent of the provided pixels.
|
|
414
|
+
*/
|
|
415
|
+
rPadding?: PaddingArray;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
|
|
419
|
+
* you want to override the default or you want to extra options.
|
|
420
|
+
* @default scaleLinear
|
|
421
|
+
*/
|
|
422
|
+
xScale?: XScale;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
|
|
426
|
+
* you want to override the default or you want to extra options.
|
|
427
|
+
* @default scaleLinear
|
|
428
|
+
*/
|
|
429
|
+
yScale?: YScale;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
|
|
433
|
+
* you want to override the default or you want to extra options.
|
|
434
|
+
* @default scaleLinear
|
|
435
|
+
*/
|
|
123
436
|
zScale?: AnyScale;
|
|
124
|
-
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if
|
|
440
|
+
* you want to override the default or you want to extra options.
|
|
441
|
+
* @default scaleSqrt
|
|
442
|
+
*/
|
|
125
443
|
rScale?: AnyScale;
|
|
126
|
-
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* The D3 scale that should be used for the x1-dimension. Pass in an instantiated D3 scale if
|
|
447
|
+
* you want to override the default or you want to extra options.
|
|
448
|
+
* @default scaleLinear
|
|
449
|
+
*/
|
|
127
450
|
x1Scale?: AnyScale;
|
|
128
|
-
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The D3 scale that should be used for the y1-dimension. Pass in an instantiated D3 scale if
|
|
454
|
+
* you want to override the default or you want to extra options.
|
|
455
|
+
* @default scaleLinear
|
|
456
|
+
*/
|
|
129
457
|
y1Scale?: AnyScale;
|
|
130
|
-
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* The D3 scale that should be used for the color dimension. Pass in an instantiated D3 scale
|
|
461
|
+
* if you want to override the default or you want to extra options.
|
|
462
|
+
* @default scaleOrdinal
|
|
463
|
+
*/
|
|
131
464
|
cScale?: AnyScale;
|
|
132
465
|
|
|
133
|
-
/** Override the default x range of `[0, width]` by setting an array or function with argument
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
466
|
+
/** Override the default x range of `[0, width]` by setting an array or function with argument
|
|
467
|
+
* `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can
|
|
468
|
+
* also be a list of numbers or strings for scales with discrete ranges like
|
|
469
|
+
* [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
470
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
471
|
+
*/
|
|
472
|
+
xRange?: BaseRange;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Override the default y range of `[0, height]` by setting an array or function with argument
|
|
476
|
+
* `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can
|
|
477
|
+
* also be a list of numbers or strings for scales with discrete ranges like
|
|
478
|
+
* [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
479
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
480
|
+
*/
|
|
481
|
+
yRange?: BaseRange;
|
|
482
|
+
|
|
483
|
+
/** Override the default z range of `[0, width]` by setting an array or function with argument
|
|
484
|
+
* `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can
|
|
485
|
+
* also be a list of numbers or strings for scales with discrete ranges like
|
|
486
|
+
* [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
487
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
488
|
+
*/
|
|
489
|
+
zRange?: BaseRange;
|
|
490
|
+
|
|
491
|
+
/** Override the default r range of `[1, 25]` by setting an array or function with argument
|
|
492
|
+
* `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can
|
|
493
|
+
* also be a list of numbers or strings for scales with discrete ranges like
|
|
494
|
+
* [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
495
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
496
|
+
*/
|
|
497
|
+
rRange?: BaseRange;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Set the x1 range by setting an array or function with argument `({ xScale, width, height})`
|
|
501
|
+
* that returns an array. This can also be a list of numbers or strings for scales with
|
|
502
|
+
* discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
503
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
504
|
+
*/
|
|
505
|
+
x1Range?: XRangeWithScale<XScale>;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Set the y1 range by setting an array or function with argument `({ yScale, width, height})`
|
|
509
|
+
* that returns an array. This can also be a list of numbers or strings for scales with
|
|
510
|
+
* discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
511
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
512
|
+
*/
|
|
513
|
+
y1Range?: YRangeWithScale<YScale>;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Override the default y1 range of `[0, width]` by setting an array or function with argument
|
|
517
|
+
* `({ yScale, width, height})` that returns an array. Setting this prop overrides `x1Reverse`.
|
|
518
|
+
* This can also be a list of numbers or strings for scales with discrete ranges like
|
|
519
|
+
* [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or
|
|
520
|
+
* [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales).
|
|
521
|
+
*/
|
|
164
522
|
cRange?: string[] | readonly string[];
|
|
165
523
|
|
|
166
|
-
/**
|
|
524
|
+
/**
|
|
525
|
+
* Reverse the default x range. By default this is `false` and the range is `[0, width]`.
|
|
526
|
+
* Ignored if you set the xRange prop.
|
|
527
|
+
* @default false
|
|
528
|
+
*/
|
|
167
529
|
xReverse?: boolean;
|
|
168
|
-
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Reverse the default y range. By default this is `true` and the range is `[height, 0]` unless
|
|
533
|
+
* using an ordinal scale with a `.bandwidth` method for `yScale`.
|
|
534
|
+
* Ignored if you set the `yRange` prop.
|
|
535
|
+
* @default true
|
|
536
|
+
*/
|
|
169
537
|
yReverse?: boolean;
|
|
170
|
-
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Reverse the default z range. By default this is `false` and the range is `[0, width]`.
|
|
541
|
+
* Ignored if you set the zRange prop.
|
|
542
|
+
* @default false
|
|
543
|
+
*/
|
|
171
544
|
zReverse?: boolean;
|
|
172
|
-
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Reverse the default r range. By default this is `false` and the range is `[1, 25]`.
|
|
548
|
+
* Ignored if you set the rRange prop.
|
|
549
|
+
* @default false
|
|
550
|
+
*/
|
|
173
551
|
rReverse?: boolean;
|
|
174
552
|
|
|
175
|
-
/**
|
|
553
|
+
/**
|
|
554
|
+
* ***Only used when scale is ordinal.***
|
|
555
|
+
* Set whether the calculated unique items come back sorted.
|
|
556
|
+
*
|
|
557
|
+
* @default false
|
|
558
|
+
*/
|
|
176
559
|
xDomainSort?: boolean;
|
|
177
|
-
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* ***Only used when scale is ordinal.***
|
|
563
|
+
* Set whether the calculated unique items come back sorted.
|
|
564
|
+
*
|
|
565
|
+
* @default false
|
|
566
|
+
*/
|
|
178
567
|
yDomainSort?: boolean;
|
|
179
|
-
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* ***Only used when scale is ordinal.***
|
|
571
|
+
* Set whether the calculated unique items come back sorted.
|
|
572
|
+
*
|
|
573
|
+
* @default false
|
|
574
|
+
*/
|
|
180
575
|
zDomainSort?: boolean;
|
|
181
|
-
/** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
|
|
182
|
-
rDomainSort?: boolean;
|
|
183
576
|
|
|
184
|
-
/**
|
|
185
|
-
|
|
577
|
+
/**
|
|
578
|
+
* ***Only used when scale is ordinal.***
|
|
579
|
+
* Set whether the calculated unique items come back sorted.
|
|
580
|
+
*
|
|
581
|
+
* @default false
|
|
582
|
+
*/
|
|
583
|
+
rDomainSort?: boolean;
|
|
186
584
|
|
|
187
|
-
/**
|
|
585
|
+
/**
|
|
586
|
+
* The amount of padding to put around your chart. It operates like CSS
|
|
587
|
+
* box-sizing: border-box; where values are subtracted from the parent container's width
|
|
588
|
+
* and height, the same as a [D3 margin convention](https://bl.ocks.org/mbostock/3019563).
|
|
589
|
+
*
|
|
590
|
+
* If a number is passed, it will be applied to all sides.
|
|
591
|
+
*/
|
|
592
|
+
padding?: { top?: number; right?: number; bottom?: number; left?: number } | number;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Manually set the extents of the x, y or r scale as a two-dimensional array of the min and
|
|
596
|
+
* max you want. Setting values here will skip any dynamic extent calculation of the data for
|
|
597
|
+
* that dimension.
|
|
598
|
+
*/
|
|
188
599
|
extents?: {
|
|
189
|
-
x?: [min:
|
|
190
|
-
y?: [min:
|
|
191
|
-
r?: [min:
|
|
192
|
-
z?: [min:
|
|
600
|
+
x?: [min: number, max: number];
|
|
601
|
+
y?: [min: number, max: number];
|
|
602
|
+
r?: [min: number, max: number];
|
|
603
|
+
z?: [min: number, max: number];
|
|
193
604
|
};
|
|
194
605
|
|
|
195
|
-
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
606
|
+
/**
|
|
607
|
+
* Any extra configuration values you want available on the Chart context.
|
|
608
|
+
* This could be useful for color lookups or additional constants.
|
|
609
|
+
*/
|
|
610
|
+
meta?: Record<string, any>;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Enable debug printing to the console.
|
|
614
|
+
* Useful to inspect your scales and dimensions.
|
|
615
|
+
*
|
|
616
|
+
* @default false
|
|
617
|
+
*/
|
|
199
618
|
debug?: boolean;
|
|
200
619
|
|
|
201
|
-
/**
|
|
620
|
+
/**
|
|
621
|
+
* Show warnings in the console.
|
|
622
|
+
*
|
|
623
|
+
* @default true
|
|
624
|
+
*/
|
|
202
625
|
verbose?: boolean;
|
|
203
626
|
|
|
204
|
-
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
627
|
+
/**
|
|
628
|
+
* x value guaranteed to be visible in xDomain. Useful with optional negative values since
|
|
629
|
+
* `xDomain={[0, null]}` would ignore negative values
|
|
630
|
+
*
|
|
631
|
+
* @default null
|
|
632
|
+
*/
|
|
633
|
+
xBaseline?: number | null;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* y value guaranteed to be visible in yDomain. Useful with optional negative values since
|
|
637
|
+
* `yDomain={[0, null]}` would ignore negative values
|
|
638
|
+
*
|
|
639
|
+
* @default null
|
|
640
|
+
*/
|
|
641
|
+
yBaseline?: number | null;
|
|
209
642
|
|
|
210
643
|
/* Props passed to ChartContext */
|
|
211
|
-
/** Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
212
|
-
radial?: typeof radial;
|
|
213
|
-
|
|
214
|
-
/** Props passed to GeoContext */
|
|
215
|
-
geo?: typeof geo;
|
|
216
|
-
|
|
217
|
-
/** Exposed via bind: to support `bind:geoProjection` for external access */
|
|
218
|
-
geoProjection?: typeof geoProjection;
|
|
219
|
-
|
|
220
|
-
/** Props passed to TooltipContext */
|
|
221
|
-
tooltip?: typeof tooltip;
|
|
222
|
-
|
|
223
|
-
/** Exposed via bind: to support `bind:tooltipContext` for external access (ex. `tooltipContext.data) */
|
|
224
|
-
tooltipContext?: typeof tooltipContext;
|
|
225
|
-
|
|
226
|
-
/** Props passed to TransformContext */
|
|
227
|
-
transform?: typeof transform;
|
|
228
644
|
|
|
229
|
-
/**
|
|
230
|
-
|
|
645
|
+
/**
|
|
646
|
+
* Use radial instead of cartesian coordinates, mapping `x` to `angle` and `y`` to radial.
|
|
647
|
+
* Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`)
|
|
648
|
+
* to change the origin
|
|
649
|
+
*
|
|
650
|
+
* @default false
|
|
651
|
+
*/
|
|
652
|
+
radial?: boolean;
|
|
653
|
+
|
|
654
|
+
children?: Snippet<[{ context: ChartContextValue<T, XScale, YScale> }]>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* A bindable reference to the chart context.
|
|
658
|
+
*/
|
|
659
|
+
context?: ChartContextValue<T, XScale, YScale>;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Props passed to GeoContext
|
|
663
|
+
*/
|
|
664
|
+
geo?: Partial<ComponentProps<typeof GeoContext>>;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Props passed to the `TooltipContext` component.
|
|
668
|
+
*/
|
|
669
|
+
tooltip?: Partial<ComponentProps<typeof TooltipContext>> | boolean;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Props passed to TransformContext
|
|
673
|
+
*/
|
|
674
|
+
transform?: Partial<ComponentProps<typeof TransformContext>>;
|
|
231
675
|
|
|
232
676
|
/** Props passed to BrushContext */
|
|
233
|
-
brush?: typeof
|
|
677
|
+
brush?: Partial<ComponentProps<typeof BrushContext>> | boolean;
|
|
234
678
|
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
onresize?: typeof onresize;
|
|
679
|
+
/**
|
|
680
|
+
* A callback function that is called when the chart is resized.
|
|
681
|
+
*/
|
|
682
|
+
onResize?: (e: ChartResizeDetail) => void;
|
|
240
683
|
|
|
241
684
|
// TransformContext callback events
|
|
242
|
-
ondragstart?: typeof ondragstart;
|
|
243
|
-
ondragend?: typeof ondragend;
|
|
244
|
-
|
|
245
|
-
}
|
|
685
|
+
ondragstart?: ComponentProps<typeof TransformContext>['ondragstart'];
|
|
686
|
+
ondragend?: ComponentProps<typeof TransformContext>['ondragend'];
|
|
687
|
+
onTransform?: ComponentProps<typeof TransformContext>['onTransform'];
|
|
688
|
+
};
|
|
689
|
+
</script>
|
|
246
690
|
|
|
247
|
-
|
|
691
|
+
<script
|
|
692
|
+
lang="ts"
|
|
693
|
+
generics="TData = any, XScale extends AnyScale = AnyScale, YScale extends AnyScale = AnyScale"
|
|
694
|
+
>
|
|
695
|
+
let {
|
|
696
|
+
ssr = false,
|
|
697
|
+
pointerEvents = true,
|
|
698
|
+
position = 'relative',
|
|
699
|
+
percentRange = false,
|
|
700
|
+
ref: refProp = $bindable(),
|
|
701
|
+
x: xProp,
|
|
702
|
+
y: yProp,
|
|
703
|
+
z: zProp,
|
|
704
|
+
r: rProp,
|
|
705
|
+
data = [],
|
|
706
|
+
xDomain: xDomainProp,
|
|
707
|
+
yDomain: yDomainProp,
|
|
708
|
+
zDomain: zDomainProp,
|
|
709
|
+
rDomain: rDomainProp,
|
|
710
|
+
xNice = false,
|
|
711
|
+
yNice = false,
|
|
712
|
+
zNice = false,
|
|
713
|
+
rNice = false,
|
|
714
|
+
xPadding,
|
|
715
|
+
yPadding,
|
|
716
|
+
zPadding,
|
|
717
|
+
rPadding,
|
|
718
|
+
// @ts-expect-error shh
|
|
719
|
+
xScale: xScaleProp = scaleLinear(),
|
|
720
|
+
// @ts-expect-error shh
|
|
721
|
+
yScale: yScaleProp = scaleLinear(),
|
|
722
|
+
zScale: zScaleProp = scaleLinear(),
|
|
723
|
+
rScale: rScaleProp = scaleSqrt(),
|
|
724
|
+
flatData: flatDataProp,
|
|
725
|
+
padding: paddingProp = {},
|
|
726
|
+
verbose = true,
|
|
727
|
+
debug = false,
|
|
728
|
+
extents: extentsProp = {},
|
|
729
|
+
xDomainSort = false,
|
|
730
|
+
yDomainSort = false,
|
|
731
|
+
zDomainSort = false,
|
|
732
|
+
rDomainSort = false,
|
|
733
|
+
xReverse = false,
|
|
734
|
+
zReverse = false,
|
|
735
|
+
rReverse = false,
|
|
736
|
+
yRange: _yRangeProp,
|
|
737
|
+
zRange: zRangeProp,
|
|
738
|
+
rRange: rRangeProp,
|
|
739
|
+
xBaseline = null,
|
|
740
|
+
yBaseline = null,
|
|
741
|
+
meta = {},
|
|
742
|
+
children: _children,
|
|
743
|
+
radial = false,
|
|
744
|
+
xRange: _xRangeProp,
|
|
745
|
+
x1: x1Prop,
|
|
746
|
+
x1Domain: x1DomainProp,
|
|
747
|
+
x1Range: x1RangeProp,
|
|
748
|
+
x1Scale: x1ScaleProp,
|
|
749
|
+
y1: y1Prop,
|
|
750
|
+
y1Domain: y1DomainProp,
|
|
751
|
+
y1Range: y1RangeProp,
|
|
752
|
+
y1Scale: y1ScaleProp,
|
|
753
|
+
c: cProp,
|
|
754
|
+
cScale: cScaleProp,
|
|
755
|
+
cDomain: cDomainProp,
|
|
756
|
+
cRange: cRangeProp,
|
|
757
|
+
onResize,
|
|
758
|
+
geo,
|
|
759
|
+
context: contextProp = $bindable(),
|
|
760
|
+
tooltip,
|
|
761
|
+
transform,
|
|
762
|
+
onTransform,
|
|
763
|
+
ondragend,
|
|
764
|
+
ondragstart,
|
|
765
|
+
brush,
|
|
766
|
+
}: ChartPropsWithoutHTML<TData, XScale, YScale> = $props();
|
|
767
|
+
|
|
768
|
+
let ref = $state<HTMLElement>();
|
|
769
|
+
|
|
770
|
+
$effect.pre(() => {
|
|
771
|
+
refProp = ref;
|
|
772
|
+
});
|
|
248
773
|
|
|
249
|
-
|
|
250
|
-
export let xRange: $$Props['xRange'] = undefined;
|
|
774
|
+
const xRangeProp = $derived(_xRangeProp ? _xRangeProp : radial ? [0, 2 * Math.PI] : undefined);
|
|
251
775
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
export let yRange: $$Props['yRange'] = undefined;
|
|
776
|
+
let containerWidth = $state(100);
|
|
777
|
+
let containerHeight = $state(100);
|
|
255
778
|
|
|
256
|
-
|
|
257
|
-
export let x1Scale: $$Props['x1Scale'] = undefined;
|
|
258
|
-
export let x1Domain: $$Props['x1Domain'] = undefined;
|
|
259
|
-
export let x1Range: $$Props['x1Range'] = undefined;
|
|
779
|
+
const logDebug = useDebounce(printDebug, 200);
|
|
260
780
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
781
|
+
const _xDomain: DomainType | undefined = $derived.by(() => {
|
|
782
|
+
if (xDomainProp !== undefined) return xDomainProp;
|
|
783
|
+
if (xBaseline != null && Array.isArray(data)) {
|
|
784
|
+
const xValues = data.flatMap(accessor(xProp));
|
|
785
|
+
return [min([xBaseline, ...xValues]), max([xBaseline, ...xValues])];
|
|
786
|
+
}
|
|
787
|
+
});
|
|
265
788
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
789
|
+
const _yDomain: DomainType | undefined = $derived.by(() => {
|
|
790
|
+
if (yDomainProp !== undefined) return yDomainProp;
|
|
791
|
+
if (yBaseline != null && Array.isArray(data)) {
|
|
792
|
+
const yValues = data.flatMap(accessor(yProp));
|
|
793
|
+
return [min([yBaseline, ...yValues]), max([yBaseline, ...yValues])];
|
|
794
|
+
}
|
|
795
|
+
});
|
|
270
796
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
export let xBaseline: number | null = null;
|
|
797
|
+
const yRangeProp = $derived(
|
|
798
|
+
_yRangeProp ?? (radial ? ({ height }: { height: number }) => [0, height / 2] : undefined)
|
|
799
|
+
);
|
|
275
800
|
|
|
276
|
-
|
|
277
|
-
$: if (xBaseline != null && Array.isArray(data)) {
|
|
278
|
-
const xValues = data.flatMap(accessor(x));
|
|
279
|
-
xDomain = [min([xBaseline, ...xValues]), max([xBaseline, ...xValues])];
|
|
280
|
-
}
|
|
801
|
+
const yReverse = $derived(yScaleProp ? !isScaleBand(yScaleProp) : true);
|
|
281
802
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
803
|
+
const x = $derived(makeAccessor(xProp));
|
|
804
|
+
const y = $derived(makeAccessor(yProp));
|
|
805
|
+
const z = $derived(makeAccessor(zProp));
|
|
806
|
+
const r = $derived(makeAccessor(rProp));
|
|
807
|
+
const c = $derived(accessor(cProp));
|
|
808
|
+
const x1 = $derived(accessor(x1Prop));
|
|
809
|
+
const y1 = $derived(accessor(y1Prop));
|
|
286
810
|
|
|
287
|
-
|
|
288
|
-
$: if (yBaseline != null && Array.isArray(data)) {
|
|
289
|
-
const yValues = data.flatMap(accessor(y));
|
|
290
|
-
yDomain = [min([yBaseline, ...yValues]), max([yBaseline, ...yValues])];
|
|
291
|
-
}
|
|
811
|
+
const flatData = $derived(flatDataProp ?? data) as TData[];
|
|
292
812
|
|
|
293
|
-
|
|
294
|
-
* Reverse the default y range ([0, height] becomes [height, 0]). By default this is `true` unless using scaleBand y scale.
|
|
295
|
-
* see: https://layercake.graphics/guide#yreverse
|
|
296
|
-
* see: https://github.com/mhkeller/layercake/issues/83
|
|
297
|
-
*/
|
|
298
|
-
$: yReverse = yScale ? !isScaleBand(yScale) : true;
|
|
813
|
+
const filteredExtents = $derived(filterObject($state.snapshot(extentsProp)));
|
|
299
814
|
|
|
300
|
-
|
|
301
|
-
|
|
815
|
+
const activeGetters = $derived({
|
|
816
|
+
x,
|
|
817
|
+
y,
|
|
818
|
+
z,
|
|
819
|
+
r,
|
|
820
|
+
});
|
|
302
821
|
|
|
303
|
-
|
|
304
|
-
|
|
822
|
+
const padding = $derived.by(() => {
|
|
823
|
+
if (typeof paddingProp === 'number') {
|
|
824
|
+
return {
|
|
825
|
+
...defaultPadding,
|
|
826
|
+
top: paddingProp,
|
|
827
|
+
right: paddingProp,
|
|
828
|
+
bottom: paddingProp,
|
|
829
|
+
left: paddingProp,
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
return { ...defaultPadding, ...paddingProp };
|
|
833
|
+
});
|
|
305
834
|
|
|
306
|
-
|
|
307
|
-
|
|
835
|
+
let isMounted = $state(false);
|
|
836
|
+
|
|
837
|
+
const box = $derived.by(() => {
|
|
838
|
+
const top = padding.top;
|
|
839
|
+
const right = containerWidth - padding.right;
|
|
840
|
+
const bottom = containerHeight - padding.bottom;
|
|
841
|
+
const left = padding.left;
|
|
842
|
+
const width = right - left;
|
|
843
|
+
const height = bottom - top;
|
|
844
|
+
if (verbose === true) {
|
|
845
|
+
if (width <= 0 && isMounted === true) {
|
|
846
|
+
console.warn(
|
|
847
|
+
'[LayerChart] Target div has zero or negative width. Did you forget to set an explicit width in CSS on the container?'
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
if (height <= 0 && isMounted === true) {
|
|
851
|
+
console.warn(
|
|
852
|
+
'[LayerChart] Target div has zero or negative height. Did you forget to set an explicit height in CSS on the container?'
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return {
|
|
858
|
+
top,
|
|
859
|
+
left,
|
|
860
|
+
bottom,
|
|
861
|
+
right,
|
|
862
|
+
width,
|
|
863
|
+
height,
|
|
864
|
+
};
|
|
865
|
+
});
|
|
308
866
|
|
|
309
|
-
|
|
310
|
-
|
|
867
|
+
const width = $derived(box.width);
|
|
868
|
+
const height = $derived(box.height);
|
|
311
869
|
|
|
312
|
-
|
|
313
|
-
|
|
870
|
+
interface ScaleEntry {
|
|
871
|
+
scale: AnyScale;
|
|
872
|
+
sort?: boolean;
|
|
873
|
+
}
|
|
314
874
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
875
|
+
/* --------------------------------------------
|
|
876
|
+
* Calculate extents by taking the extent of the data
|
|
877
|
+
* and filling that in with anything set by the user
|
|
878
|
+
* Note that this is different from an "extent" passed
|
|
879
|
+
* in as a domain, which can be a partial domain
|
|
880
|
+
*/
|
|
881
|
+
const extents: Extents = $derived.by(() => {
|
|
882
|
+
const scaleLookup: Record<string, ScaleEntry> = {
|
|
883
|
+
x: { scale: xScaleProp, sort: xDomainSort },
|
|
884
|
+
y: { scale: yScaleProp, sort: yDomainSort },
|
|
885
|
+
z: { scale: zScaleProp, sort: zDomainSort },
|
|
886
|
+
r: { scale: rScaleProp, sort: rDomainSort },
|
|
887
|
+
};
|
|
319
888
|
|
|
320
|
-
|
|
321
|
-
|
|
889
|
+
const getters = filterObject(activeGetters, filteredExtents);
|
|
890
|
+
const activeScales: Record<string, ScaleEntry> = Object.fromEntries(
|
|
891
|
+
Object.keys(getters).map((k) => [k, scaleLookup[k]])
|
|
892
|
+
);
|
|
893
|
+
|
|
894
|
+
if (Object.keys(getters).length > 0) {
|
|
895
|
+
const calculatedExtents = calcScaleExtents(flatData, getters, activeScales);
|
|
896
|
+
return { ...calculatedExtents, ...filteredExtents };
|
|
897
|
+
} else {
|
|
898
|
+
return {};
|
|
899
|
+
}
|
|
900
|
+
});
|
|
322
901
|
|
|
323
|
-
|
|
324
|
-
|
|
902
|
+
const xDomain = $derived(calcDomain('x', extents, _xDomain));
|
|
903
|
+
const yDomain = $derived(calcDomain('y', extents, _yDomain));
|
|
904
|
+
const zDomain = $derived(calcDomain('z', extents, zDomainProp));
|
|
905
|
+
const rDomain = $derived(calcDomain('r', extents, rDomainProp));
|
|
906
|
+
|
|
907
|
+
const x1Domain = $derived(x1DomainProp ?? extent(chartDataArray(data), x1));
|
|
908
|
+
const y1Domain = $derived(y1DomainProp ?? extent(chartDataArray(data), y1));
|
|
909
|
+
const cDomain = $derived(cDomainProp ?? unique(chartDataArray(data).map(c)));
|
|
910
|
+
|
|
911
|
+
const snappedPadding = $derived($state.snapshot(xPadding));
|
|
912
|
+
const snappedExtents = $derived($state.snapshot(extents));
|
|
913
|
+
|
|
914
|
+
const xScale = $derived(
|
|
915
|
+
createChartScale('x', {
|
|
916
|
+
scale: xScaleProp,
|
|
917
|
+
domain: xDomain,
|
|
918
|
+
padding: snappedPadding,
|
|
919
|
+
nice: xNice,
|
|
920
|
+
reverse: xReverse,
|
|
921
|
+
percentRange,
|
|
922
|
+
range: xRangeProp,
|
|
923
|
+
height,
|
|
924
|
+
width,
|
|
925
|
+
extents: snappedExtents,
|
|
926
|
+
})
|
|
927
|
+
);
|
|
928
|
+
|
|
929
|
+
const xGet = $derived(createGetter(x, xScale));
|
|
930
|
+
|
|
931
|
+
const yScale = $derived(
|
|
932
|
+
createChartScale('y', {
|
|
933
|
+
scale: yScaleProp,
|
|
934
|
+
domain: yDomain,
|
|
935
|
+
padding: yPadding,
|
|
936
|
+
nice: yNice,
|
|
937
|
+
reverse: yReverse,
|
|
938
|
+
percentRange,
|
|
939
|
+
range: yRangeProp,
|
|
940
|
+
height,
|
|
941
|
+
width,
|
|
942
|
+
extents: filteredExtents,
|
|
943
|
+
})
|
|
944
|
+
);
|
|
945
|
+
|
|
946
|
+
const yGet = $derived(createGetter(y, yScale));
|
|
947
|
+
|
|
948
|
+
const zScale = $derived(
|
|
949
|
+
createChartScale('z', {
|
|
950
|
+
scale: zScaleProp,
|
|
951
|
+
domain: zDomain,
|
|
952
|
+
padding: zPadding,
|
|
953
|
+
nice: zNice,
|
|
954
|
+
reverse: zReverse,
|
|
955
|
+
percentRange,
|
|
956
|
+
range: zRangeProp,
|
|
957
|
+
height,
|
|
958
|
+
width,
|
|
959
|
+
extents: filteredExtents,
|
|
960
|
+
})
|
|
961
|
+
);
|
|
962
|
+
const zGet = $derived(createGetter(z, zScale));
|
|
963
|
+
|
|
964
|
+
const rScale = $derived(
|
|
965
|
+
createChartScale('r', {
|
|
966
|
+
scale: rScaleProp,
|
|
967
|
+
domain: rDomain,
|
|
968
|
+
padding: rPadding,
|
|
969
|
+
nice: rNice,
|
|
970
|
+
reverse: rReverse,
|
|
971
|
+
percentRange,
|
|
972
|
+
range: rRangeProp,
|
|
973
|
+
height,
|
|
974
|
+
width,
|
|
975
|
+
extents: filteredExtents,
|
|
976
|
+
})
|
|
977
|
+
);
|
|
978
|
+
|
|
979
|
+
const rGet = $derived(createGetter(r, rScale));
|
|
980
|
+
|
|
981
|
+
const x1Scale = $derived(
|
|
982
|
+
x1ScaleProp && x1RangeProp
|
|
983
|
+
? createScale(x1ScaleProp, x1Domain, x1RangeProp, {
|
|
984
|
+
xScale: xScale,
|
|
985
|
+
width,
|
|
986
|
+
height,
|
|
987
|
+
})
|
|
988
|
+
: null
|
|
989
|
+
);
|
|
990
|
+
|
|
991
|
+
const x1Get = $derived(createGetter(x1, x1Scale));
|
|
992
|
+
|
|
993
|
+
const y1Scale = $derived(
|
|
994
|
+
y1ScaleProp && y1RangeProp
|
|
995
|
+
? createScale(y1ScaleProp, y1Domain, y1RangeProp, {
|
|
996
|
+
yScale: yScale,
|
|
997
|
+
width,
|
|
998
|
+
height,
|
|
999
|
+
})
|
|
1000
|
+
: null
|
|
1001
|
+
);
|
|
1002
|
+
|
|
1003
|
+
const y1Get = $derived(createGetter(y1, y1Scale));
|
|
1004
|
+
|
|
1005
|
+
const cScale = $derived(
|
|
1006
|
+
cRangeProp
|
|
1007
|
+
? createScale(cScaleProp ?? scaleOrdinal(), cDomain, cRangeProp, { width, height })
|
|
1008
|
+
: null
|
|
1009
|
+
);
|
|
1010
|
+
|
|
1011
|
+
const cGet = $derived((d: any) => cScale?.(c(d)));
|
|
1012
|
+
|
|
1013
|
+
const xDomainPossiblyNice = $derived(xScale.domain());
|
|
1014
|
+
const yDomainPossiblyNice = $derived(yScale.domain());
|
|
1015
|
+
const zDomainPossiblyNice = $derived(zScale.domain());
|
|
1016
|
+
const rDomainPossiblyNice = $derived(rScale.domain());
|
|
1017
|
+
|
|
1018
|
+
const xRange = $derived(getRange(xScale));
|
|
1019
|
+
const yRange = $derived(getRange(yScale));
|
|
1020
|
+
const zRange = $derived(getRange(zScale));
|
|
1021
|
+
const rRange = $derived(getRange(rScale));
|
|
1022
|
+
|
|
1023
|
+
const aspectRatio = $derived(width / height);
|
|
1024
|
+
|
|
1025
|
+
const config: PreservedChartConfig<TData, XScale, YScale> = $derived({
|
|
1026
|
+
x: xProp,
|
|
1027
|
+
y: yProp,
|
|
1028
|
+
z: zProp,
|
|
1029
|
+
r: rProp,
|
|
1030
|
+
c: cProp,
|
|
1031
|
+
x1: x1Prop,
|
|
1032
|
+
y1: y1Prop,
|
|
1033
|
+
xDomain: _xDomain,
|
|
1034
|
+
yDomain: _yDomain,
|
|
1035
|
+
zDomain: zDomainProp,
|
|
1036
|
+
rDomain: rDomainProp,
|
|
1037
|
+
x1Domain: x1DomainProp,
|
|
1038
|
+
y1Domain: y1DomainProp,
|
|
1039
|
+
cDomain: cDomainProp,
|
|
1040
|
+
xRange: _xRangeProp,
|
|
1041
|
+
yRange: _yRangeProp,
|
|
1042
|
+
zRange: zRangeProp,
|
|
1043
|
+
rRange: rRangeProp,
|
|
1044
|
+
cRange: cRangeProp,
|
|
1045
|
+
x1Range: x1RangeProp,
|
|
1046
|
+
y1Range: y1RangeProp,
|
|
1047
|
+
});
|
|
325
1048
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
1049
|
+
let geoContext = $state<GeoContextValue>(null!);
|
|
1050
|
+
let transformContext = $state<TransformContextValue>(null!);
|
|
1051
|
+
let tooltipContext = $state<TooltipContextValue>(null!);
|
|
1052
|
+
let brushContext = $state<BrushContextValue>(null!);
|
|
1053
|
+
|
|
1054
|
+
const context: ChartContextValue<TData, XScale, YScale> = {
|
|
1055
|
+
get activeGetters() {
|
|
1056
|
+
return activeGetters;
|
|
1057
|
+
},
|
|
1058
|
+
get config() {
|
|
1059
|
+
return config;
|
|
1060
|
+
},
|
|
1061
|
+
get width() {
|
|
1062
|
+
return width;
|
|
1063
|
+
},
|
|
1064
|
+
get height() {
|
|
1065
|
+
return height;
|
|
1066
|
+
},
|
|
1067
|
+
get percentRange() {
|
|
1068
|
+
return percentRange;
|
|
1069
|
+
},
|
|
1070
|
+
get aspectRatio() {
|
|
1071
|
+
return aspectRatio;
|
|
1072
|
+
},
|
|
1073
|
+
get containerWidth() {
|
|
1074
|
+
return containerWidth;
|
|
1075
|
+
},
|
|
1076
|
+
get containerHeight() {
|
|
1077
|
+
return containerHeight;
|
|
1078
|
+
},
|
|
1079
|
+
get x() {
|
|
1080
|
+
return x;
|
|
1081
|
+
},
|
|
1082
|
+
get y() {
|
|
1083
|
+
return y;
|
|
1084
|
+
},
|
|
1085
|
+
get z() {
|
|
1086
|
+
return z;
|
|
1087
|
+
},
|
|
1088
|
+
get r() {
|
|
1089
|
+
return r;
|
|
1090
|
+
},
|
|
1091
|
+
get c() {
|
|
1092
|
+
return c;
|
|
1093
|
+
},
|
|
1094
|
+
get x1() {
|
|
1095
|
+
return x1;
|
|
1096
|
+
},
|
|
1097
|
+
get y1() {
|
|
1098
|
+
return y1;
|
|
1099
|
+
},
|
|
1100
|
+
get data() {
|
|
1101
|
+
return data;
|
|
1102
|
+
},
|
|
1103
|
+
get xNice() {
|
|
1104
|
+
return xNice;
|
|
1105
|
+
},
|
|
1106
|
+
get yNice() {
|
|
1107
|
+
return yNice;
|
|
1108
|
+
},
|
|
1109
|
+
get zNice() {
|
|
1110
|
+
return zNice;
|
|
1111
|
+
},
|
|
1112
|
+
get rNice() {
|
|
1113
|
+
return rNice;
|
|
1114
|
+
},
|
|
1115
|
+
get xDomainSort() {
|
|
1116
|
+
return xDomainSort;
|
|
1117
|
+
},
|
|
1118
|
+
get yDomainSort() {
|
|
1119
|
+
return yDomainSort;
|
|
1120
|
+
},
|
|
1121
|
+
get zDomainSort() {
|
|
1122
|
+
return zDomainSort;
|
|
1123
|
+
},
|
|
1124
|
+
get rDomainSort() {
|
|
1125
|
+
return rDomainSort;
|
|
1126
|
+
},
|
|
1127
|
+
get xReverse() {
|
|
1128
|
+
return xReverse;
|
|
1129
|
+
},
|
|
1130
|
+
get yReverse() {
|
|
1131
|
+
return yReverse;
|
|
1132
|
+
},
|
|
1133
|
+
get zReverse() {
|
|
1134
|
+
return zReverse;
|
|
1135
|
+
},
|
|
1136
|
+
get rReverse() {
|
|
1137
|
+
return rReverse;
|
|
1138
|
+
},
|
|
1139
|
+
get xPadding() {
|
|
1140
|
+
return xPadding;
|
|
1141
|
+
},
|
|
1142
|
+
get yPadding() {
|
|
1143
|
+
return yPadding;
|
|
1144
|
+
},
|
|
1145
|
+
get zPadding() {
|
|
1146
|
+
return zPadding;
|
|
1147
|
+
},
|
|
1148
|
+
get rPadding() {
|
|
1149
|
+
return rPadding;
|
|
1150
|
+
},
|
|
1151
|
+
get padding() {
|
|
1152
|
+
return padding;
|
|
1153
|
+
},
|
|
1154
|
+
get flatData() {
|
|
1155
|
+
return flatData;
|
|
1156
|
+
},
|
|
1157
|
+
get extents() {
|
|
1158
|
+
return extents;
|
|
1159
|
+
},
|
|
1160
|
+
get xDomain() {
|
|
1161
|
+
return xDomainPossiblyNice;
|
|
1162
|
+
},
|
|
1163
|
+
get yDomain() {
|
|
1164
|
+
return yDomainPossiblyNice;
|
|
1165
|
+
},
|
|
1166
|
+
get zDomain() {
|
|
1167
|
+
return zDomainPossiblyNice;
|
|
1168
|
+
},
|
|
1169
|
+
get rDomain() {
|
|
1170
|
+
return rDomainPossiblyNice;
|
|
1171
|
+
},
|
|
1172
|
+
get cDomain() {
|
|
1173
|
+
return cDomain;
|
|
1174
|
+
},
|
|
1175
|
+
get x1Domain() {
|
|
1176
|
+
return x1Domain;
|
|
1177
|
+
},
|
|
1178
|
+
get y1Domain() {
|
|
1179
|
+
return y1Domain;
|
|
1180
|
+
},
|
|
1181
|
+
get xRange() {
|
|
1182
|
+
return xRange;
|
|
1183
|
+
},
|
|
1184
|
+
get yRange() {
|
|
1185
|
+
return yRange;
|
|
1186
|
+
},
|
|
1187
|
+
get zRange() {
|
|
1188
|
+
return zRange;
|
|
1189
|
+
},
|
|
1190
|
+
get rRange() {
|
|
1191
|
+
return rRange;
|
|
1192
|
+
},
|
|
1193
|
+
get cRange() {
|
|
1194
|
+
return cRangeProp;
|
|
1195
|
+
},
|
|
1196
|
+
get x1Range() {
|
|
1197
|
+
return x1RangeProp;
|
|
1198
|
+
},
|
|
1199
|
+
get y1Range() {
|
|
1200
|
+
return y1RangeProp;
|
|
1201
|
+
},
|
|
1202
|
+
get meta() {
|
|
1203
|
+
return meta;
|
|
1204
|
+
},
|
|
1205
|
+
set meta(v: Record<string, any>) {
|
|
1206
|
+
meta = v;
|
|
1207
|
+
},
|
|
1208
|
+
get xScale() {
|
|
1209
|
+
return xScale;
|
|
1210
|
+
},
|
|
1211
|
+
get yScale() {
|
|
1212
|
+
return yScale;
|
|
1213
|
+
},
|
|
1214
|
+
get zScale() {
|
|
1215
|
+
return zScale;
|
|
1216
|
+
},
|
|
1217
|
+
get rScale() {
|
|
1218
|
+
return rScale;
|
|
1219
|
+
},
|
|
1220
|
+
get yGet() {
|
|
1221
|
+
return yGet;
|
|
1222
|
+
},
|
|
1223
|
+
get xGet() {
|
|
1224
|
+
return xGet;
|
|
1225
|
+
},
|
|
1226
|
+
get zGet() {
|
|
1227
|
+
return zGet;
|
|
1228
|
+
},
|
|
1229
|
+
get rGet() {
|
|
1230
|
+
return rGet;
|
|
1231
|
+
},
|
|
1232
|
+
get cGet() {
|
|
1233
|
+
return cGet;
|
|
1234
|
+
},
|
|
1235
|
+
get x1Get() {
|
|
1236
|
+
return x1Get;
|
|
1237
|
+
},
|
|
1238
|
+
get y1Get() {
|
|
1239
|
+
return y1Get;
|
|
1240
|
+
},
|
|
1241
|
+
get cScale() {
|
|
1242
|
+
return cScale;
|
|
1243
|
+
},
|
|
1244
|
+
get x1Scale() {
|
|
1245
|
+
return x1Scale;
|
|
1246
|
+
},
|
|
1247
|
+
get y1Scale() {
|
|
1248
|
+
return y1Scale;
|
|
1249
|
+
},
|
|
1250
|
+
get radial() {
|
|
1251
|
+
return radial;
|
|
1252
|
+
},
|
|
1253
|
+
get containerRef() {
|
|
1254
|
+
return ref;
|
|
1255
|
+
},
|
|
1256
|
+
get geo() {
|
|
1257
|
+
return geoContext;
|
|
1258
|
+
},
|
|
1259
|
+
get transform() {
|
|
1260
|
+
return transformContext;
|
|
1261
|
+
},
|
|
1262
|
+
get tooltip() {
|
|
1263
|
+
return tooltipContext;
|
|
1264
|
+
},
|
|
1265
|
+
get brush() {
|
|
1266
|
+
return brushContext;
|
|
1267
|
+
},
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
contextProp = context;
|
|
1271
|
+
|
|
1272
|
+
setChartContext(context);
|
|
1273
|
+
|
|
1274
|
+
$effect(() => {
|
|
1275
|
+
isMounted = true;
|
|
1276
|
+
});
|
|
330
1277
|
|
|
331
|
-
// Track when mounted since LayerCake initializes width/height with `100` until bound `clientWidth`/`clientWidth` can run
|
|
332
|
-
// Useful to key/remount TransformContext with correct `initialTranslate` / `initialScale` values
|
|
333
|
-
let isMounted = false;
|
|
334
1278
|
onMount(() => {
|
|
335
|
-
|
|
1279
|
+
if (box && debug === true && (ssr === true || typeof window !== 'undefined')) {
|
|
1280
|
+
logDebug({
|
|
1281
|
+
data,
|
|
1282
|
+
flatData: typeof flatData !== 'undefined' ? flatData : null,
|
|
1283
|
+
boundingBox: box,
|
|
1284
|
+
activeGetters,
|
|
1285
|
+
x: xProp,
|
|
1286
|
+
y: yProp,
|
|
1287
|
+
z: zProp,
|
|
1288
|
+
r: rProp,
|
|
1289
|
+
xScale,
|
|
1290
|
+
yScale,
|
|
1291
|
+
zScale,
|
|
1292
|
+
rScale,
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
336
1295
|
});
|
|
337
1296
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
1297
|
+
$effect(() => {
|
|
1298
|
+
if (!isMounted) return;
|
|
1299
|
+
onResize?.({
|
|
1300
|
+
width: context.width,
|
|
1301
|
+
height: context.height,
|
|
1302
|
+
containerWidth: context.containerWidth,
|
|
1303
|
+
containerHeight: context.containerHeight,
|
|
1304
|
+
});
|
|
1305
|
+
});
|
|
347
1306
|
|
|
348
|
-
|
|
349
|
-
<LayerCake
|
|
350
|
-
{data}
|
|
351
|
-
x={_x}
|
|
352
|
-
{xDomain}
|
|
353
|
-
xRange={xRange ?? (radial ? [0, 2 * Math.PI] : undefined)}
|
|
354
|
-
y={_y}
|
|
355
|
-
{yScale}
|
|
356
|
-
{yDomain}
|
|
357
|
-
yRange={_yRange}
|
|
358
|
-
{yReverse}
|
|
359
|
-
xDomainSort={false}
|
|
360
|
-
yDomainSort={false}
|
|
361
|
-
zDomainSort={false}
|
|
362
|
-
rDomainSort={false}
|
|
363
|
-
{...$$restProps}
|
|
364
|
-
let:aspectRatio
|
|
365
|
-
let:containerHeight
|
|
366
|
-
let:containerWidth
|
|
367
|
-
let:height
|
|
368
|
-
let:width
|
|
369
|
-
let:element
|
|
370
|
-
let:x
|
|
371
|
-
let:xScale
|
|
372
|
-
let:xGet
|
|
373
|
-
let:y
|
|
374
|
-
let:yScale
|
|
375
|
-
let:yGet
|
|
376
|
-
let:z
|
|
377
|
-
let:zScale
|
|
378
|
-
let:zGet
|
|
379
|
-
let:r
|
|
380
|
-
let:rScale
|
|
381
|
-
let:rGet
|
|
382
|
-
let:padding
|
|
383
|
-
>
|
|
384
|
-
<!-- Apply `fitGeojson` using TransformContext instead of GeoContext if `applyTransform` is used -->
|
|
385
|
-
{@const initialTransform =
|
|
1307
|
+
const initialTransform = $derived(
|
|
386
1308
|
geo?.applyTransform?.includes('translate') && geo?.fitGeojson && geo?.projection
|
|
387
1309
|
? geoFitObjectTransform(geo.projection(), [width, height], geo.fitGeojson)
|
|
388
|
-
: undefined
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
{
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
1310
|
+
: undefined
|
|
1311
|
+
);
|
|
1312
|
+
|
|
1313
|
+
const processTranslate = $derived.by(() => {
|
|
1314
|
+
if (!geo) return undefined;
|
|
1315
|
+
return (x: number, y: number, deltaX: number, deltaY: number) => {
|
|
1316
|
+
if (geo.applyTransform?.includes('rotate') && geoContext?.projection) {
|
|
1317
|
+
// When applying transform to rotate, invert `y` values and reduce sensitivity based on projection scale
|
|
1318
|
+
// see: https://observablehq.com/@benoldenburg/simple-globe and https://observablehq.com/@michael-keith/draggable-globe-in-d3
|
|
1319
|
+
const projectionScale = geoContext.projection.scale() ?? 0;
|
|
1320
|
+
const sensitivity = 75;
|
|
1321
|
+
return {
|
|
1322
|
+
x: x + deltaX * (sensitivity / projectionScale),
|
|
1323
|
+
y: y + deltaY * (sensitivity / projectionScale) * -1,
|
|
1324
|
+
};
|
|
1325
|
+
} else {
|
|
1326
|
+
// Apply default TransformContext.processTransform (passing `undefined` below appears to not work when checking for `geo?.applyTransform` exists)
|
|
1327
|
+
return { x: x + deltaX, y: y + deltaY };
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
const brushProps = $derived(typeof brush === 'object' ? brush : { disabled: !brush });
|
|
1333
|
+
const tooltipProps = $derived(typeof tooltip === 'object' ? tooltip : {});
|
|
1334
|
+
</script>
|
|
1335
|
+
|
|
1336
|
+
{#if ssr === true || typeof window !== 'undefined'}
|
|
1337
|
+
<div
|
|
1338
|
+
bind:this={ref}
|
|
1339
|
+
style:position
|
|
1340
|
+
style:top={position === 'absolute' ? '0' : null}
|
|
1341
|
+
style:right={position === 'absolute' ? '0' : null}
|
|
1342
|
+
style:bottom={position === 'absolute' ? '0' : null}
|
|
1343
|
+
style:left={position === 'absolute' ? '0' : null}
|
|
1344
|
+
style:pointer-events={pointerEvents === false ? 'none' : null}
|
|
1345
|
+
bind:clientWidth={containerWidth}
|
|
1346
|
+
bind:clientHeight={containerHeight}
|
|
1347
|
+
class={layerClass('root-container')}
|
|
418
1348
|
>
|
|
419
1349
|
{#key isMounted}
|
|
1350
|
+
<!-- svelte-ignore ownership_invalid_binding -->
|
|
420
1351
|
<TransformContext
|
|
421
|
-
bind:
|
|
1352
|
+
bind:transformContext
|
|
422
1353
|
mode={(transform?.mode ?? geo?.applyTransform?.length) ? 'manual' : 'none'}
|
|
423
1354
|
initialTranslate={initialTransform?.translate}
|
|
424
1355
|
initialScale={initialTransform?.scale}
|
|
425
|
-
processTranslate
|
|
426
|
-
? (x, y, deltaX, deltaY) => {
|
|
427
|
-
if (geo.applyTransform?.includes('rotate')) {
|
|
428
|
-
// When applying transform to rotate, invert `y` values and reduce sensitivity based on projection scale
|
|
429
|
-
// see: https://observablehq.com/@benoldenburg/simple-globe and https://observablehq.com/@michael-keith/draggable-globe-in-d3
|
|
430
|
-
// @ts-expect-error
|
|
431
|
-
const projectionScale = $geoProjection.scale();
|
|
432
|
-
const sensitivity = 75;
|
|
433
|
-
return {
|
|
434
|
-
x: x + deltaX * (sensitivity / projectionScale),
|
|
435
|
-
y: y + deltaY * (sensitivity / projectionScale) * -1,
|
|
436
|
-
};
|
|
437
|
-
} else {
|
|
438
|
-
// Apply default TransformContext.processTransform (passing `undefined` below appears to not work when checking for `geo?.applyTransform` exists)
|
|
439
|
-
return { x: x + deltaX, y: y + deltaY };
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
: undefined}
|
|
1356
|
+
{processTranslate}
|
|
443
1357
|
{...transform}
|
|
444
|
-
let:transform={_transform}
|
|
445
1358
|
{ondragstart}
|
|
446
|
-
{
|
|
1359
|
+
{onTransform}
|
|
447
1360
|
{ondragend}
|
|
448
1361
|
>
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
{height}
|
|
459
|
-
{width}
|
|
460
|
-
{element}
|
|
461
|
-
{projection}
|
|
462
|
-
transform={_transform}
|
|
463
|
-
{tooltip}
|
|
464
|
-
{brush}
|
|
465
|
-
{x}
|
|
466
|
-
{xScale}
|
|
467
|
-
{xGet}
|
|
468
|
-
{y}
|
|
469
|
-
{yScale}
|
|
470
|
-
{yGet}
|
|
471
|
-
{z}
|
|
472
|
-
{zScale}
|
|
473
|
-
{zGet}
|
|
474
|
-
{r}
|
|
475
|
-
{rScale}
|
|
476
|
-
{rGet}
|
|
477
|
-
{x1}
|
|
478
|
-
{x1Scale}
|
|
479
|
-
{x1Get}
|
|
480
|
-
{y1}
|
|
481
|
-
{y1Scale}
|
|
482
|
-
{y1Get}
|
|
483
|
-
{c}
|
|
484
|
-
{cScale}
|
|
485
|
-
{cGet}
|
|
486
|
-
{padding}
|
|
487
|
-
{data}
|
|
488
|
-
{flatData}
|
|
489
|
-
{config}
|
|
490
|
-
/>
|
|
1362
|
+
<!-- svelte-ignore ownership_invalid_binding -->
|
|
1363
|
+
<GeoContext {...geo} bind:geoContext>
|
|
1364
|
+
<!-- svelte-ignore ownership_invalid_binding -->
|
|
1365
|
+
<BrushContext {...brushProps} bind:brushContext>
|
|
1366
|
+
<!-- svelte-ignore ownership_invalid_binding -->
|
|
1367
|
+
<TooltipContext {...tooltipProps} bind:tooltipContext>
|
|
1368
|
+
{@render _children?.({
|
|
1369
|
+
context,
|
|
1370
|
+
})}
|
|
491
1371
|
</TooltipContext>
|
|
492
1372
|
</BrushContext>
|
|
493
1373
|
</GeoContext>
|
|
494
1374
|
</TransformContext>
|
|
495
1375
|
{/key}
|
|
496
|
-
</
|
|
497
|
-
|
|
1376
|
+
</div>
|
|
1377
|
+
{/if}
|
|
1378
|
+
|
|
1379
|
+
<style>
|
|
1380
|
+
.lc-root-container,
|
|
1381
|
+
.lc-root-container :global(*) {
|
|
1382
|
+
box-sizing: border-box;
|
|
1383
|
+
}
|
|
1384
|
+
.lc-root-container {
|
|
1385
|
+
width: 100%;
|
|
1386
|
+
height: 100%;
|
|
1387
|
+
}
|
|
1388
|
+
</style>
|