svelteplot 0.3.4 → 0.3.5-pr-121.1

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 (190) hide show
  1. package/dist/Mark.svelte +25 -27
  2. package/dist/Mark.svelte.d.ts +87 -17
  3. package/dist/Plot.svelte +1 -2
  4. package/dist/Plot.svelte.d.ts +1 -1
  5. package/dist/constants.d.ts +1 -1
  6. package/dist/core/Facet.svelte +1 -1
  7. package/dist/core/Facet.svelte.d.ts +1 -1
  8. package/dist/core/FacetAxes.svelte +3 -1
  9. package/dist/core/FacetGrid.svelte +1 -1
  10. package/dist/core/FacetGrid.svelte.d.ts +1 -1
  11. package/dist/core/Plot.svelte +1 -1
  12. package/dist/core/Plot.svelte.d.ts +1 -1
  13. package/dist/helpers/autoScales.d.ts +1 -1
  14. package/dist/helpers/autoTicks.d.ts +1 -1
  15. package/dist/helpers/autoTicks.js +1 -1
  16. package/dist/helpers/callWithProps.d.ts +1 -1
  17. package/dist/helpers/colors.d.ts +2 -2
  18. package/dist/helpers/curves.d.ts +1 -1
  19. package/dist/helpers/facets.d.ts +1 -1
  20. package/dist/helpers/getBaseStyles.d.ts +2 -2
  21. package/dist/helpers/group.d.ts +1 -1
  22. package/dist/helpers/index.d.ts +3 -3
  23. package/dist/helpers/isDataRecord.d.ts +1 -1
  24. package/dist/helpers/isRawValue.d.ts +1 -1
  25. package/dist/helpers/projection.d.ts +1 -1
  26. package/dist/helpers/reduce.d.ts +1 -1
  27. package/dist/helpers/regressionLoess.d.ts +1 -1
  28. package/dist/helpers/resolve.d.ts +3 -3
  29. package/dist/helpers/scales.d.ts +2 -2
  30. package/dist/helpers/typeChecks.d.ts +5 -5
  31. package/dist/marks/Area.svelte +14 -17
  32. package/dist/marks/Area.svelte.d.ts +91 -19
  33. package/dist/marks/AreaX.svelte +15 -12
  34. package/dist/marks/AreaX.svelte.d.ts +94 -3
  35. package/dist/marks/AreaY.svelte +15 -15
  36. package/dist/marks/AreaY.svelte.d.ts +94 -3
  37. package/dist/marks/Arrow.svelte +16 -19
  38. package/dist/marks/Arrow.svelte.d.ts +110 -38
  39. package/dist/marks/AxisX.svelte +60 -56
  40. package/dist/marks/AxisX.svelte.d.ts +98 -25
  41. package/dist/marks/AxisY.svelte +73 -54
  42. package/dist/marks/AxisY.svelte.d.ts +100 -27
  43. package/dist/marks/BarX.svelte +28 -30
  44. package/dist/marks/BarX.svelte.d.ts +89 -17
  45. package/dist/marks/BarY.svelte +27 -27
  46. package/dist/marks/BarY.svelte.d.ts +88 -16
  47. package/dist/marks/BollingerX.svelte +21 -16
  48. package/dist/marks/BollingerX.svelte.d.ts +17 -16
  49. package/dist/marks/BollingerY.svelte +21 -16
  50. package/dist/marks/BollingerY.svelte.d.ts +17 -16
  51. package/dist/marks/BoxX.svelte +5 -7
  52. package/dist/marks/BoxX.svelte.d.ts +5 -3
  53. package/dist/marks/BoxY.svelte +13 -16
  54. package/dist/marks/BoxY.svelte.d.ts +41 -28
  55. package/dist/marks/Brush.svelte +27 -30
  56. package/dist/marks/Brush.svelte.d.ts +20 -15
  57. package/dist/marks/BrushX.svelte +9 -7
  58. package/dist/marks/BrushX.svelte.d.ts +5 -2
  59. package/dist/marks/BrushY.svelte +9 -7
  60. package/dist/marks/BrushY.svelte.d.ts +5 -2
  61. package/dist/marks/Cell.svelte +17 -18
  62. package/dist/marks/Cell.svelte.d.ts +80 -8
  63. package/dist/marks/CellX.svelte +12 -8
  64. package/dist/marks/CellX.svelte.d.ts +5 -2
  65. package/dist/marks/CellY.svelte +12 -8
  66. package/dist/marks/CellY.svelte.d.ts +5 -2
  67. package/dist/marks/ColorLegend.svelte +5 -8
  68. package/dist/marks/ColorLegend.svelte.d.ts +2 -2
  69. package/dist/marks/CustomMark.svelte +23 -16
  70. package/dist/marks/CustomMark.svelte.d.ts +17 -14
  71. package/dist/marks/CustomMarkHTML.svelte +20 -18
  72. package/dist/marks/CustomMarkHTML.svelte.d.ts +29 -15
  73. package/dist/marks/DifferenceY.svelte +54 -18
  74. package/dist/marks/DifferenceY.svelte.d.ts +59 -28
  75. package/dist/marks/Dot.svelte +13 -14
  76. package/dist/marks/Dot.svelte.d.ts +84 -12
  77. package/dist/marks/DotX.svelte +9 -9
  78. package/dist/marks/DotX.svelte.d.ts +86 -4
  79. package/dist/marks/DotY.svelte +10 -9
  80. package/dist/marks/DotY.svelte.d.ts +87 -5
  81. package/dist/marks/Frame.svelte +20 -27
  82. package/dist/marks/Frame.svelte.d.ts +24 -10
  83. package/dist/marks/Geo.svelte +22 -15
  84. package/dist/marks/Geo.svelte.d.ts +97 -13
  85. package/dist/marks/Graticule.svelte +16 -19
  86. package/dist/marks/Graticule.svelte.d.ts +3 -3
  87. package/dist/marks/GridX.svelte +5 -8
  88. package/dist/marks/GridX.svelte.d.ts +79 -7
  89. package/dist/marks/GridY.svelte +5 -8
  90. package/dist/marks/GridY.svelte.d.ts +79 -7
  91. package/dist/marks/HTMLTooltip.svelte +9 -14
  92. package/dist/marks/HTMLTooltip.svelte.d.ts +25 -12
  93. package/dist/marks/Line.svelte +24 -29
  94. package/dist/marks/Line.svelte.d.ts +97 -25
  95. package/dist/marks/LineX.svelte +9 -4
  96. package/dist/marks/LineX.svelte.d.ts +99 -3
  97. package/dist/marks/LineY.svelte +11 -5
  98. package/dist/marks/LineY.svelte.d.ts +100 -4
  99. package/dist/marks/Link.svelte +35 -19
  100. package/dist/marks/Link.svelte.d.ts +107 -18
  101. package/dist/marks/Pointer.svelte +13 -18
  102. package/dist/marks/Pointer.svelte.d.ts +34 -21
  103. package/dist/marks/Rect.svelte +19 -19
  104. package/dist/marks/Rect.svelte.d.ts +86 -13
  105. package/dist/marks/RectX.svelte +10 -9
  106. package/dist/marks/RectX.svelte.d.ts +22 -6
  107. package/dist/marks/RectY.svelte +9 -10
  108. package/dist/marks/RectY.svelte.d.ts +22 -6
  109. package/dist/marks/RegressionX.svelte +1 -1
  110. package/dist/marks/RegressionX.svelte.d.ts +1 -1
  111. package/dist/marks/RegressionY.svelte +1 -1
  112. package/dist/marks/RegressionY.svelte.d.ts +1 -1
  113. package/dist/marks/RuleX.svelte +14 -16
  114. package/dist/marks/RuleX.svelte.d.ts +84 -12
  115. package/dist/marks/RuleY.svelte +12 -15
  116. package/dist/marks/RuleY.svelte.d.ts +84 -12
  117. package/dist/marks/Sphere.svelte +6 -7
  118. package/dist/marks/Sphere.svelte.d.ts +3 -2
  119. package/dist/marks/Spike.svelte +17 -9
  120. package/dist/marks/Spike.svelte.d.ts +94 -4
  121. package/dist/marks/SymbolLegend.svelte +1 -1
  122. package/dist/marks/Text.svelte +25 -23
  123. package/dist/marks/Text.svelte.d.ts +101 -25
  124. package/dist/marks/TickX.svelte +12 -13
  125. package/dist/marks/TickX.svelte.d.ts +92 -20
  126. package/dist/marks/TickY.svelte +11 -14
  127. package/dist/marks/TickY.svelte.d.ts +92 -20
  128. package/dist/marks/Vector.svelte +19 -23
  129. package/dist/marks/Vector.svelte.d.ts +93 -21
  130. package/dist/marks/helpers/AreaCanvas.svelte +1 -1
  131. package/dist/marks/helpers/AreaCanvas.svelte.d.ts +1 -1
  132. package/dist/marks/helpers/BaseAxisX.svelte +5 -3
  133. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -1
  134. package/dist/marks/helpers/BaseAxisY.svelte +10 -8
  135. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +3 -1
  136. package/dist/marks/helpers/CanvasLayer.svelte +1 -1
  137. package/dist/marks/helpers/DotCanvas.svelte +1 -1
  138. package/dist/marks/helpers/DotCanvas.svelte.d.ts +1 -1
  139. package/dist/marks/helpers/GeoCanvas.svelte +1 -1
  140. package/dist/marks/helpers/GeoCanvas.svelte.d.ts +1 -1
  141. package/dist/marks/helpers/LineCanvas.svelte +1 -1
  142. package/dist/marks/helpers/LineCanvas.svelte.d.ts +1 -1
  143. package/dist/marks/helpers/LinearGradientX.svelte +1 -1
  144. package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
  145. package/dist/marks/helpers/LinearGradientY.svelte +1 -1
  146. package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
  147. package/dist/marks/helpers/MarkerPath.svelte +1 -1
  148. package/dist/marks/helpers/MarkerPath.svelte.d.ts +1 -41
  149. package/dist/marks/helpers/MultilineText.svelte +1 -1
  150. package/dist/marks/helpers/MultilineText.svelte.d.ts +1 -1
  151. package/dist/marks/helpers/RectPath.svelte +29 -26
  152. package/dist/marks/helpers/RectPath.svelte.d.ts +39 -26
  153. package/dist/marks/helpers/Regression.svelte +7 -2
  154. package/dist/marks/helpers/Regression.svelte.d.ts +2 -5
  155. package/dist/marks/helpers/events.d.ts +1 -1
  156. package/dist/transforms/bin.d.ts +2 -2
  157. package/dist/transforms/bollinger.d.ts +2 -67
  158. package/dist/transforms/centroid.d.ts +8 -66
  159. package/dist/transforms/centroid.js +10 -7
  160. package/dist/transforms/filter.d.ts +1 -1
  161. package/dist/transforms/group.d.ts +5 -13
  162. package/dist/transforms/interval.d.ts +3 -123
  163. package/dist/transforms/jitter.d.ts +1 -1
  164. package/dist/transforms/map.d.ts +4 -184
  165. package/dist/transforms/normalize.d.ts +3 -123
  166. package/dist/transforms/recordize.d.ts +1 -1
  167. package/dist/transforms/rename.d.ts +2 -2
  168. package/dist/transforms/select.d.ts +8 -428
  169. package/dist/transforms/shift.d.ts +1 -1
  170. package/dist/transforms/sort.d.ts +4 -243
  171. package/dist/transforms/stack.d.ts +1 -1
  172. package/dist/transforms/window.d.ts +3 -131
  173. package/dist/types/channel.d.ts +11 -0
  174. package/dist/types/colorScheme.d.ts +1 -0
  175. package/dist/types/colorScheme.js +1 -0
  176. package/dist/types/data.d.ts +13 -0
  177. package/dist/types/data.js +1 -0
  178. package/dist/types/facet.d.ts +50 -0
  179. package/dist/types/facet.js +1 -0
  180. package/dist/types/index.d.ts +58 -0
  181. package/dist/types/index.js +7 -0
  182. package/dist/types/mark.d.ts +123 -0
  183. package/dist/types/mark.js +1 -0
  184. package/dist/types/plot.d.ts +459 -0
  185. package/dist/types/plot.js +1 -0
  186. package/dist/types/scale.d.ts +143 -0
  187. package/dist/types/scale.js +1 -0
  188. package/package.json +125 -120
  189. package/dist/types.d.ts +0 -841
  190. /package/dist/{types.js → types/channel.js} +0 -0
package/dist/types.d.ts DELETED
@@ -1,841 +0,0 @@
1
- import type { ScaleBand, ScaleLinear, ScaleOrdinal } from 'd3-scale';
2
- import type { Snippet } from 'svelte';
3
- import type { MouseEventHandler } from 'svelte/elements';
4
- import type { MarkerShape } from './marks/helpers/Marker.svelte';
5
- import type { Writable } from 'svelte/store';
6
- import type * as CSS from 'csstype';
7
- import type { AreaMarkProps } from './marks/Area.svelte';
8
- import type { ArrowMarkProps } from './marks/Arrow.svelte';
9
- import type { AxisXMarkProps } from './marks/AxisX.svelte';
10
- import type { AxisYMarkProps } from './marks/AxisY.svelte';
11
- import type { BarXMarkProps } from './marks/BarX.svelte';
12
- import type { CellMarkProps } from './marks/Cell.svelte';
13
- import type { DotMarkProps } from './marks/Dot.svelte';
14
- import type { FrameMarkProps } from './marks/Frame.svelte';
15
- import type { GeoMarkProps } from './marks/Geo.svelte';
16
- import type { GraticuleMarkProps } from './marks/Graticule.svelte';
17
- import type { LineMarkProps } from './marks/Line.svelte';
18
- import type { LinkMarkProps } from './marks/Link.svelte';
19
- import type { RectMarkProps } from './marks/Rect.svelte';
20
- import type { RuleXMarkProps } from './marks/RuleX.svelte';
21
- import type { SphereMarkProps } from './marks/Sphere.svelte';
22
- import type { SpikeMarkProps } from './marks/Spike.svelte';
23
- import type { TextMarkProps } from './marks/Text.svelte';
24
- import type { TickXMarkProps } from './marks/TickX.svelte';
25
- import type { VectorMarkProps } from './marks/Vector.svelte';
26
- import type { BrushMarkProps } from './marks/Brush.svelte';
27
- import type { BrushXMarkProps } from './marks/BrushX.svelte';
28
- import type { BrushYMarkProps } from './marks/BrushY.svelte';
29
- import type { RectXMarkProps } from './marks/RectX.svelte';
30
- import type { RectYMarkProps } from './marks/RectY.svelte';
31
- import type { RuleYMarkProps } from './marks/RuleY.svelte';
32
- import type { TickYMarkProps } from './marks/TickY.svelte';
33
- import type { GridYMarkProps } from './marks/GridY.svelte';
34
- import type { GridXMarkProps } from './marks/GridX.svelte';
35
- import type { PointerMarkProps } from './marks/Pointer.svelte';
36
- import type { BoxXMarkProps } from './marks/BoxX.svelte';
37
- import type { BoxYMarkProps } from './marks/BoxY.svelte';
38
- export type MarkType = 'area' | 'arrow' | 'axisX' | 'axisY' | 'barX' | 'barY' | 'cell' | 'dot' | 'vector' | 'frame' | 'geo' | 'gridX' | 'gridY' | 'line' | 'rect' | 'regression' | 'ruleX' | 'ruleY' | 'swoopyArrow' | 'text' | 'tickX' | 'tickY';
39
- export type ScaleName = 'x' | 'y' | 'r' | 'color' | 'opacity' | 'length' | 'symbol' | 'fx' | 'fy' | 'projection';
40
- export type ScaleType = 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
41
- export type Mark<T> = {
42
- id: symbol;
43
- type: MarkType;
44
- channels: ScaledChannelName[];
45
- scales: Set<ScaleName>;
46
- data: DataRecord[];
47
- options: T;
48
- };
49
- export type ScaledChannelName = 'fill' | 'fillOpacity' | 'opacity' | 'r' | 'length' | 'stroke' | 'strokeOpacity' | 'symbol' | 'fx' | 'fy' | 'x' | 'x1' | 'x2' | 'y' | 'y1' | 'y2';
50
- export type ChannelName = ScaledChannelName | 'z' | 'sort' | 'filter' | 'interval';
51
- export type RawValue = number | Date | boolean | string | symbol;
52
- export type ScaleOptions = {
53
- /**
54
- * Override the automatic scale type detection.
55
- */
56
- type: ScaleType | 'auto';
57
- /**
58
- * Set a custom domain for the scale instead of auto-computing the domain
59
- * from the mark data channels.
60
- */
61
- domain?: RawValue[];
62
- /**
63
- * Set a custom range for the scale.
64
- */
65
- range?: RawValue[];
66
- /**
67
- * Reverse the scale.
68
- */
69
- reverse: boolean;
70
- label?: string;
71
- interval?: string | number;
72
- clamp: boolean;
73
- nice: boolean;
74
- zero: boolean;
75
- round: boolean;
76
- percent: boolean;
77
- transform?: (d: RawValue) => RawValue;
78
- /**
79
- * set the padding for band scales
80
- */
81
- padding: number;
82
- /**
83
- * set the align for band or point scales
84
- */
85
- align: number;
86
- /**
87
- * set the inner padding for band scales
88
- */
89
- paddingInner?: number;
90
- /**
91
- * set the outer padding for band scales
92
- */
93
- paddingOuter?: number;
94
- insetLeft?: number;
95
- insetRight?: number;
96
- insetTop?: number;
97
- insetBottom?: number;
98
- ticks?: (number | Date)[];
99
- tickSpacing: number;
100
- base?: number;
101
- sort?: ChannelAccessor | ((a: RawValue, b: RawValue) => number) | {
102
- channel: string;
103
- order: 'ascending' | 'descending';
104
- };
105
- constant?: number;
106
- };
107
- export type ColorScaleOptions = ScaleOptions & {
108
- legend: boolean;
109
- type: ScaleType | 'categorical' | 'sequential' | 'cyclical' | 'threshold' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
110
- scheme: string;
111
- /**
112
- * fallback color used for null/undefined
113
- */
114
- unknown: string;
115
- /**
116
- * center value for diverging scales
117
- */
118
- pivot: number;
119
- /**
120
- * number of colors for quantize and quantile-threshold scales
121
- */
122
- n: number;
123
- interpolate: (d: any) => typeof d;
124
- };
125
- export type AxisXAnchor = 'bottom' | 'top' | 'both';
126
- export type AxisYAnchor = 'left' | 'right' | 'both';
127
- export type XScaleOptions = ScaleOptions & {
128
- /**
129
- * Activate the implicit GridX mark. For more control over the grid styling
130
- * and layering, add an explicit GridX mark to your plot instead of using the
131
- * implicit grids.
132
- */
133
- grid: boolean;
134
- /**
135
- * Controls the position of the implicit AxisX mark, or set to false to disable
136
- * the implicit AxisX mark. For more control over the axis styling and layering
137
- * add an explicit AxisX mark to your plot instead of using the implicit axes.
138
- */
139
- axis: AxisXAnchor | false;
140
- /**
141
- * rotate the axis ticks
142
- */
143
- tickRotate: number;
144
- labelAnchor: 'auto' | 'left' | 'center' | 'right';
145
- tickFormat: 'auto' | string | ((d: RawValue) => string);
146
- };
147
- export type YScaleOptions = ScaleOptions & {
148
- /**
149
- * Activate the implicit GridY mark. For more control over the grid styling
150
- * and layering, add an explicit GridY mark to your plot instead of using the
151
- * implicit grids.
152
- */
153
- grid: boolean;
154
- /**
155
- * Controls the position of the implicit AxisY mark, or set to false to disable
156
- * the implicit AxisY mark. For more control over the axis styling and layering
157
- * add an explicit AxisY mark to your plot instead of using the implicit axes.
158
- */
159
- axis: AxisYAnchor | false;
160
- tickFormat: string | ((d: RawValue) => string);
161
- /**
162
- * rotate the axis ticks
163
- */
164
- tickRotate: number;
165
- labelAnchor: 'auto' | 'bottom' | 'middle' | 'top';
166
- };
167
- export type LegendScaleOptions = ScaleOptions & {
168
- legend: boolean;
169
- };
170
- export type PlotOptions = {
171
- /**
172
- * The plot title, rendered as H2 tag above the SVG element. Instead of
173
- * using the title, you can also pass a "header" snippet and render your
174
- * own custom title markup.
175
- */
176
- title: string;
177
- /**
178
- * The plot subtitle, rendered as H3 tag above the SVG element. Instead of
179
- * using the subtitle, you can also pass a "header" snippet and render your
180
- * own custom title markup.
181
- */
182
- subtitle: string;
183
- /**
184
- * The plot caption, rendered as FIGCAPTION tag below the SVG element. Instead of
185
- * using the caption, you can also pass a "footer" snippet and render your
186
- * own custom title markup.
187
- */
188
- caption: string;
189
- /**
190
- * By default, the plot will extend to fit 100% of the parent container width. By
191
- * setting the maxWidth style property you can limit the width of your plot.
192
- */
193
- maxWidth?: string;
194
- /**
195
- * force the plot into a fixed width
196
- */
197
- width?: number;
198
- /**
199
- * force the plot into a fixed height
200
- */
201
- height: 'auto' | number | ((d: number) => number);
202
- /**
203
- * Convenience option for setting all four margins at once, in px.
204
- */
205
- margin: number | {
206
- top?: number;
207
- right?: number;
208
- bottom?: number;
209
- left?: number;
210
- };
211
- /**
212
- * Left margin of the plot, in px.
213
- */
214
- marginLeft: number;
215
- /**
216
- * Right margin of the plot, in px.
217
- */
218
- marginRight: number;
219
- /**
220
- * Top margin of the plot, in px.
221
- */
222
- marginTop: number;
223
- /**
224
- * Bottom margin of the plot, in px.
225
- */
226
- marginBottom: number;
227
- /**
228
- * Activates the implicit GridX and GridY marks.
229
- */
230
- grid: boolean;
231
- /**
232
- * Activates the implicit AxisX and AxisY marks.
233
- */
234
- axes: boolean;
235
- /**
236
- * Activates the implicit frame marks
237
- */
238
- frame: boolean;
239
- /**
240
- * Convenience shortcut for setting both the x and y scale insets.
241
- */
242
- inset: number;
243
- /**
244
- * Convenience shortcut for setting both the x and y scale paddings
245
- */
246
- padding: number;
247
- /**
248
- * Geo-projection
249
- */
250
- projection: string | null;
251
- /**
252
- * if not null, computes a default height such that a variation of one
253
- * unit in the x dimension is represented by the corresponding number
254
- * of pixels as a variation in the y dimension of one unit.
255
- */
256
- aspectRatio: number | null;
257
- /**
258
- * Top-level faceting options
259
- */
260
- facet: Partial<{
261
- /**
262
- * The data to facet by. Turns on automatic faceting for all marks that
263
- * use the exact same data (===)
264
- */
265
- data: DataRecord[];
266
- x: ChannelAccessor;
267
- y: ChannelAccessor;
268
- }>;
269
- /**
270
- * Options for the shared x scale.
271
- */
272
- x: Partial<XScaleOptions>;
273
- /**
274
- * Options for the shared y scale
275
- */
276
- y: Partial<YScaleOptions>;
277
- /**
278
- * Options for the shared radius scale
279
- */
280
- r: Partial<ScaleOptions>;
281
- color: Partial<ColorScaleOptions>;
282
- opacity: Partial<ScaleOptions>;
283
- symbol: Partial<LegendScaleOptions>;
284
- length: Partial<ScaleOptions>;
285
- fx: Partial<ScaleOptions>;
286
- fy: Partial<ScaleOptions>;
287
- children: Snippet<[
288
- {
289
- width: number;
290
- height: number;
291
- options: PlotOptions;
292
- scales: PlotScales;
293
- }
294
- ]>;
295
- /**
296
- * You can use the header snippet to render a custom title and subtitle for
297
- * your plot, or place a legend above the visualization.
298
- */
299
- header: Snippet;
300
- footer: Snippet;
301
- /**
302
- * The underlay snippet is useful for adding a layer of custom HTML markup
303
- * behind the SVG body of your plot, e.g. for a watermark or background image.
304
- */
305
- underlay: Snippet<[PlotOptions]>;
306
- /**
307
- * The overlay snippet is useful for adding a layer of custom HTML markup
308
- * in front of the SVG body of your plot, e.g. for HTML tooltips.
309
- */
310
- overlay: Snippet;
311
- facetAxes: Snippet;
312
- /**
313
- * if you set testid, the plot container will get a data-testid attribute which
314
- * can be useful for automatic testing
315
- */
316
- testid: string;
317
- /**
318
- * in case you want to give your Plot element an extra CSS class
319
- */
320
- class: string | null;
321
- /**
322
- * if set to true, the plot will use the implicit scales
323
- */
324
- implicitScales: boolean;
325
- /**
326
- * locale used for automatic axis ticks
327
- */
328
- locale: string;
329
- /**
330
- * pass a @emotion/css function to style plot using dynamic classes
331
- */
332
- css: (d: string) => string | undefined;
333
- };
334
- export type GenericMarkOptions = Record<string | symbol, any>;
335
- export type DataRecord = Record<string | symbol, RawValue> & {
336
- ___orig___?: RawValue | [RawValue, RawValue];
337
- };
338
- export type ResolvedDataRecord = Partial<Record<ScaledChannelName, any>> & {
339
- datum: DataRecord;
340
- };
341
- export type ScaledDataRecord = Partial<Record<ScaledChannelName, number | string | boolean | undefined>> & {
342
- datum: DataRecord;
343
- valid: Boolean;
344
- };
345
- export type DataRow = DataRecord | RawValue | [number, number] | null;
346
- export type PlotScale = {
347
- type: ScaleType;
348
- domain: RawValue[];
349
- range: RawValue[];
350
- autoTitle?: string;
351
- /**
352
- * The number of marks that are using this scale.
353
- */
354
- manualActiveMarks: number;
355
- /**
356
- * Set of accessors used in channels that are bound to this scale.
357
- */
358
- uniqueScaleProps: Set<ChannelAccessor>;
359
- skip: Map<ScaledChannelName, Set<symbol>>;
360
- fn: ScaleLinear<RawValue, number> & ScaleBand<RawValue> & ScaleOrdinal<string | Date, number> & ScaleOrdinal<string | Date, string>;
361
- };
362
- export type CurveName = 'basis' | 'basis-closed' | 'basis-open' | 'bundle' | 'bump-x' | 'bump-y' | 'cardinal' | 'cardinal-closed' | 'cardinal-open' | 'catmull-rom' | 'catmull-rom-closed' | 'catmull-rom-open' | 'linear' | 'linear-closed' | 'monotone-x' | 'monotone-y' | 'natural' | 'step' | 'step-after' | 'step-before';
363
- export type MarkerOptions = {
364
- /**
365
- * the marker for the starting point of a line segment
366
- */
367
- markerStart?: boolean | MarkerShape | Snippet;
368
- /**
369
- * the marker for any intermediate point of a line segment
370
- */
371
- markerMid?: boolean | MarkerShape | Snippet;
372
- /**
373
- * the marker for the end point of a line segment
374
- */
375
- markerEnd?: boolean | MarkerShape | Snippet;
376
- /**
377
- * shorthand for setting the marker on all points
378
- */
379
- marker?: boolean | MarkerShape | Snippet;
380
- };
381
- export type PlotScales = Record<ScaleName, PlotScale>;
382
- export type ChannelAccessor = RawValue | ((d: DataRow) => RawValue) | null | undefined;
383
- export type ConstantAccessor<T> = T | ((d: DataRow) => T) | null | undefined;
384
- export type PlotState = {
385
- width: number;
386
- height: number;
387
- options: PlotOptions;
388
- facetWidth: number;
389
- facetHeight: number;
390
- plotWidth: number;
391
- plotHeight: number;
392
- scales: PlotScales;
393
- body: HTMLDivElement;
394
- /**
395
- * True if there's a color scale and a symbol scale and both are bound to the same
396
- * single channel accessor.
397
- */
398
- colorSymbolRedundant: boolean;
399
- /**
400
- * True if the plot is using filled dot marks.
401
- */
402
- hasFilledDotMarks: boolean;
403
- css: ((d: string) => string) | null;
404
- };
405
- export type PlotContext = {
406
- /**
407
- * Registers a mark with the Plot component along with its
408
- * data and the channel mappings.
409
- */
410
- addMark: (mark: Mark<GenericMarkOptions>) => Mark<GenericMarkOptions>;
411
- /**
412
- * Updates a mark after either the data or the channel mappings
413
- * have been updated.
414
- */
415
- updateMark: (mark: Mark<GenericMarkOptions>) => void;
416
- /**
417
- * Unregister a mark from the Plot component after the mark
418
- * component has been destroyed.
419
- */
420
- removeMark: (mark: Mark<GenericMarkOptions>) => void;
421
- getPlotState: () => PlotState;
422
- getTopLevelFacet: () => PlotOptions['facet'];
423
- /**
424
- * Updates the plots internal facetWidth and facetHeight dimensions
425
- * which are used as range for the positional scales x and y.
426
- */
427
- updateDimensions: (width: number, height: number) => void;
428
- };
429
- type FacetState = {
430
- fx: RawValue;
431
- fy: RawValue;
432
- /**
433
- * True, if the facet is the leftmost in its row
434
- */
435
- left: boolean;
436
- /**
437
- * True, if the facet is the topmost in its column
438
- */
439
- top: boolean;
440
- /**
441
- * True, if the facet is the rightmost in its row
442
- */
443
- right: boolean;
444
- /**
445
- * True, if the facet is the bottommost in its column
446
- */
447
- bottom: boolean;
448
- /**
449
- * True, if the adjacent facet to the top is empty
450
- */
451
- topEmpty: boolean;
452
- /**
453
- * True, if the adjacent facet to the bottom is empty
454
- */
455
- bottomEmpty: boolean;
456
- /**
457
- * True, if the adjacent facet to the left is empty
458
- */
459
- leftEmpty: boolean;
460
- /**
461
- * True, if the adjacent facet to the right is empty
462
- */
463
- rightEmpty: boolean;
464
- };
465
- /**
466
- * Test if the given data record is visible in the current facet.
467
- */
468
- type TestFacetFunction = (datum: DataRecord, channels: Record<ChannelName, ChannelAccessor>) => boolean;
469
- export type FacetContext = {
470
- /**
471
- * Returns a stateful function that tests whether a specific data
472
- * record is visible in the current facet or not.
473
- */
474
- getTestFacet: () => TestFacetFunction;
475
- getFacetState: () => FacetState;
476
- };
477
- export type LinkableMarkProps = {
478
- /**
479
- * if set, the mark element will be wrapped in a <a> link element
480
- */
481
- href?: ConstantAccessor<string>;
482
- /**
483
- * the relationship of the target object to the link object (e.g. "noopener")
484
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#rel
485
- */
486
- rel?: ConstantAccessor<string>;
487
- /**
488
- * the link target mime type, e.g. "text/csv"
489
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#type
490
- */
491
- type?: ConstantAccessor<string>;
492
- /**
493
- * the target of the link, e.g. "_blank" or "_self"
494
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#target
495
- */
496
- target?: ConstantAccessor<'_self' | '_blank' | '_parent' | '_top' | string>;
497
- /**
498
- * if set to true, the link will be downloaded instead of navigating to it
499
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download
500
- */
501
- download?: ConstantAccessor<boolean>;
502
- [key: `data-sveltekit-${string}`]: string | boolean;
503
- };
504
- export type BaseMarkProps = Partial<{
505
- /**
506
- * Filter the data without modifying the inferred scales
507
- */
508
- filter?: ConstantAccessor<boolean>;
509
- facet?: 'auto' | 'include' | 'exclude';
510
- fx: ChannelAccessor;
511
- fy: ChannelAccessor;
512
- dx: ConstantAccessor<number>;
513
- dy: ConstantAccessor<number>;
514
- fill: ConstantAccessor<string>;
515
- fillOpacity: ConstantAccessor<number>;
516
- sort: string | ConstantAccessor<RawValue> | ((a: RawValue, b: RawValue) => number) | {
517
- /** sort data using an already defined channel */
518
- channel: string;
519
- /** sort order */
520
- order?: 'ascending' | 'descending';
521
- };
522
- stroke: ConstantAccessor<string>;
523
- strokeWidth: ConstantAccessor<number>;
524
- strokeOpacity: ConstantAccessor<number>;
525
- strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin>;
526
- strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap>;
527
- strokeMiterlimit: ConstantAccessor<number>;
528
- opacity: ConstantAccessor<number>;
529
- strokeDasharray: ConstantAccessor<string>;
530
- strokeDashoffset: ConstantAccessor<number>;
531
- mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode>;
532
- clipPath: string;
533
- imageFilter: ConstantAccessor<string>;
534
- shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering>;
535
- paintOrder: ConstantAccessor<string>;
536
- onclick?: MouseEventHandler<SVGPathElement>;
537
- ondblclick?: MouseEventHandler<SVGPathElement>;
538
- onmouseup?: MouseEventHandler<SVGPathElement>;
539
- onmousedown?: MouseEventHandler<SVGPathElement>;
540
- onmouseenter?: MouseEventHandler<SVGPathElement>;
541
- onmousemove?: MouseEventHandler<SVGPathElement>;
542
- onmouseleave?: MouseEventHandler<SVGPathElement>;
543
- onmouseout?: MouseEventHandler<SVGPathElement>;
544
- onmouseover?: MouseEventHandler<SVGPathElement>;
545
- onpointercancel?: MouseEventHandler<SVGPathElement>;
546
- onpointerdown?: MouseEventHandler<SVGPathElement>;
547
- onpointerup?: MouseEventHandler<SVGPathElement>;
548
- onpointerenter?: MouseEventHandler<SVGPathElement>;
549
- onpointerleave?: MouseEventHandler<SVGPathElement>;
550
- onpointermove?: MouseEventHandler<SVGPathElement>;
551
- onpointerover?: MouseEventHandler<SVGPathElement>;
552
- onpointerout?: MouseEventHandler<SVGPathElement>;
553
- ondrag?: MouseEventHandler<SVGPathElement>;
554
- ondrop?: MouseEventHandler<SVGPathElement>;
555
- ondragstart?: MouseEventHandler<SVGPathElement>;
556
- ondragenter?: MouseEventHandler<SVGPathElement>;
557
- ondragleave?: MouseEventHandler<SVGPathElement>;
558
- ondragover?: MouseEventHandler<SVGPathElement>;
559
- ondragend?: MouseEventHandler<SVGPathElement>;
560
- ontouchstart?: MouseEventHandler<SVGPathElement>;
561
- ontouchmove?: MouseEventHandler<SVGPathElement>;
562
- ontouchend?: MouseEventHandler<SVGPathElement>;
563
- ontouchcancel?: MouseEventHandler<SVGPathElement>;
564
- oncontextmenu?: MouseEventHandler<SVGPathElement>;
565
- onwheel?: MouseEventHandler<SVGPathElement>;
566
- /**
567
- * if you want to give your mark element an extra CSS class
568
- */
569
- class: string | null;
570
- cursor: ConstantAccessor<CSS.Property.Cursor>;
571
- }>;
572
- export type BorderRadius = number | {
573
- topLeft?: number;
574
- topRight?: number;
575
- bottomRight?: number;
576
- bottomLeft?: number;
577
- };
578
- export type BaseRectMarkProps = {
579
- inset?: ConstantAccessor<number>;
580
- insetLeft?: ConstantAccessor<number>;
581
- insetTop?: ConstantAccessor<number>;
582
- insetRight?: ConstantAccessor<number>;
583
- insetBottom?: ConstantAccessor<number>;
584
- borderRadius?: BorderRadius;
585
- };
586
- export type Channels = Record<string, ChannelAccessor | ConstantAccessor<string | number | boolean | symbol>>;
587
- export type TransformArg<K> = Channels & BaseMarkProps & {
588
- data: K[];
589
- };
590
- export type MapArg<K> = Channels & {
591
- data: K[];
592
- };
593
- export type TransformArgsRow = Partial<Channels> & {
594
- data: DataRow[];
595
- };
596
- export type TransformArgsRecord = Partial<Channels> & {
597
- data: DataRecord[];
598
- };
599
- export type ColorScheme = 'brbg' | 'prgn' | 'piyg' | 'puor' | 'rdbu' | 'rdgy' | 'rdylbu' | 'rdylgn' | 'spectral' | 'burd' | 'buylrd' | 'blues' | 'greens' | 'grays' | 'greys' | 'oranges' | 'purples' | 'reds' | 'turbo' | 'viridis' | 'magma' | 'inferno' | 'plasma' | 'cividis' | 'cubehelix' | 'warm' | 'cool' | 'bugn' | 'bupu' | 'gnbu' | 'orrd' | 'pubu' | 'pubugn' | 'purd' | 'rdpu' | 'ylgn' | 'ylgnbu' | 'ylorbr' | 'ylorrd' | 'rainbow' | 'sinebow' | 'accent' | 'category10' | 'dark2' | 'paired' | 'pastel1' | 'pastel2' | 'set1' | 'set2' | 'set3' | 'tableau10' | 'observable10';
600
- export type MarkStyleProps = 'strokeDasharray' | 'strokeLinejoin' | 'strokeLinecap' | 'opacity' | 'cursor' | 'pointerEvents' | 'blend' | 'fill' | 'fillOpacity' | 'fontWeight' | 'fontVariant' | 'fontSize' | 'fontStyle' | 'stroke' | 'strokeWidth' | 'strokeOpacity' | 'x' | 'y' | 'clipPath' | 'mask' | 'filter' | 'angle' | 'radius' | 'symbol' | 'textAnchor' | 'width';
601
- export type AutoMarginStores = {
602
- autoMarginTop: Writable<Map<string, number>>;
603
- autoMarginLeft: Writable<Map<string, number>>;
604
- autoMarginRight: Writable<Map<string, number>>;
605
- autoMarginBottom: Writable<Map<string, number>>;
606
- };
607
- type IgnoreDefaults = 'data' | 'facet' | ChannelName | 'title' | 'automatic' | 'children';
608
- /**
609
- * these are the default options for the plot marks that can be set using
610
- * the 'svelteplot/defaults' context.
611
- */
612
- export type PlotDefaults = {
613
- /**
614
- * default plot height
615
- */
616
- height: number;
617
- /**
618
- * default plot inset
619
- */
620
- inset: number;
621
- /**
622
- * default color scheme
623
- */
624
- colorScheme: ColorScheme;
625
- categoricalColorScheme: ColorScheme | string[];
626
- /**
627
- * fallback color to be used for null/NA
628
- */
629
- unknown: string;
630
- /**
631
- * optional @emotion/css function to style the plot
632
- */
633
- css: (d: string) => string | undefined;
634
- /**
635
- * for computing the automatic height based on the number of
636
- * domain items in a point scale
637
- */
638
- pointScaleHeight: number;
639
- /**
640
- * for computing the automatic height based on the number of
641
- * domain items in a band scale
642
- */
643
- bandScaleHeight: number;
644
- /**
645
- * initial width of the plot before measuring the actual width
646
- */
647
- initialWidth: number;
648
- /**
649
- * locale, used for automatic axis ticks
650
- */
651
- locale: string;
652
- /**
653
- * default number format for axis ticks
654
- */
655
- numberFormat: Intl.NumberFormatOptions;
656
- /**
657
- * default dot radius for line markers, used in dot, circle, and circle-stroke markers
658
- */
659
- markerDotRadius: number;
660
- /**
661
- * default props for area marks, applied to area, areaX, and areaY marks
662
- */
663
- area: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
664
- /**
665
- * default props for areaX marks
666
- */
667
- areaX: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
668
- /**
669
- * default props for areaY marks
670
- */
671
- areaY: Partial<Omit<AreaMarkProps, IgnoreDefaults>>;
672
- /**
673
- * default props for arrow marks
674
- */
675
- arrow: Partial<Omit<ArrowMarkProps, IgnoreDefaults>>;
676
- /**
677
- * default props for axis marks, applied to both axisX and axisY marks
678
- */
679
- axis: Partial<Omit<AxisXMarkProps, 'data' | 'facet' | ChannelName | 'facetAnchor' | 'labelAnchor' | 'anchor'> & {
680
- implicit: boolean;
681
- }>;
682
- /**
683
- * default props for axisX marks
684
- */
685
- axisX: Partial<Omit<AxisXMarkProps, IgnoreDefaults> & {
686
- implicit: boolean;
687
- }>;
688
- /**
689
- * default props for axisY marks
690
- */
691
- axisY: Partial<Omit<AxisYMarkProps, IgnoreDefaults> & {
692
- implicit: boolean;
693
- }>;
694
- /**
695
- * default props for bar marks, applied to both barX and barY marks
696
- */
697
- bar: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
698
- /**
699
- * default props for barX marks
700
- */
701
- barX: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
702
- /**
703
- * default props for barY marks
704
- */
705
- barY: Partial<Omit<BarXMarkProps, IgnoreDefaults>>;
706
- /**
707
- * default props for box marks, applied to boxX and boxY marks
708
- */
709
- box: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
710
- /**
711
- * default props for boxX marks
712
- */
713
- boxX: Partial<Omit<BoxXMarkProps, IgnoreDefaults>>;
714
- /**
715
- * default props for boxY marks
716
- */
717
- boxY: Partial<Omit<BoxYMarkProps, IgnoreDefaults>>;
718
- /**
719
- * default props for brush marks, applied to brush, brushX and brushY marks
720
- */
721
- brush: Partial<Omit<BrushMarkProps, IgnoreDefaults | 'limitDimension'>>;
722
- /**
723
- * default props for brushX marks
724
- */
725
- brushX: Partial<Omit<BrushXMarkProps, IgnoreDefaults>>;
726
- /**
727
- * default props for brushY marks
728
- */
729
- brushY: Partial<Omit<BrushYMarkProps, IgnoreDefaults>>;
730
- /**
731
- * default props for cell marks
732
- */
733
- cell: Partial<Omit<CellMarkProps, IgnoreDefaults>>;
734
- /**
735
- * default props for dot marks
736
- */
737
- dot: Partial<Omit<DotMarkProps, IgnoreDefaults>>;
738
- /**
739
- * default props for frame marks
740
- */
741
- frame: Partial<FrameMarkProps & {
742
- implicit: boolean;
743
- }>;
744
- /**
745
- * default props for geo marks
746
- */
747
- geo: Partial<Omit<GeoMarkProps, IgnoreDefaults>>;
748
- /**
749
- * default props for graticule marks
750
- */
751
- graticule: Partial<Omit<GraticuleMarkProps, IgnoreDefaults>>;
752
- /**
753
- * default props for grid marks, applied to both gridX and gridY marks
754
- */
755
- grid: Partial<Omit<GridXMarkProps, IgnoreDefaults> & {
756
- implicit: boolean;
757
- }>;
758
- /**
759
- * default props for gridX marks
760
- */
761
- gridX: Partial<Omit<GridXMarkProps, IgnoreDefaults> & {
762
- implicit: boolean;
763
- }>;
764
- /**
765
- * default props for gridY marks
766
- */
767
- gridY: Partial<Omit<GridYMarkProps, IgnoreDefaults> & {
768
- implicit: boolean;
769
- }>;
770
- /**
771
- * default props for line marks
772
- */
773
- line: Partial<Omit<LineMarkProps, IgnoreDefaults>>;
774
- /**
775
- * default props for link marks
776
- */
777
- link: Partial<Omit<LinkMarkProps, IgnoreDefaults>>;
778
- /**
779
- * default props for pointer marks
780
- */
781
- pointer: Partial<Omit<PointerMarkProps, IgnoreDefaults>>;
782
- /**
783
- * default props for rect marks, applied to rect and rectX marks
784
- */
785
- rect: Partial<Omit<RectMarkProps, IgnoreDefaults>>;
786
- /**
787
- * default props for rectX marks
788
- */
789
- rectX: Partial<Omit<RectXMarkProps, IgnoreDefaults>>;
790
- /**
791
- * default props for rectY marks
792
- */
793
- rectY: Partial<Omit<RectYMarkProps, IgnoreDefaults>>;
794
- /**
795
- * default props for rule marks
796
- */
797
- rule: Partial<Omit<RuleXMarkProps, IgnoreDefaults>>;
798
- /**
799
- * default props for rule marks
800
- */
801
- ruleX: Partial<Omit<RuleXMarkProps, IgnoreDefaults>>;
802
- /**
803
- * default props for rule marks
804
- */
805
- ruleY: Partial<Omit<RuleYMarkProps, IgnoreDefaults>>;
806
- /**
807
- * default props for sphere marks
808
- */
809
- sphere: Partial<SphereMarkProps>;
810
- /**
811
- * default props for spike marks
812
- */
813
- spike: Partial<Omit<SpikeMarkProps, IgnoreDefaults>>;
814
- /**
815
- * default props for text marks
816
- */
817
- text: Partial<Omit<TextMarkProps, IgnoreDefaults>>;
818
- /**
819
- * default props for tick marks, applied to tickX and tickY marks
820
- */
821
- tick: Partial<Omit<TickXMarkProps, IgnoreDefaults>>;
822
- /**
823
- * default props for tickX marks
824
- */
825
- tickX: Partial<Omit<TickXMarkProps, IgnoreDefaults>>;
826
- /**
827
- * default props for tickY marks
828
- */
829
- tickY: Partial<Omit<TickYMarkProps, IgnoreDefaults>>;
830
- /**
831
- * default props for vector marks
832
- */
833
- vector: Partial<Omit<VectorMarkProps, IgnoreDefaults>>;
834
- };
835
- export type MapIndexObject = {
836
- mapIndex: (I: number[], S: RawValue[], T: RawValue[]) => void;
837
- };
838
- export type MapMethod = 'cumsum' | 'rank' | 'quantile' | ((I: number[], S: number[]) => number[]) | MapIndexObject;
839
- export type MapOptions = Partial<Record<ScaledChannelName, MapMethod>>;
840
- export type UsedScales = Record<ScaledChannelName, boolean>;
841
- export {};