layerchart 0.44.0 → 0.51.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 (116) hide show
  1. package/dist/components/Arc.svelte +18 -1
  2. package/dist/components/Arc.svelte.d.ts +3 -0
  3. package/dist/components/Area.svelte +49 -18
  4. package/dist/components/Area.svelte.d.ts +0 -1
  5. package/dist/components/Axis.svelte +2 -1
  6. package/dist/components/Axis.svelte.d.ts +2 -1
  7. package/dist/components/Bar.svelte +18 -8
  8. package/dist/components/Bar.svelte.d.ts +6 -3
  9. package/dist/components/Bars.svelte +18 -11
  10. package/dist/components/Bars.svelte.d.ts +3 -3
  11. package/dist/components/Blur.svelte +1 -1
  12. package/dist/components/Brush.svelte +2 -1
  13. package/dist/components/Calendar.svelte +2 -2
  14. package/dist/components/Calendar.svelte.d.ts +1 -1
  15. package/dist/components/Chart.svelte +85 -25
  16. package/dist/components/Chart.svelte.d.ts +77 -37
  17. package/dist/components/ChartContext.svelte +124 -6
  18. package/dist/components/ChartContext.svelte.d.ts +50 -2
  19. package/dist/components/Circle.svelte +1 -1
  20. package/dist/components/CircleClipPath.svelte +1 -1
  21. package/dist/components/ClipPath.svelte +1 -1
  22. package/dist/components/GeoPath.svelte +1 -1
  23. package/dist/components/GeoPath.svelte.d.ts +1 -1
  24. package/dist/components/Highlight.svelte +45 -19
  25. package/dist/components/Highlight.svelte.d.ts +2 -3
  26. package/dist/components/HitCanvas.svelte +1 -1
  27. package/dist/components/Hull.svelte +1 -1
  28. package/dist/components/Labels.svelte +39 -73
  29. package/dist/components/Labels.svelte.d.ts +2 -5
  30. package/dist/components/Legend.svelte +5 -5
  31. package/dist/components/Legend.svelte.d.ts +2 -2
  32. package/dist/components/Line.svelte +1 -1
  33. package/dist/components/LinearGradient.svelte +1 -1
  34. package/dist/components/MotionPath.svelte +1 -1
  35. package/dist/components/Pie.svelte +18 -41
  36. package/dist/components/Pie.svelte.d.ts +2 -3
  37. package/dist/components/Points.svelte +110 -56
  38. package/dist/components/Points.svelte.d.ts +20 -2
  39. package/dist/components/RadialGradient.svelte +1 -1
  40. package/dist/components/Rect.svelte +2 -1
  41. package/dist/components/Rect.svelte.d.ts +1 -0
  42. package/dist/components/RectClipPath.svelte +1 -1
  43. package/dist/components/Rule.svelte +1 -1
  44. package/dist/components/Spline.svelte +26 -18
  45. package/dist/components/Spline.svelte.d.ts +1 -1
  46. package/dist/components/Text.svelte +1 -1
  47. package/dist/components/Threshold.svelte +19 -81
  48. package/dist/components/Threshold.svelte.d.ts +13 -20
  49. package/dist/components/TransformContext.svelte.d.ts +2 -2
  50. package/dist/components/TransformControls.svelte +2 -1
  51. package/dist/components/TransformControls.svelte.d.ts +2 -2
  52. package/dist/components/Voronoi.svelte +15 -5
  53. package/dist/components/Voronoi.svelte.d.ts +6 -1
  54. package/dist/components/charts/AreaChart.svelte +182 -0
  55. package/dist/components/charts/AreaChart.svelte.d.ts +261 -0
  56. package/dist/components/charts/BarChart.svelte +207 -0
  57. package/dist/components/charts/BarChart.svelte.d.ts +241 -0
  58. package/dist/components/charts/LineChart.svelte +138 -0
  59. package/dist/components/charts/LineChart.svelte.d.ts +260 -0
  60. package/dist/components/charts/PieChart.svelte +146 -0
  61. package/dist/components/charts/PieChart.svelte.d.ts +220 -0
  62. package/dist/components/charts/ScatterChart.svelte +133 -0
  63. package/dist/components/charts/ScatterChart.svelte.d.ts +236 -0
  64. package/dist/components/charts/index.d.ts +5 -0
  65. package/dist/components/charts/index.js +5 -0
  66. package/dist/components/index.d.ts +2 -6
  67. package/dist/components/index.js +3 -6
  68. package/dist/components/layout/Canvas.svelte +1 -1
  69. package/dist/components/layout/Html.svelte +1 -1
  70. package/dist/components/layout/Svg.svelte +14 -4
  71. package/dist/components/layout/Svg.svelte.d.ts +1 -0
  72. package/dist/components/{Tooltip.svelte → tooltip/Tooltip.svelte} +5 -28
  73. package/dist/components/{Tooltip.svelte.d.ts → tooltip/Tooltip.svelte.d.ts} +1 -5
  74. package/dist/components/{TooltipContext.svelte → tooltip/TooltipContext.svelte} +20 -12
  75. package/dist/components/tooltip/TooltipHeader.svelte +21 -0
  76. package/dist/components/tooltip/TooltipHeader.svelte.d.ts +23 -0
  77. package/dist/components/tooltip/TooltipItem.svelte +37 -0
  78. package/dist/components/{TooltipItem.svelte.d.ts → tooltip/TooltipItem.svelte.d.ts} +4 -1
  79. package/dist/components/tooltip/TooltipList.svelte +12 -0
  80. package/dist/components/tooltip/TooltipList.svelte.d.ts +18 -0
  81. package/dist/components/tooltip/TooltipSeparator.svelte +4 -0
  82. package/dist/components/tooltip/index.d.ts +6 -0
  83. package/dist/components/tooltip/index.js +6 -0
  84. package/dist/docs/Blockquote.svelte +2 -1
  85. package/dist/docs/Code.svelte +2 -1
  86. package/dist/docs/CurveMenuField.svelte +2 -1
  87. package/dist/docs/GeoDebug.svelte +3 -1
  88. package/dist/docs/Json.svelte +1 -1
  89. package/dist/docs/Preview.svelte +2 -1
  90. package/dist/docs/TransformDebug.svelte +2 -1
  91. package/dist/utils/common.d.ts +1 -1
  92. package/dist/utils/common.js +2 -2
  93. package/dist/utils/common.test.d.ts +8 -0
  94. package/dist/utils/common.test.js +38 -0
  95. package/dist/utils/event.js +1 -1
  96. package/dist/utils/genData.d.ts +2 -2
  97. package/dist/utils/genData.js +20 -20
  98. package/dist/utils/math.d.ts +2 -2
  99. package/dist/utils/math.js +8 -2
  100. package/dist/utils/rect.d.ts +4 -10
  101. package/dist/utils/rect.js +15 -19
  102. package/dist/utils/scales.d.ts +8 -2
  103. package/dist/utils/scales.js +15 -1
  104. package/dist/utils/stack.d.ts +2 -2
  105. package/dist/utils/stack.js +37 -20
  106. package/dist/utils/stack.test.d.ts +6 -0
  107. package/dist/utils/stack.test.js +136 -0
  108. package/dist/utils/string.js +41 -0
  109. package/dist/utils/ticks.js +1 -2
  110. package/package.json +9 -3
  111. package/dist/components/AreaStack.svelte +0 -47
  112. package/dist/components/AreaStack.svelte.d.ts +0 -28
  113. package/dist/components/TooltipItem.svelte +0 -26
  114. package/dist/components/TooltipSeparator.svelte +0 -4
  115. /package/dist/components/{TooltipContext.svelte.d.ts → tooltip/TooltipContext.svelte.d.ts} +0 -0
  116. /package/dist/components/{TooltipSeparator.svelte.d.ts → tooltip/TooltipSeparator.svelte.d.ts} +0 -0
@@ -1,17 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { WebGL as _WebGL } from 'layercake';
3
- import _Canvas from './layout/Canvas.svelte';
4
- import _Html from './layout/Html.svelte';
5
- import _Svg from './layout/Svg.svelte';
6
- export declare const Canvas: typeof _Canvas;
7
- export declare const Html: typeof _Html;
8
- export declare const Svg: typeof _Svg;
9
- export declare const WebGL: typeof _WebGL;
10
- import { type Accessor } from '../utils/common.js';
11
2
  import type { HierarchyNode } from 'd3-hierarchy';
12
3
  import type { SankeyGraph } from 'd3-sankey';
13
- import { type AnyScale } from '../utils/scales.js';
14
4
  import TransformContext from './TransformContext.svelte';
5
+ import { type Accessor } from '../utils/common.js';
6
+ import { type AnyScale, type DomainType } from '../utils/scales.js';
15
7
  declare class __sveltets_Render<TData> {
16
8
  props(): {
17
9
  /** Whether this chart should be rendered server side. @default false */
@@ -33,7 +25,7 @@ declare class __sveltets_Render<TData> {
33
25
  /** The .layercake-container `<div>` tag. Useful for bindings. */
34
26
  element?: HTMLDivElement;
35
27
  /** 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. */
36
- data?: SankeyGraph<any, any> | TData[] | HierarchyNode<TData> | undefined;
28
+ data?: SankeyGraph<any, any> | HierarchyNode<TData> | TData[] | undefined;
37
29
  /** A flat version of data. */
38
30
  flatData?: any[];
39
31
  /** 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. */
@@ -44,14 +36,26 @@ declare class __sveltets_Render<TData> {
44
36
  z?: Accessor<TData>;
45
37
  /** 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. */
46
38
  r?: Accessor<TData>;
39
+ /** 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. */
40
+ x1?: Accessor<TData>;
41
+ /** 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. */
42
+ y1?: Accessor<TData>;
43
+ /** 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. */
44
+ c?: Accessor<TData>;
47
45
  /** 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. */
48
- xDomain?: Function | (string | number | Date | null | undefined)[] | null;
46
+ xDomain?: DomainType;
49
47
  /** 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. */
50
- yDomain?: Function | (string | number | Date | null | undefined)[] | null;
48
+ yDomain?: DomainType;
49
+ /** 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. */
50
+ zDomain?: DomainType;
51
51
  /** 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. */
52
- zDomain?: Function | (string | number | Date | null | undefined)[] | null;
52
+ rDomain?: DomainType;
53
53
  /** 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. */
54
- rDomain?: Function | (string | number | Date | null | undefined)[] | null;
54
+ x1Domain?: DomainType;
55
+ /** 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. */
56
+ y1Domain?: DomainType;
57
+ /** Set the list of color values. */
58
+ cDomain?: DomainType;
55
59
  /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the x domain. @default false */
56
60
  xNice?: boolean | number;
57
61
  /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the y domain. @default false */
@@ -60,23 +64,29 @@ declare class __sveltets_Render<TData> {
60
64
  zNice?: boolean | number;
61
65
  /** Applies D3's [scale.nice()](https://github.com/d3/d3-scale#continuous_nice) to the r domain. @default false */
62
66
  rNice?: boolean | number;
63
- /** @type 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. */
67
+ /** 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. */
64
68
  xPadding?: [number, number];
65
- /** @type 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. */
69
+ /** 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. */
66
70
  yPadding?: [number, number];
67
- /** @type 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. */
71
+ /** 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. */
68
72
  zPadding?: [number, number];
69
- /** @type 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. */
73
+ /** 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. */
70
74
  rPadding?: [number, number];
71
- /** @type {Function} [xScale=d3.scaleLinear] 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. */
75
+ /** 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 */
72
76
  xScale?: AnyScale;
73
- /** @type {Function} [yScale=d3.scaleLinear] 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. */
77
+ /** 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 */
74
78
  yScale?: AnyScale;
75
- /** @type {Function} [zScale=d3.scaleLinear] 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. */
79
+ /** 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 */
76
80
  zScale?: AnyScale;
77
- /** @type {Function} [rScale=d3.scaleSqrt] 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. */
81
+ /** 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 */
78
82
  rScale?: AnyScale;
79
- /** @type 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 [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
83
+ /** 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 */
84
+ x1Scale?: AnyScale;
85
+ /** 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 */
86
+ y1Scale?: AnyScale;
87
+ /** 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 */
88
+ cScale?: AnyScale;
89
+ /** 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 [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
80
90
  xRange?: string[] | number[] | ((args: {
81
91
  width: number;
82
92
  height: number;
@@ -96,21 +106,35 @@ declare class __sveltets_Render<TData> {
96
106
  width: number;
97
107
  height: number;
98
108
  }) => number[] | string[]) | undefined;
109
+ /** 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 [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
110
+ x1Range?: string[] | number[] | ((args: {
111
+ xScale: AnyScale;
112
+ width: number;
113
+ height: number;
114
+ }) => number[] | string[]) | undefined;
115
+ /** 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 [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
116
+ y1Range?: string[] | number[] | ((args: {
117
+ yScale: AnyScale;
118
+ width: number;
119
+ height: number;
120
+ }) => number[] | string[]) | undefined;
121
+ /** 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 [scaleThreshhold](https://github.com/d3/d3-scale#threshold-scales) or [scaleQuantize](https://github.com/d3/d3-scale#quantize-scales). */
122
+ cRange?: string[];
99
123
  /** 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 */
100
124
  xReverse?: boolean;
101
125
  /** 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 */
102
126
  yReverse?: boolean;
103
- /** @type {Boolean} [zReverse=false] 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 */
127
+ /** 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 */
104
128
  zReverse?: boolean;
105
- /** @type {Boolean} [rReverse=false] 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 */
129
+ /** 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 */
106
130
  rReverse?: boolean;
107
- /** @type {Boolean} [xDomainSort=true] Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
131
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
108
132
  xDomainSort?: boolean;
109
- /** @type {Boolean} [yDomainSort=true] Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
133
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
110
134
  yDomainSort?: boolean;
111
- /** @type {Boolean} [zDomainSort=true] Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
135
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
112
136
  zDomainSort?: boolean;
113
- /** @type {Boolean} [rDomainSort=true] Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
137
+ /** Only used when scale is ordinal. Set whether the calculated unique items come back sorted. */
114
138
  rDomainSort?: boolean;
115
139
  /** 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). */
116
140
  padding?: {
@@ -128,14 +152,16 @@ declare class __sveltets_Render<TData> {
128
152
  } | undefined;
129
153
  /** Any extra configuration values you want available on the LayerCake context. This could be useful for color lookups or additional constants. */
130
154
  custom?: Record<string, any>;
131
- /** @type {Boolean} debug Enable debug printing to the console. Useful to inspect your scales and dimensions. */
155
+ /** Enable debug printing to the console. Useful to inspect your scales and dimensions. */
132
156
  debug?: boolean;
133
- /** @type {Boolean} [verbose=true] Show warnings in the console. */
157
+ /** Show warnings in the console. */
134
158
  verbose?: boolean;
135
159
  /** x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values */
136
160
  xBaseline?: number | null;
137
161
  /** y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values */
138
162
  yBaseline?: number | null;
163
+ /** 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 */
164
+ radial?: boolean;
139
165
  /** Props passed to GeoContext */
140
166
  geo?: Partial<{
141
167
  projection?: (() => import("d3-geo").GeoProjection) | undefined;
@@ -169,7 +195,7 @@ declare class __sveltets_Render<TData> {
169
195
  }> | undefined;
170
196
  /** Props passed to TransformContext */
171
197
  transform?: Partial<{
172
- mode?: "none" | "canvas" | "manual";
198
+ mode?: "canvas" | "manual" | "none";
173
199
  translateOnScale?: boolean;
174
200
  spring?: boolean | Parameters<typeof import("../stores/motionStore").motionStore>[1]["spring"];
175
201
  tweened?: boolean | Parameters<typeof import("../stores/motionStore").motionStore>[1]["tweened"];
@@ -195,7 +221,7 @@ declare class __sveltets_Render<TData> {
195
221
  y: number;
196
222
  }>;
197
223
  initialScale?: number | undefined;
198
- scale?: import("svelte/motion").Spring<number> | import("svelte/motion").Tweened<number> | import("svelte/store").Writable<number>;
224
+ scale?: import("svelte/store").Writable<number> | import("svelte/motion").Spring<number> | import("svelte/motion").Tweened<number>;
199
225
  setScrollMode?: (mode: "none" | "scale" | "translate") => void;
200
226
  reset?: () => void;
201
227
  zoomIn?: () => void;
@@ -218,7 +244,7 @@ declare class __sveltets_Render<TData> {
218
244
  transformContext?: TransformContext;
219
245
  };
220
246
  events(): {
221
- resize: CustomEvent<any>;
247
+ resize: any;
222
248
  transform: CustomEvent<{
223
249
  scale: number;
224
250
  translate: {
@@ -267,14 +293,27 @@ declare class __sveltets_Render<TData> {
267
293
  show: (e: PointerEvent, tooltipData?: any) => void;
268
294
  hide: () => void;
269
295
  };
296
+ x: Function;
270
297
  xScale: any;
271
298
  xGet: any;
299
+ y: Function;
272
300
  yScale: any;
273
301
  yGet: any;
302
+ z: Function;
274
303
  zScale: any;
275
304
  zGet: any;
305
+ r: Function;
276
306
  rScale: any;
277
307
  rGet: any;
308
+ x1: any;
309
+ x1Scale: any;
310
+ x1Get: any;
311
+ y1: any;
312
+ y1Scale: any;
313
+ y1Get: any;
314
+ c: any;
315
+ cScale: any;
316
+ cGet: any;
278
317
  padding: {
279
318
  top: number;
280
319
  right: number;
@@ -286,8 +325,9 @@ declare class __sveltets_Render<TData> {
286
325
  bottom?: number | undefined;
287
326
  left?: number | undefined;
288
327
  };
289
- data: unknown[] | SankeyGraph<any, any> | HierarchyNode<unknown>;
290
- flatData: import("svelte/store").Readable<unknown[] | SankeyGraph<any, any> | HierarchyNode<unknown>>;
328
+ data: any;
329
+ flatData: any;
330
+ config: any;
291
331
  };
292
332
  };
293
333
  }
@@ -1,6 +1,7 @@
1
1
  <!-- Wrapper to allow getting LayerCake context from <Chart> and exposing with a strongly type context getter -->
2
- <script context="module">import { createEventDispatcher, getContext, onMount, setContext } from 'svelte';
3
- import {} from 'svelte/store';
2
+ <script context="module">import { createScale } from '../utils/scales.js';
3
+ import { createEventDispatcher, getContext, onMount, setContext, } from 'svelte';
4
+ import { derived, writable } from 'svelte/store';
4
5
  export const chartContextKey = Symbol();
5
6
  export function chartContext() {
6
7
  return getContext(chartContextKey);
@@ -10,10 +11,114 @@ function setChartContext(context) {
10
11
  }
11
12
  </script>
12
13
 
13
- <script generics="TData">const dispatch = createEventDispatcher();
14
+ <script generics="TData">import { unique } from '@layerstack/utils/array';
15
+ import { scaleOrdinal } from 'd3-scale';
16
+ import { extent } from 'd3-array';
17
+ import { accessor, chartDataArray } from '../utils/common.js';
18
+ export let x1 = undefined;
19
+ export let x1Scale = undefined;
20
+ export let x1Domain = undefined;
21
+ export let x1Range = undefined;
22
+ export let y1 = undefined;
23
+ export let y1Scale = undefined;
24
+ export let y1Domain = undefined;
25
+ export let y1Range = undefined;
26
+ export let c = undefined;
27
+ export let cScale = undefined;
28
+ export let cDomain = undefined;
29
+ export let cRange = undefined;
14
30
  const layerCakeContext = getContext('LayerCake');
15
- setChartContext(layerCakeContext);
16
- const { width, height, containerWidth, containerHeight } = layerCakeContext;
31
+ const { data: contextData, width, height, containerWidth, containerHeight, xScale, yScale, } = layerCakeContext;
32
+ /* --------------------------------------------
33
+ * Make store versions of each parameter
34
+ * Prefix these with `_` to keep things organized
35
+ */
36
+ const _x1 = writable(accessor(x1));
37
+ const _x1Scale = writable(null);
38
+ const _x1Domain = writable(x1Domain);
39
+ const _x1Range = writable(x1Range);
40
+ const _x1Get = writable();
41
+ $: $_x1 = accessor(x1);
42
+ $: $_x1Domain = x1Domain ?? extent(chartDataArray($contextData), $_x1);
43
+ $: $_x1Scale =
44
+ x1Scale && x1Range
45
+ ? createScale(x1Scale, $_x1Domain, x1Range, { xScale: $xScale, $width, $height })
46
+ : null;
47
+ $: $_x1Range = x1Range;
48
+ $: $_x1Get = (d) => $_x1Scale?.($_x1(d));
49
+ const _y1 = writable(accessor(y1));
50
+ const _y1Scale = writable(null);
51
+ const _y1Domain = writable(y1Domain);
52
+ const _y1Range = writable(y1Range);
53
+ const _y1Get = writable();
54
+ $: $_y1 = accessor(y1);
55
+ $: $_y1Domain = y1Domain ?? extent(chartDataArray($contextData), $_y1);
56
+ $: $_y1Range = y1Range;
57
+ $: $_y1Scale =
58
+ y1Scale && y1Range
59
+ ? createScale(y1Scale, $_y1Domain, y1Range, { yScale: $yScale, $width, $height })
60
+ : null;
61
+ $: $_y1Get = (d) => $_y1Scale?.($_y1(d));
62
+ const _c = writable(accessor(c));
63
+ const _cScale = writable(scaleOrdinal());
64
+ const _cDomain = writable(cDomain);
65
+ const _cRange = writable(cRange);
66
+ const _cGet = writable();
67
+ $: $_c = accessor(c);
68
+ $: $_cDomain = cDomain ?? unique(chartDataArray($contextData).map($_c));
69
+ $: $_cRange = cRange;
70
+ $: $_cScale = cRange
71
+ ? createScale(cScale ?? scaleOrdinal(), $_cDomain, cRange, { $width, $height })
72
+ : null;
73
+ $: $_cGet = (d) => $_cScale?.($_c(d));
74
+ /** 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 */
75
+ export let radial = false;
76
+ const _radial = writable(radial);
77
+ $: $_radial = radial;
78
+ $: addtConfig = {
79
+ ...(x1 && { x1 }),
80
+ ...(x1Domain && { x1Domain }),
81
+ ...(x1Range && { x1Range }),
82
+ ...(x1Scale && { x1Scale }),
83
+ ...(y1 && { y1 }),
84
+ ...(y1Domain && { y1Domain }),
85
+ ...(y1Range && { y1Range }),
86
+ ...(y1Scale && { y1Scale }),
87
+ ...(c && { c }),
88
+ ...(cDomain && { cDomain }),
89
+ ...(cRange && { cRange }),
90
+ ...(cScale && { cScale }),
91
+ };
92
+ const _addtConfig = writable(addtConfig);
93
+ $: $_addtConfig = addtConfig;
94
+ const config = derived([layerCakeContext.config, _addtConfig], ([$config, $addtConfig]) => {
95
+ return {
96
+ ...$config,
97
+ ...$addtConfig,
98
+ };
99
+ });
100
+ const chartContext = {
101
+ ...layerCakeContext,
102
+ x1: _x1,
103
+ x1Domain: _x1Domain,
104
+ x1Range: _x1Range,
105
+ x1Scale: _x1Scale,
106
+ x1Get: _x1Get,
107
+ y1: _y1,
108
+ y1Domain: _y1Domain,
109
+ y1Range: _y1Range,
110
+ y1Scale: _y1Scale,
111
+ y1Get: _y1Get,
112
+ c: _c,
113
+ cDomain: _cDomain,
114
+ cRange: _cRange,
115
+ cScale: _cScale,
116
+ cGet: _cGet,
117
+ config,
118
+ radial: _radial,
119
+ };
120
+ setChartContext(chartContext);
121
+ const dispatch = createEventDispatcher();
17
122
  $: if (isMounted) {
18
123
  dispatch('resize', {
19
124
  width: $width,
@@ -31,4 +136,17 @@ onMount(() => {
31
136
  export let data = []; // Same as `ComponentProps<Chart<TData>>` but causes circular reference
32
137
  </script>
33
138
 
34
- <slot {data} flatData={layerCakeContext.data} />
139
+ <slot
140
+ {data}
141
+ flatData={chartContext.data}
142
+ config={$config}
143
+ x1={$_x1}
144
+ x1Scale={$_x1Scale}
145
+ x1Get={$_x1Get}
146
+ y1={$_y1}
147
+ y1Scale={$_y1Scale}
148
+ y1Get={$_y1Get}
149
+ c={$_c}
150
+ cScale={$_cScale}
151
+ cGet={$_cGet}
152
+ />
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { AnyScale } from '../index.js/utils/scales.js';
2
+ import { type AnyScale } from '../utils/scales.js';
3
3
  import type { HierarchyNode } from 'd3-hierarchy';
4
4
  import { type Readable } from 'svelte/store';
5
5
  export declare const chartContextKey: unique symbol;
@@ -20,6 +20,9 @@ type LayerCakeContext<TData> = {
20
20
  y: Readable<(d: TData) => any>;
21
21
  z: Readable<(d: TData) => any>;
22
22
  r: Readable<(d: TData) => any>;
23
+ x1: Readable<(d: TData) => any>;
24
+ y1: Readable<(d: TData) => any>;
25
+ c: Readable<(d: TData) => any>;
23
26
  custom: Readable<Object>;
24
27
  data: Readable<TData[] | HierarchyNode<TData> | SankeyGraph<any, any>>;
25
28
  xNice: Readable<number | boolean>;
@@ -50,10 +53,16 @@ type LayerCakeContext<TData> = {
50
53
  yDomain: Readable<any>;
51
54
  zDomain: Readable<any>;
52
55
  rDomain: Readable<any>;
56
+ x1Domain: Readable<any>;
57
+ y1Domain: Readable<any>;
58
+ cDomain: Readable<any>;
53
59
  xRange: Readable<any>;
54
60
  yRange: Readable<any>;
55
61
  zRange: Readable<any>;
56
62
  rRange: Readable<any>;
63
+ x1Range: Readable<any>;
64
+ y1Range: Readable<any>;
65
+ cRange: Readable<any>;
57
66
  config: Readable<any>;
58
67
  xScale: Readable<AnyScale>;
59
68
  xGet: Readable<any>;
@@ -63,6 +72,12 @@ type LayerCakeContext<TData> = {
63
72
  zGet: Readable<any>;
64
73
  rScale: Readable<AnyScale>;
65
74
  rGet: Readable<any>;
75
+ x1Scale: Readable<AnyScale | null>;
76
+ x1Get: Readable<any>;
77
+ y1Scale: Readable<AnyScale | null>;
78
+ y1Get: Readable<any>;
79
+ cScale: Readable<AnyScale | null>;
80
+ cGet: Readable<any>;
66
81
  };
67
82
  export type ChartEvents = {
68
83
  resize: ChartResizeDetail;
@@ -74,11 +89,34 @@ export type ChartResizeDetail = {
74
89
  containerHeight: number;
75
90
  };
76
91
  export type ChartResizeEvent = CustomEvent<ChartResizeDetail>;
77
- export type ChartContext<TData> = LayerCakeContext<TData> & {};
92
+ export type ChartContext<TData> = LayerCakeContext<TData> & {
93
+ radial: Readable<boolean>;
94
+ };
78
95
  export declare function chartContext<TData = any>(): ChartContext<TData>;
79
96
  import type { SankeyGraph } from 'd3-sankey';
80
97
  declare class __sveltets_Render<TData> {
81
98
  props(): {
99
+ x1?: import("../utils/common.js").Accessor<TData>;
100
+ x1Scale?: AnyScale<any, any, any, any> | undefined;
101
+ x1Domain?: import("../utils/scales.js").DomainType | undefined;
102
+ x1Range?: string[] | number[] | ((args: {
103
+ xScale: AnyScale;
104
+ width: number;
105
+ height: number;
106
+ }) => number[] | string[]) | undefined;
107
+ y1?: import("../utils/common.js").Accessor<TData>;
108
+ y1Scale?: AnyScale<any, any, any, any> | undefined;
109
+ y1Domain?: import("../utils/scales.js").DomainType | undefined;
110
+ y1Range?: string[] | number[] | ((args: {
111
+ yScale: AnyScale;
112
+ width: number;
113
+ height: number;
114
+ }) => number[] | string[]) | undefined;
115
+ c?: import("../utils/common.js").Accessor<TData>;
116
+ cScale?: AnyScale<any, any, any, any> | undefined;
117
+ cDomain?: import("../utils/scales.js").DomainType | undefined;
118
+ cRange?: string[] | undefined;
119
+ /** 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 */ radial?: boolean;
82
120
  data?: SankeyGraph<any, any> | TData[] | HierarchyNode<TData> | undefined;
83
121
  };
84
122
  events(): {} & {
@@ -88,6 +126,16 @@ declare class __sveltets_Render<TData> {
88
126
  default: {
89
127
  data: SankeyGraph<any, any> | TData[] | HierarchyNode<TData>;
90
128
  flatData: Readable<SankeyGraph<any, any> | TData[] | HierarchyNode<TData>>;
129
+ config: any;
130
+ x1: (d: TData) => any;
131
+ x1Scale: AnyScale<any, any, any, any> | null;
132
+ x1Get: Function;
133
+ y1: (d: TData) => any;
134
+ y1Scale: AnyScale<any, any, any, any> | null;
135
+ y1Get: Function;
136
+ c: (d: TData) => any;
137
+ cScale: AnyScale<any, any, any, any> | null;
138
+ cGet: Function;
91
139
  };
92
140
  };
93
141
  }
@@ -1,5 +1,5 @@
1
1
  <script>import { tick } from 'svelte';
2
- import { cls } from 'svelte-ux';
2
+ import { cls } from '@layerstack/tailwind';
3
3
  import { motionStore } from '../stores/motionStore.js';
4
4
  export let cx = 0;
5
5
  export let initialCx = cx;
@@ -1,4 +1,4 @@
1
- <script>import { uniqueId } from 'svelte-ux';
1
+ <script>import { uniqueId } from '@layerstack/utils';
2
2
  import ClipPath from './ClipPath.svelte';
3
3
  import Circle from './Circle.svelte';
4
4
  /** Unique id for clipPath */
@@ -1,4 +1,4 @@
1
- <script>import { uniqueId } from 'svelte-ux';
1
+ <script>import { uniqueId } from '@layerstack/utils';
2
2
  /** Unique id for clipPath */
3
3
  export let id = uniqueId('clipPath-');
4
4
  /** Use existing path or shape (by id) for clipPath */
@@ -1,6 +1,6 @@
1
1
  <script>import { createEventDispatcher, getContext } from 'svelte';
2
2
  import { geoTransform as d3geoTransform, } from 'd3-geo';
3
- import { cls } from 'svelte-ux';
3
+ import { cls } from '@layerstack/tailwind';
4
4
  import { chartContext } from './ChartContext.svelte';
5
5
  import { geoContext } from './GeoContext.svelte';
6
6
  import { curveLinearClosed } from 'd3-shape';
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import { type GeoIdentityTransform, type GeoPermissibleObjects, type GeoProjection, type GeoTransformPrototype } from 'd3-geo';
3
- import type { TooltipContextValue } from './TooltipContext.svelte';
3
+ import type { TooltipContextValue } from './tooltip/TooltipContext.svelte';
4
4
  import { type CurveFactory, type CurveFactoryLineOnly } from 'd3-shape';
5
5
  import { geoCurvePath } from '../utils/geo.js';
6
6
  declare const __propDef: {