layerchart 0.54.0 → 0.55.0

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.
Files changed (105) hide show
  1. package/dist/components/Arc.svelte +170 -144
  2. package/dist/components/Area.svelte +96 -67
  3. package/dist/components/Area.svelte.d.ts +1 -0
  4. package/dist/components/Axis.svelte +205 -155
  5. package/dist/components/Bar.svelte +72 -45
  6. package/dist/components/Bars.svelte +45 -34
  7. package/dist/components/Blur.svelte +5 -3
  8. package/dist/components/Bounds.svelte +37 -21
  9. package/dist/components/Brush.svelte +269 -112
  10. package/dist/components/Brush.svelte.d.ts +7 -0
  11. package/dist/components/Calendar.svelte +51 -38
  12. package/dist/components/Chart.svelte +295 -74
  13. package/dist/components/Chart.svelte.d.ts +17 -17
  14. package/dist/components/ChartClipPath.svelte +8 -5
  15. package/dist/components/ChartContext.svelte +243 -93
  16. package/dist/components/ChartContext.svelte.d.ts +15 -23
  17. package/dist/components/Circle.svelte +25 -16
  18. package/dist/components/CircleClipPath.svelte +16 -10
  19. package/dist/components/ClipPath.svelte +11 -7
  20. package/dist/components/ColorRamp.svelte +12 -10
  21. package/dist/components/ForceSimulation.svelte +185 -116
  22. package/dist/components/Frame.svelte +10 -6
  23. package/dist/components/GeoCircle.svelte +15 -9
  24. package/dist/components/GeoContext.svelte +109 -62
  25. package/dist/components/GeoEdgeFade.svelte +20 -14
  26. package/dist/components/GeoPath.svelte +107 -69
  27. package/dist/components/GeoPoint.svelte +32 -18
  28. package/dist/components/GeoSpline.svelte +30 -22
  29. package/dist/components/GeoTile.svelte +40 -30
  30. package/dist/components/GeoVisible.svelte +10 -7
  31. package/dist/components/Graticule.svelte +14 -8
  32. package/dist/components/Grid.svelte +75 -48
  33. package/dist/components/Group.svelte +43 -31
  34. package/dist/components/Highlight.svelte +284 -243
  35. package/dist/components/HitCanvas.svelte +75 -42
  36. package/dist/components/Hull.svelte +40 -20
  37. package/dist/components/Labels.svelte +81 -70
  38. package/dist/components/Legend.svelte +105 -74
  39. package/dist/components/Legend.svelte.d.ts +1 -1
  40. package/dist/components/Line.svelte +65 -19
  41. package/dist/components/Line.svelte.d.ts +13 -1
  42. package/dist/components/LinearGradient.svelte +21 -15
  43. package/dist/components/Link.svelte +94 -22
  44. package/dist/components/Link.svelte.d.ts +17 -1
  45. package/dist/components/Marker.svelte +81 -0
  46. package/dist/components/Marker.svelte.d.ts +28 -0
  47. package/dist/components/MonthPath.svelte +23 -16
  48. package/dist/components/MotionPath.svelte +34 -25
  49. package/dist/components/Pack.svelte +21 -14
  50. package/dist/components/Partition.svelte +35 -20
  51. package/dist/components/Pattern.svelte +8 -6
  52. package/dist/components/Pie.svelte +76 -57
  53. package/dist/components/Point.svelte +11 -7
  54. package/dist/components/Points.svelte +178 -143
  55. package/dist/components/RadialGradient.svelte +25 -18
  56. package/dist/components/Rect.svelte +33 -19
  57. package/dist/components/RectClipPath.svelte +16 -11
  58. package/dist/components/Rule.svelte +50 -42
  59. package/dist/components/Sankey.svelte +55 -30
  60. package/dist/components/Spline.svelte +167 -96
  61. package/dist/components/Spline.svelte.d.ts +15 -0
  62. package/dist/components/Text.svelte +137 -104
  63. package/dist/components/Threshold.svelte +18 -7
  64. package/dist/components/TileImage.svelte +56 -50
  65. package/dist/components/TransformContext.svelte +235 -135
  66. package/dist/components/TransformControls.svelte +57 -29
  67. package/dist/components/TransformControls.svelte.d.ts +1 -1
  68. package/dist/components/Tree.svelte +33 -23
  69. package/dist/components/Treemap.svelte +69 -41
  70. package/dist/components/Voronoi.svelte +55 -28
  71. package/dist/components/charts/AreaChart.svelte +138 -87
  72. package/dist/components/charts/AreaChart.svelte.d.ts +4 -4
  73. package/dist/components/charts/BarChart.svelte +179 -114
  74. package/dist/components/charts/BarChart.svelte.d.ts +4 -4
  75. package/dist/components/charts/LineChart.svelte +97 -53
  76. package/dist/components/charts/LineChart.svelte.d.ts +4 -4
  77. package/dist/components/charts/PieChart.svelte +104 -54
  78. package/dist/components/charts/PieChart.svelte.d.ts +3 -3
  79. package/dist/components/charts/ScatterChart.svelte +83 -48
  80. package/dist/components/charts/ScatterChart.svelte.d.ts +4 -4
  81. package/dist/components/layout/Canvas.svelte +63 -43
  82. package/dist/components/layout/Html.svelte +28 -18
  83. package/dist/components/layout/Svg.svelte +47 -32
  84. package/dist/components/tooltip/Tooltip.svelte +137 -91
  85. package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
  86. package/dist/components/tooltip/TooltipContext.svelte +315 -249
  87. package/dist/components/tooltip/TooltipHeader.svelte +9 -3
  88. package/dist/components/tooltip/TooltipItem.svelte +17 -9
  89. package/dist/components/tooltip/TooltipList.svelte +2 -1
  90. package/dist/components/tooltip/TooltipSeparator.svelte +3 -2
  91. package/dist/docs/Blockquote.svelte +4 -3
  92. package/dist/docs/Code.svelte +15 -8
  93. package/dist/docs/CurveMenuField.svelte +17 -12
  94. package/dist/docs/GeoDebug.svelte +13 -9
  95. package/dist/docs/Header1.svelte +2 -1
  96. package/dist/docs/Json.svelte +6 -4
  97. package/dist/docs/Layout.svelte +6 -6
  98. package/dist/docs/PathDataMenuField.svelte +52 -44
  99. package/dist/docs/Preview.svelte +39 -33
  100. package/dist/docs/TilesetField.svelte +80 -62
  101. package/dist/docs/TransformDebug.svelte +8 -5
  102. package/dist/docs/ViewSourceButton.svelte +13 -9
  103. package/dist/stores/motionStore.d.ts +1 -1
  104. package/dist/utils/scales.d.ts +3 -3
  105. package/package.json +29 -30
@@ -1,83 +1,304 @@
1
- <script generics="TData">import { onMount } from 'svelte';
2
- import { LayerCake } from 'layercake';
3
- import { max, min } from 'd3-array';
4
- import ChartContext from './ChartContext.svelte';
5
- import GeoContext from './GeoContext.svelte';
6
- import TooltipContext from './tooltip/TooltipContext.svelte';
7
- import TransformContext from './TransformContext.svelte';
8
- import { accessor } from '../utils/common.js';
9
- import { isScaleBand } from '../utils/scales.js';
10
- import { geoFitObjectTransform } from '../utils/geo.js';
11
- export let data = [];
12
- export let x = undefined;
13
- export let xRange = undefined;
14
- export let y = undefined;
15
- export let yScale = undefined;
16
- export let yRange = undefined;
17
- export let x1 = undefined;
18
- export let x1Scale = undefined;
19
- export let x1Domain = undefined;
20
- export let x1Range = undefined;
21
- export let y1 = undefined;
22
- export let y1Scale = undefined;
23
- export let y1Domain = undefined;
24
- export let y1Range = undefined;
25
- export let c = undefined;
26
- export let cScale = undefined;
27
- export let cDomain = undefined;
28
- export let cRange = undefined;
29
- /**
30
- * x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values
31
- */
32
- export let xBaseline = null;
33
- let xDomain = undefined;
34
- $: if (xBaseline != null && Array.isArray(data)) {
1
+ <script lang="ts" generics="TData">
2
+ import { onMount, type ComponentProps } from 'svelte';
3
+ import { LayerCake } from 'layercake';
4
+ import type { HierarchyNode } from 'd3-hierarchy';
5
+ import type { SankeyGraph } from 'd3-sankey';
6
+ import { max, min } from 'd3-array';
7
+
8
+ import ChartContext from './ChartContext.svelte';
9
+ import GeoContext from './GeoContext.svelte';
10
+ import TooltipContext from './tooltip/TooltipContext.svelte';
11
+ import TransformContext from './TransformContext.svelte';
12
+
13
+ import { accessor, type Accessor } from '../utils/common.js';
14
+ import { isScaleBand, type AnyScale, type DomainType } from '../utils/scales.js';
15
+ import { geoFitObjectTransform } from '../utils/geo.js';
16
+
17
+ type LayerCakeProps = ComponentProps<LayerCake>;
18
+
19
+ interface $$Props {
20
+ /** Whether this chart should be rendered server side. @default false */
21
+ ssr?: boolean;
22
+
23
+ /** Whether to allow pointer events via CSS. Set this to `false` to set `pointer-events: none;` on all components, disabling all mouse interaction. @default true */
24
+ pointerEvents?: boolean;
25
+
26
+ /** Determine the positioning of the wrapper div. Set this to `'absolute'` when you want to stack cakes. @default 'relative' */
27
+ position?: string;
28
+
29
+ /** If `true`, set all scale ranges to `[0, 100]`. Ranges reversed via `xReverse`, `yReverse`, `zReverse` or `rReverse` props will continue to be reversed as usual. @default false */
30
+ percentRange?: boolean;
31
+
32
+ /** Override the automated width. */
33
+ width?: number;
34
+ /** Override the automated height. */
35
+ height?: number;
36
+
37
+ /** The bound container width. */
38
+ containerWidth?: number;
39
+ /**The bound container height. */
40
+ containerHeight?: number;
41
+
42
+ /** The .layercake-container `<div>` tag. Useful for bindings. */
43
+ element?: HTMLDivElement;
44
+
45
+ /** If `data` is not a flat array of objects and you want to use any of the scales, set a flat version of the data via the `flatData` prop. */
46
+ data?: typeof data;
47
+
48
+ /** A flat version of data. */
49
+ flatData?: any[];
50
+
51
+ /** The x accessor. The key in each row of data that corresponds to the x-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
52
+ x?: Accessor<TData>;
53
+ /** The y accessor. The key in each row of data that corresponds to the y-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
54
+ y?: Accessor<TData>;
55
+ /** The z accessor. The key in each row of data that corresponds to the z-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
56
+ z?: Accessor<TData>;
57
+ /** The r accessor. The key in each row of data that corresponds to the r-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
58
+ r?: Accessor<TData>;
59
+ /** The x1 accessor. The key in each row of data that corresponds to the x1-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
60
+ x1?: Accessor<TData>;
61
+ /** The y1 accessor. The key in each row of data that corresponds to the y1-field. This can be a string, an accessor function, a number or an array of any combination of those types. This property gets converted to a function when you access it through the context. */
62
+ y1?: Accessor<TData>;
63
+ /** The c (color) accessor. The key in each row of data that corresponds to the color. This can be a string or an accessor function. This property gets converted to a function when you access it through the context. */
64
+ c?: Accessor<TData>;
65
+
66
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
67
+ xDomain?: DomainType;
68
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
69
+ yDomain?: DomainType;
70
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
71
+ zDomain?: DomainType;
72
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
73
+ rDomain?: DomainType;
74
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
75
+ x1Domain?: DomainType;
76
+ /** Set a min or max. For linear scales, if you want to inherit the value from the data's extent, set that value to `null`. This value can also be an array because sometimes your scales are [piecewise](https://github.com/d3/d3-scale#continuous_domain) or are a list of discrete values such as in [ordinal scales](https://github.com/d3/d3-scale#ordinal-scales), useful for color series. Set it to a function that receives the computed domain and lets you return a modified domain, useful for sorting values. */
77
+ y1Domain?: DomainType;
78
+ /** Set the list of color values. */
79
+ cDomain?: DomainType;
80
+
81
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the x domain. @default false */
82
+ xNice?: boolean | number;
83
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the y domain. @default false */
84
+ yNice?: boolean | number;
85
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the z domain. @default false */
86
+ zNice?: boolean | number;
87
+ /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the r domain. @default false */
88
+ rNice?: boolean | number;
89
+
90
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
91
+ xPadding?: [number, number];
92
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
93
+ yPadding?: [number, number];
94
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
95
+ zPadding?: [number, number];
96
+ /** Assign a pixel value to add to the min or max of the scale. This will increase the scales domain by the scale unit equivalent of the provided pixels. */
97
+ rPadding?: [number, number];
98
+
99
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
100
+ xScale?: AnyScale;
101
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
102
+ yScale?: AnyScale;
103
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
104
+ zScale?: AnyScale;
105
+ /** The D3 scale that should be used for the x-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleSqrt */
106
+ rScale?: AnyScale;
107
+ /** The D3 scale that should be used for the x1-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
108
+ x1Scale?: AnyScale;
109
+ /** The D3 scale that should be used for the y1-dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleLinear */
110
+ y1Scale?: AnyScale;
111
+ /** The D3 scale that should be used for the color dimension. Pass in an instantiated D3 scale if you want to override the default or you want to extra options. @default scaleOrdinal */
112
+ cScale?: AnyScale;
113
+
114
+ /** Override the default x range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `xReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
115
+ xRange?:
116
+ | number[]
117
+ | string[]
118
+ | ((args: { width: number; height: number }) => number[] | string[]);
119
+ /** Override the default y range of `[0, height]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `yReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
120
+ yRange?:
121
+ | number[]
122
+ | string[]
123
+ | ((args: { width: number; height: number }) => number[] | string[]);
124
+ /** Override the default z range of `[0, width]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `zReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
125
+ zRange?:
126
+ | number[]
127
+ | string[]
128
+ | ((args: { width: number; height: number }) => number[] | string[]);
129
+ /** Override the default r range of `[1, 25]` by setting an array or function with argument `({ width, height})` that returns an array. Setting this prop overrides `rReverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
130
+ rRange?:
131
+ | number[]
132
+ | string[]
133
+ | ((args: { width: number; height: number }) => number[] | string[]);
134
+ /** Set the x1 range by setting an array or function with argument `({ xScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
135
+ x1Range?:
136
+ | number[]
137
+ | string[]
138
+ | ((args: { xScale: AnyScale; width: number; height: number }) => number[] | string[]);
139
+ /** Set the y1 range by setting an array or function with argument `({ yScale, width, height})` that returns an array. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
140
+ y1Range?:
141
+ | number[]
142
+ | string[]
143
+ | ((args: { yScale: AnyScale; width: number; height: number }) => number[] | string[]);
144
+ /** Override the default y1 range of `[0, width]` by setting an array or function with argument `({ yScale, width, height})` that returns an array. Setting this prop overrides `x1Reverse`. This can also be a list of numbers or strings for scales with discrete ranges like [scaleThreshold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
145
+ cRange?: string[] | readonly string[];
146
+
147
+ /** Reverse the default x range. By default this is `false` and the range is `[0, width]`. Ignored if you set the xRange prop. @default false */
148
+ xReverse?: boolean;
149
+ /** Reverse the default y range. By default this is `true` and the range is `[height, 0]` unless using an ordinal scale with a `.bandwidth` method for `yScale`. Ignored if you set the `yRange` prop. @default true */
150
+ yReverse?: boolean;
151
+ /** Reverse the default z range. By default this is `false` and the range is `[0, width]`. Ignored if you set the zRange prop. @default false */
152
+ zReverse?: boolean;
153
+ /** Reverse the default r range. By default this is `false` and the range is `[1, 25]`. Ignored if you set the rRange prop. @default false */
154
+ rReverse?: boolean;
155
+
156
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
157
+ xDomainSort?: boolean;
158
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
159
+ yDomainSort?: boolean;
160
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
161
+ zDomainSort?: boolean;
162
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
163
+ rDomainSort?: boolean;
164
+
165
+ /** The amount of padding to put around your chart. It operates like CSS box-sizing: border-box; where values are subtracted from the parent container's width and height, the same as a [D3 margin convention](https://bl.ocks.org/mbostock/3019563). */
166
+ padding?: { top?: Number; right?: Number; bottom?: Number; left?: Number };
167
+
168
+ /** Manually set the extents of the x, y or r scale as a two-dimensional array of the min and max you want. Setting values here will skip any dynamic extent calculation of the data for that dimension. */
169
+ extents?: {
170
+ x?: [min: Number, max: Number];
171
+ y?: [min: Number, max: Number];
172
+ r?: [min: Number, max: Number];
173
+ z?: [min: Number, max: Number];
174
+ };
175
+
176
+ /** Any extra configuration values you want available on the LayerCake context. This could be useful for color lookups or additional constants. */
177
+ custom?: Record<string, any>;
178
+
179
+ /** Enable debug printing to the console. Useful to inspect your scales and dimensions. */
180
+ debug?: boolean;
181
+
182
+ /** Show warnings in the console. */
183
+ verbose?: boolean;
184
+
185
+ /** x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values */
186
+ xBaseline?: typeof xBaseline;
187
+
188
+ /** y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values */
189
+ yBaseline?: typeof xBaseline;
190
+
191
+ /* Props passed to ChartContext */
192
+ /** 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 */
193
+ radial?: typeof radial;
194
+
195
+ /** Props passed to GeoContext */
196
+ geo?: typeof geo;
197
+
198
+ /** Props passed to TooltipContext */
199
+ tooltip?: typeof tooltip;
200
+
201
+ /** Props passed to TransformContext */
202
+ transform?: typeof transform;
203
+
204
+ /** Expose to support `bind:transformContext` for imperative control (`transformContext.translate(...)`) */
205
+ transformContext?: typeof transformContext;
206
+
207
+ /** Exposed via bind: to support `bind:geoProjection` for external access */
208
+ geoProjection?: typeof geoProjection;
209
+
210
+ /** Exposed via bind: to support `bind:tooltipContext` for external access (ex. `tooltipContext.data) */
211
+ tooltipContext?: typeof tooltipContext;
212
+ }
213
+
214
+ export let data: TData[] | HierarchyNode<TData> | SankeyGraph<any, any> = [];
215
+
216
+ export let x: Accessor<TData> = undefined;
217
+ export let xRange: $$Props['xRange'] = undefined;
218
+
219
+ export let y: Accessor<TData> = undefined;
220
+ export let yScale: AnyScale | undefined = undefined;
221
+ export let yRange: $$Props['yRange'] = undefined;
222
+
223
+ export let x1: $$Props['x1'] = undefined;
224
+ export let x1Scale: $$Props['x1Scale'] = undefined;
225
+ export let x1Domain: $$Props['x1Domain'] = undefined;
226
+ export let x1Range: $$Props['x1Range'] = undefined;
227
+
228
+ export let y1: $$Props['y1'] = undefined;
229
+ export let y1Scale: $$Props['y1Scale'] = undefined;
230
+ export let y1Domain: $$Props['y1Domain'] = undefined;
231
+ export let y1Range: $$Props['y1Range'] = undefined;
232
+
233
+ export let c: $$Props['c'] = undefined;
234
+ export let cScale: $$Props['cScale'] = undefined;
235
+ export let cDomain: $$Props['cDomain'] = undefined;
236
+ export let cRange: $$Props['cRange'] = undefined;
237
+
238
+ /**
239
+ * x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values
240
+ */
241
+ export let xBaseline: number | null = null;
242
+
243
+ let xDomain: [number, number] | undefined = undefined;
244
+ $: if (xBaseline != null && Array.isArray(data)) {
35
245
  const xValues = data.flatMap(accessor(x));
36
246
  xDomain = [min([xBaseline, ...xValues]), max([xBaseline, ...xValues])];
37
- }
38
- /**
39
- * y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values
40
- */
41
- export let yBaseline = null;
42
- let yDomain = undefined;
43
- $: if (yBaseline != null && Array.isArray(data)) {
247
+ }
248
+
249
+ /**
250
+ * y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values
251
+ */
252
+ export let yBaseline: number | null = null;
253
+
254
+ let yDomain: [number, number] | undefined = undefined;
255
+ $: if (yBaseline != null && Array.isArray(data)) {
44
256
  const yValues = data.flatMap(accessor(y));
45
257
  yDomain = [min([yBaseline, ...yValues]), max([yBaseline, ...yValues])];
46
- }
47
- /**
48
- * Reverse the default y range ([0, height] becomes [height, 0]). By default this is `true` unless using scaleBand y scale.
49
- * see: https://layercake.graphics/guide#yreverse
50
- * see: https://github.com/mhkeller/layercake/issues/83
51
- */
52
- $: yReverse = yScale ? !isScaleBand(yScale) : true;
53
- /** 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 */
54
- export let radial = false;
55
- /** Props passed to GeoContext */
56
- export let geo = undefined;
57
- /** Props passed to TooltipContext */
58
- export let tooltip = undefined;
59
- /** Props passed to TransformContext */
60
- export let transform = undefined;
61
- // @ts-expect-error will only be undefined until bind:transformContext runs
62
- export let transformContext = undefined;
63
- /** Expose bound geo projection context */
64
- export let geoProjection = undefined;
65
- /** Expose bound tooltip context */
66
- export let tooltipContext = undefined;
67
- // Track when mounted since LayerCake initializes width/height with `100` until bound `clientWidth`/`clientWidth` can run
68
- // Useful to key/remount TransformContext with correct `initialTranslate` / `initialScale` values
69
- let isMounted = false;
70
- onMount(() => {
258
+ }
259
+
260
+ /**
261
+ * Reverse the default y range ([0, height] becomes [height, 0]). By default this is `true` unless using scaleBand y scale.
262
+ * see: https://layercake.graphics/guide#yreverse
263
+ * see: https://github.com/mhkeller/layercake/issues/83
264
+ */
265
+ $: yReverse = yScale ? !isScaleBand(yScale) : true;
266
+
267
+ /** 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 */
268
+ export let radial = false;
269
+
270
+ /** Props passed to GeoContext */
271
+ export let geo: Partial<ComponentProps<GeoContext>> | undefined = undefined;
272
+
273
+ /** Props passed to TooltipContext */
274
+ export let tooltip: Partial<ComponentProps<TooltipContext>> | boolean | undefined = undefined;
275
+
276
+ /** Props passed to TransformContext */
277
+ export let transform: Partial<ComponentProps<TransformContext>> | undefined = undefined;
278
+ // @ts-expect-error will only be undefined until bind:transformContext runs
279
+ export let transformContext: TransformContext = undefined;
280
+
281
+ /** Expose bound geo projection context */
282
+ export let geoProjection: ComponentProps<GeoContext>['geo'] = undefined;
283
+
284
+ /** Expose bound tooltip context */
285
+ export let tooltipContext: ComponentProps<TooltipContext>['tooltip'] = undefined;
286
+
287
+ // Track when mounted since LayerCake initializes width/height with `100` until bound `clientWidth`/`clientWidth` can run
288
+ // Useful to key/remount TransformContext with correct `initialTranslate` / `initialScale` values
289
+ let isMounted = false;
290
+ onMount(() => {
71
291
  isMounted = true;
72
- });
73
- // TODO: Hacks until LayerCake has better typings (`Accessor<TData>`)
74
- $: _x = x;
75
- $: _y = y;
76
- $: _yRange =
292
+ });
293
+
294
+ // TODO: Hacks until LayerCake has better typings (`Accessor<TData>`)
295
+ $: _x = x as LayerCakeProps['x'];
296
+ $: _y = y as LayerCakeProps['y'];
297
+ $: _yRange =
77
298
  yRange ??
78
- (radial
79
- ? ({ height }) => [0, height / 2]
80
- : undefined);
299
+ ((radial
300
+ ? ({ height }: { height: number }) => [0, height / 2]
301
+ : undefined) as LayerCakeProps['yRange']);
81
302
  </script>
82
303
 
83
304
  <!-- Remove domain sorting by default: https://github.com/mhkeller/layercake/issues/147 -->
@@ -261,7 +261,7 @@ declare class __sveltets_Render<TData> {
261
261
  }> | undefined;
262
262
  };
263
263
  events(): {
264
- resize: any;
264
+ resize: CustomEvent<any>;
265
265
  transform: CustomEvent<{
266
266
  scale: number;
267
267
  translate: {
@@ -281,7 +281,7 @@ declare class __sveltets_Render<TData> {
281
281
  containerWidth: number;
282
282
  height: number;
283
283
  width: number;
284
- element: Element;
284
+ element: Element | undefined;
285
285
  projection: import("d3-geo").GeoProjection;
286
286
  transform: {
287
287
  scale: number;
@@ -322,28 +322,28 @@ declare class __sveltets_Render<TData> {
322
322
  r: Function;
323
323
  rScale: any;
324
324
  rGet: any;
325
- x1: any;
326
- x1Scale: any;
327
- x1Get: any;
328
- y1: any;
329
- y1Scale: any;
330
- y1Get: any;
331
- c: any;
332
- cScale: any;
333
- cGet: any;
325
+ x1: (d: any) => any;
326
+ x1Scale: AnyScale<any, any, any, any> | null;
327
+ x1Get: Function;
328
+ y1: (d: any) => any;
329
+ y1Scale: AnyScale<any, any, any, any> | null;
330
+ y1Get: Function;
331
+ c: (d: any) => any;
332
+ cScale: AnyScale<any, any, any, any> | null;
333
+ cGet: Function;
334
334
  padding: {
335
335
  top: number;
336
336
  right: number;
337
337
  bottom: number;
338
338
  left: number;
339
339
  } & {
340
- top?: number | undefined;
341
- right?: number | undefined;
342
- bottom?: number | undefined;
343
- left?: number | undefined;
340
+ top?: number;
341
+ right?: number;
342
+ bottom?: number;
343
+ left?: number;
344
344
  };
345
- data: any;
346
- flatData: any;
345
+ data: unknown[] | SankeyGraph<any, any> | HierarchyNode<unknown>;
346
+ flatData: import("svelte/store").Readable<unknown[] | SankeyGraph<any, any> | HierarchyNode<unknown>>;
347
347
  config: any;
348
348
  };
349
349
  };
@@ -1,8 +1,11 @@
1
- <script>import { chartContext } from './ChartContext.svelte';
2
- import RectClipPath from './RectClipPath.svelte';
3
- const { width, height, padding } = chartContext();
4
- /** Include padding area (ex. axis) */
5
- export let full = false;
1
+ <script lang="ts">
2
+ import { chartContext } from './ChartContext.svelte';
3
+ import RectClipPath from './RectClipPath.svelte';
4
+
5
+ const { width, height, padding } = chartContext();
6
+
7
+ /** Include padding area (ex. axis) */
8
+ export let full = false;
6
9
  </script>
7
10
 
8
11
  <RectClipPath