svelteplot 0.10.3 → 0.11.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 (222) hide show
  1. package/dist/Mark.svelte +42 -25
  2. package/dist/Mark.svelte.d.ts +111 -32
  3. package/dist/Plot.svelte +21 -15
  4. package/dist/core/Facet.svelte +1 -1
  5. package/dist/core/FacetAxes.svelte +13 -8
  6. package/dist/core/FacetGrid.svelte +4 -4
  7. package/dist/core/Plot.svelte +41 -35
  8. package/dist/helpers/autoScales.d.ts +3 -3
  9. package/dist/helpers/autoScales.js +28 -18
  10. package/dist/helpers/autoTicks.js +2 -0
  11. package/dist/helpers/callWithProps.d.ts +1 -2
  12. package/dist/helpers/facets.js +0 -1
  13. package/dist/helpers/index.js +1 -1
  14. package/dist/helpers/mergeDeep.d.ts +1 -3
  15. package/dist/helpers/mergeDeep.js +15 -16
  16. package/dist/helpers/projection.d.ts +4 -3
  17. package/dist/helpers/projection.js +17 -5
  18. package/dist/helpers/reduce.d.ts +4 -4
  19. package/dist/helpers/reduce.js +6 -4
  20. package/dist/helpers/regressionLoess.js +2 -1
  21. package/dist/helpers/resolve.d.ts +6 -3
  22. package/dist/helpers/resolve.js +25 -16
  23. package/dist/helpers/scales.d.ts +10 -10
  24. package/dist/helpers/scales.js +43 -13
  25. package/dist/helpers/time.d.ts +10 -3
  26. package/dist/helpers/time.js +2 -1
  27. package/dist/hooks/index.d.ts +2 -0
  28. package/dist/hooks/index.js +2 -0
  29. package/dist/hooks/plotDefaults.d.ts +3 -1
  30. package/dist/hooks/plotDefaults.js +33 -1
  31. package/dist/hooks/usePlot.svelte.d.ts +10 -25
  32. package/dist/hooks/usePlot.svelte.js +8 -7
  33. package/dist/index.d.ts +1 -2
  34. package/dist/index.js +1 -3
  35. package/dist/marks/Area.svelte +24 -13
  36. package/dist/marks/Area.svelte.d.ts +118 -34
  37. package/dist/marks/AreaX.svelte +42 -8
  38. package/dist/marks/AreaX.svelte.d.ts +154 -71
  39. package/dist/marks/AreaY.svelte +42 -8
  40. package/dist/marks/AreaY.svelte.d.ts +154 -71
  41. package/dist/marks/Arrow.svelte +42 -23
  42. package/dist/marks/Arrow.svelte.d.ts +114 -35
  43. package/dist/marks/AxisX.svelte +43 -28
  44. package/dist/marks/AxisX.svelte.d.ts +125 -40
  45. package/dist/marks/AxisY.svelte +43 -26
  46. package/dist/marks/AxisY.svelte.d.ts +127 -40
  47. package/dist/marks/BarX.svelte +12 -10
  48. package/dist/marks/BarX.svelte.d.ts +104 -32
  49. package/dist/marks/BarY.svelte +11 -10
  50. package/dist/marks/BarY.svelte.d.ts +106 -34
  51. package/dist/marks/BollingerX.svelte +4 -7
  52. package/dist/marks/BollingerX.svelte.d.ts +105 -30
  53. package/dist/marks/BollingerY.svelte +3 -0
  54. package/dist/marks/BollingerY.svelte.d.ts +105 -30
  55. package/dist/marks/BoxX.svelte +3 -3
  56. package/dist/marks/BoxY.svelte +12 -9
  57. package/dist/marks/BoxY.svelte.d.ts +128 -53
  58. package/dist/marks/Brush.svelte +26 -21
  59. package/dist/marks/Brush.svelte.d.ts +119 -60
  60. package/dist/marks/Cell.svelte +13 -9
  61. package/dist/marks/Cell.svelte.d.ts +105 -30
  62. package/dist/marks/CellX.svelte +2 -1
  63. package/dist/marks/CellX.svelte.d.ts +105 -32
  64. package/dist/marks/CellY.svelte +2 -1
  65. package/dist/marks/CellY.svelte.d.ts +105 -32
  66. package/dist/marks/ColorLegend.svelte +24 -13
  67. package/dist/marks/ColorLegend.svelte.d.ts +1 -0
  68. package/dist/marks/CustomMark.svelte +16 -10
  69. package/dist/marks/CustomMark.svelte.d.ts +112 -31
  70. package/dist/marks/CustomMarkHTML.svelte +8 -2
  71. package/dist/marks/CustomMarkHTML.svelte.d.ts +8 -2
  72. package/dist/marks/DifferenceY.svelte +31 -20
  73. package/dist/marks/DifferenceY.svelte.d.ts +134 -55
  74. package/dist/marks/Dot.svelte +21 -11
  75. package/dist/marks/Dot.svelte.d.ts +117 -38
  76. package/dist/marks/DotX.svelte +2 -0
  77. package/dist/marks/DotX.svelte.d.ts +136 -62
  78. package/dist/marks/DotY.svelte +1 -0
  79. package/dist/marks/DotY.svelte.d.ts +135 -62
  80. package/dist/marks/Frame.svelte +47 -9
  81. package/dist/marks/Frame.svelte.d.ts +124 -41
  82. package/dist/marks/Geo.svelte +21 -12
  83. package/dist/marks/Geo.svelte.d.ts +105 -30
  84. package/dist/marks/Graticule.svelte +3 -0
  85. package/dist/marks/Graticule.svelte.d.ts +3 -0
  86. package/dist/marks/GridX.svelte +31 -16
  87. package/dist/marks/GridX.svelte.d.ts +108 -32
  88. package/dist/marks/GridY.svelte +30 -15
  89. package/dist/marks/GridY.svelte.d.ts +108 -32
  90. package/dist/marks/HTMLTooltip.svelte +14 -7
  91. package/dist/marks/HTMLTooltip.svelte.d.ts +7 -0
  92. package/dist/marks/Image.svelte +50 -25
  93. package/dist/marks/Image.svelte.d.ts +117 -35
  94. package/dist/marks/Line.svelte +67 -44
  95. package/dist/marks/Line.svelte.d.ts +119 -30
  96. package/dist/marks/LineX.svelte +2 -1
  97. package/dist/marks/LineX.svelte.d.ts +142 -69
  98. package/dist/marks/LineY.svelte +2 -1
  99. package/dist/marks/LineY.svelte.d.ts +142 -69
  100. package/dist/marks/Link.svelte +70 -46
  101. package/dist/marks/Link.svelte.d.ts +126 -41
  102. package/dist/marks/Pointer.svelte +24 -15
  103. package/dist/marks/Pointer.svelte.d.ts +7 -0
  104. package/dist/marks/Rect.svelte +13 -5
  105. package/dist/marks/Rect.svelte.d.ts +116 -35
  106. package/dist/marks/RectX.svelte +6 -3
  107. package/dist/marks/RectX.svelte.d.ts +158 -12
  108. package/dist/marks/RectY.svelte +6 -3
  109. package/dist/marks/RectY.svelte.d.ts +158 -12
  110. package/dist/marks/RegressionX.svelte +13 -6
  111. package/dist/marks/RegressionX.svelte.d.ts +8 -3
  112. package/dist/marks/RegressionY.svelte +13 -6
  113. package/dist/marks/RegressionY.svelte.d.ts +8 -3
  114. package/dist/marks/RuleX.svelte +18 -11
  115. package/dist/marks/RuleX.svelte.d.ts +112 -32
  116. package/dist/marks/RuleY.svelte +19 -12
  117. package/dist/marks/RuleY.svelte.d.ts +114 -34
  118. package/dist/marks/Spike.svelte +11 -5
  119. package/dist/marks/Spike.svelte.d.ts +146 -68
  120. package/dist/marks/Text.svelte +24 -7
  121. package/dist/marks/Text.svelte.d.ts +253 -75
  122. package/dist/marks/TickX.svelte +56 -48
  123. package/dist/marks/TickX.svelte.d.ts +114 -40
  124. package/dist/marks/TickY.svelte +59 -51
  125. package/dist/marks/TickY.svelte.d.ts +117 -43
  126. package/dist/marks/Trail.svelte +25 -13
  127. package/dist/marks/Trail.svelte.d.ts +116 -33
  128. package/dist/marks/Vector.svelte +20 -11
  129. package/dist/marks/Vector.svelte.d.ts +116 -35
  130. package/dist/marks/WaffleX.svelte +18 -16
  131. package/dist/marks/WaffleX.svelte.d.ts +131 -57
  132. package/dist/marks/WaffleY.svelte +16 -15
  133. package/dist/marks/WaffleY.svelte.d.ts +129 -56
  134. package/dist/marks/helpers/Anchor.svelte +17 -2
  135. package/dist/marks/helpers/Anchor.svelte.d.ts +16 -1
  136. package/dist/marks/helpers/AreaCanvas.svelte +8 -8
  137. package/dist/marks/helpers/BaseAxisX.svelte +38 -41
  138. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +11 -17
  139. package/dist/marks/helpers/BaseAxisY.svelte +35 -35
  140. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +12 -15
  141. package/dist/marks/helpers/Box.svelte +35 -28
  142. package/dist/marks/helpers/Box.svelte.d.ts +122 -50
  143. package/dist/marks/helpers/DotCanvas.svelte +11 -9
  144. package/dist/marks/helpers/GeoCanvas.svelte +7 -6
  145. package/dist/marks/helpers/LineCanvas.svelte +7 -7
  146. package/dist/marks/helpers/LinearGradientX.svelte +2 -2
  147. package/dist/marks/helpers/LinearGradientX.svelte.d.ts +1 -1
  148. package/dist/marks/helpers/LinearGradientY.svelte +2 -2
  149. package/dist/marks/helpers/LinearGradientY.svelte.d.ts +1 -1
  150. package/dist/marks/helpers/Marker.svelte +2 -2
  151. package/dist/marks/helpers/MarkerPath.svelte +15 -12
  152. package/dist/marks/helpers/MarkerPath.svelte.d.ts +105 -32
  153. package/dist/marks/helpers/MultilineText.svelte +24 -17
  154. package/dist/marks/helpers/MultilineText.svelte.d.ts +1 -1
  155. package/dist/marks/helpers/RectCanvas.svelte +31 -26
  156. package/dist/marks/helpers/RectPath.svelte +2 -2
  157. package/dist/marks/helpers/Regression.svelte +176 -86
  158. package/dist/marks/helpers/Regression.svelte.d.ts +20 -8
  159. package/dist/marks/helpers/RuleCanvas.svelte +9 -6
  160. package/dist/marks/helpers/TextCanvas.svelte +13 -9
  161. package/dist/marks/helpers/TextCanvas.svelte.d.ts +6 -6
  162. package/dist/marks/helpers/TickCanvas.svelte +6 -5
  163. package/dist/marks/helpers/TrailCanvas.svelte +16 -18
  164. package/dist/marks/helpers/TrailCanvas.svelte.d.ts +3 -5
  165. package/dist/marks/helpers/canvas.js +16 -9
  166. package/dist/marks/helpers/events.d.ts +2 -2
  167. package/dist/marks/helpers/events.js +14 -7
  168. package/dist/marks/helpers/waffle.d.ts +3 -3
  169. package/dist/marks/helpers/waffle.js +6 -4
  170. package/dist/regression/polynomial.d.ts +1 -1
  171. package/dist/regression/polynomial.js +5 -5
  172. package/dist/regression/utils/determination.d.ts +1 -1
  173. package/dist/regression/utils/determination.js +1 -1
  174. package/dist/regression/utils/geometry.d.ts +1 -1
  175. package/dist/regression/utils/interpose.d.ts +1 -1
  176. package/dist/regression/utils/interpose.js +1 -1
  177. package/dist/regression/utils/points.d.ts +1 -1
  178. package/dist/transforms/bin.d.ts +3 -3
  179. package/dist/transforms/bin.js +29 -20
  180. package/dist/transforms/bollinger.d.ts +8 -0
  181. package/dist/transforms/bollinger.js +9 -1
  182. package/dist/transforms/centroid.d.ts +4 -0
  183. package/dist/transforms/centroid.js +4 -0
  184. package/dist/transforms/density.d.ts +4 -4
  185. package/dist/transforms/density.js +20 -13
  186. package/dist/transforms/dodge.d.ts +12 -1
  187. package/dist/transforms/dodge.js +15 -6
  188. package/dist/transforms/group.d.ts +141 -4
  189. package/dist/transforms/group.js +4 -1
  190. package/dist/transforms/interval.d.ts +204 -60
  191. package/dist/transforms/jitter.d.ts +421 -4
  192. package/dist/transforms/jitter.js +10 -1
  193. package/dist/transforms/map.d.ts +412 -4
  194. package/dist/transforms/map.js +3 -3
  195. package/dist/transforms/normalize.d.ts +276 -5
  196. package/dist/transforms/normalize.js +5 -3
  197. package/dist/transforms/recordize.d.ts +17 -5
  198. package/dist/transforms/recordize.js +13 -9
  199. package/dist/transforms/rename.d.ts +11 -4
  200. package/dist/transforms/rename.js +7 -2
  201. package/dist/transforms/select.d.ts +722 -210
  202. package/dist/transforms/select.js +13 -1
  203. package/dist/transforms/shift.d.ts +8 -0
  204. package/dist/transforms/shift.js +20 -6
  205. package/dist/transforms/sort.d.ts +13 -258
  206. package/dist/transforms/sort.js +13 -10
  207. package/dist/transforms/stack.d.ts +58 -9
  208. package/dist/transforms/stack.js +27 -11
  209. package/dist/transforms/window.d.ts +221 -66
  210. package/dist/transforms/window.js +8 -2
  211. package/dist/types/axes.d.ts +43 -0
  212. package/dist/types/axes.js +1 -0
  213. package/dist/types/channel.d.ts +30 -2
  214. package/dist/types/data.d.ts +14 -1
  215. package/dist/types/facet.d.ts +5 -0
  216. package/dist/types/index.d.ts +33 -8
  217. package/dist/types/index.js +11 -7
  218. package/dist/types/mark.d.ts +124 -35
  219. package/dist/types/plot.d.ts +118 -16
  220. package/dist/types/scale.d.ts +125 -8
  221. package/package.json +178 -175
  222. package/dist/helpers/autoTicks.d.ts +0 -12
package/dist/Mark.svelte CHANGED
@@ -9,7 +9,14 @@
9
9
  children?: Snippet<
10
10
  [
11
11
  {
12
- mark: Mark<GenericMarkOptions>;
12
+ mark: {
13
+ id: symbol;
14
+ type: MarkType;
15
+ channels: ScaledChannelName[];
16
+ scales: Set<ScaleName>;
17
+ data: DataRecord[];
18
+ options: GenericMarkOptions;
19
+ };
13
20
  usedScales: ReturnType<typeof getUsedScales>;
14
21
  scaledData: ScaledDataRecord<Datum>[];
15
22
  }
@@ -121,7 +128,7 @@
121
128
  mark.channels = channels;
122
129
  mark.scales = new Set(
123
130
  channels
124
- .filter((channel) => options[channel] !== 0)
131
+ .filter((channel) => (options as any)[channel] !== 0)
125
132
  .map((channel) => CHANNEL_SCALE[channel])
126
133
  );
127
134
  mark.data = untrack(() => data);
@@ -149,10 +156,10 @@
149
156
  ScaleName
150
157
  ][]) {
151
158
  // check if the mark has defined an accessor for this channel
152
- if (options?.[channel] !== undefined && out[channel] === undefined) {
159
+ if ((options as any)?.[channel] !== undefined && out[channel] === undefined) {
153
160
  // resolve value
154
- out[channel] = resolveChannel(channel, row, options, index);
155
- if (options[channel] === INDEX) {
161
+ out[channel] = resolveChannel(channel, row, options as any);
162
+ if ((options as any)[channel] === INDEX) {
156
163
  const scale = plot.scales[CHANNEL_SCALE[channel]];
157
164
  if (scale.type === 'band' || scale.type === 'point') {
158
165
  out[channel] = scale.domain[out[channel] % scale.domain.length];
@@ -167,7 +174,13 @@
167
174
  let prevResolvedData: ResolvedDataRecord[] = [];
168
175
 
169
176
  $effect(() => {
170
- if (isDifferent(data, mark.data) || isDifferent(resolvedData, prevResolvedData)) {
177
+ if (
178
+ isDifferent(
179
+ data as unknown as ResolvedDataRecord[],
180
+ mark.data as unknown as ResolvedDataRecord[]
181
+ ) ||
182
+ isDifferent(resolvedData, prevResolvedData)
183
+ ) {
171
184
  prevResolvedData = resolvedData;
172
185
  // data has changed
173
186
  mark.data = data;
@@ -191,11 +204,11 @@
191
204
 
192
205
  const errors = $derived([
193
206
  ...required
194
- .filter((name) => options[name] == null)
207
+ .filter((name) => (options as any)[name] == null)
195
208
  .map((name) => `missing channel value for ${mark.type} mark: ${name}`),
196
209
  ...Object.entries(requiredScales)
197
210
  .filter(([scale, types]) => {
198
- return !types.includes(plot.scales[scale].type);
211
+ return !types.includes((plot.scales as any)[scale].type);
199
212
  })
200
213
  .map(
201
214
  ([scale, types]) => `scale type mismatch for ${scale} (needs ${types.join(' or ')})`
@@ -204,7 +217,7 @@
204
217
 
205
218
  $effect(() => {
206
219
  for (const name of required) {
207
- if (options[name] == null) throw new Error(`missing channel value: ${name}`);
220
+ if ((options as any)[name] == null) throw new Error(`missing channel value: ${name}`);
208
221
  }
209
222
  });
210
223
 
@@ -219,19 +232,21 @@
219
232
  const out: ScaledDataRecord<Datum> = {
220
233
  datum: row.datum,
221
234
  resolved: row,
222
- index: row[INDEX],
223
- valid: true
235
+ index: (row as any)[INDEX],
236
+ valid: true,
237
+ dx: 0,
238
+ dy: 0
224
239
  };
225
240
  // compute dx/dy
226
- out.dx = Number(resolveProp<number>(options.dx, out.datum, 0));
227
- out.dy = Number(resolveProp<number>(options.dy, out.datum, 0));
241
+ out.dx = Number(resolveProp<number, Datum>(options.dx, out.datum, 0));
242
+ out.dy = Number(resolveProp<number, Datum>(options.dy, out.datum, 0));
228
243
 
229
244
  // special handling if there's a projection, e.g. a line mark
230
245
  if (plot.scales.projection && mark.type !== 'geo') {
231
246
  for (const suffix of ['', '1', '2']) {
232
247
  if (
233
- options?.[`x${suffix}`] !== undefined &&
234
- options?.[`y${suffix}`] !== undefined
248
+ (options as any)?.[`x${suffix}`] !== undefined &&
249
+ (options as any)?.[`y${suffix}`] !== undefined
235
250
  ) {
236
251
  // we have two-dimensional accessors
237
252
  // for the x and y channels
@@ -243,12 +258,11 @@
243
258
  row.x,
244
259
  row.y,
245
260
  usedScales.x,
246
- usedScales.y,
247
- suffix
261
+ usedScales.y
248
262
  );
249
263
 
250
- out[`x${suffix}`] = x;
251
- out[`y${suffix}`] = y;
264
+ (out as any)[`x${suffix}`] = x;
265
+ (out as any)[`y${suffix}`] = y;
252
266
  out.valid =
253
267
  out.valid &&
254
268
  isValid(row.x) &&
@@ -265,11 +279,14 @@
265
279
  ScaleName
266
280
  ][]) {
267
281
  // check if the mark has defined an accessor for this channel
268
- if (options?.[channel] != null && out[channel] === undefined) {
282
+ if (
283
+ (options as any)?.[channel] != null &&
284
+ (out as any)[channel] === undefined
285
+ ) {
269
286
  // resolve value
270
287
  const value = row[channel];
271
288
  // if this channel was renamed, use the original channel for scaling
272
- const origChannel = options?.[RENAME]?.[channel] || channel;
289
+ const origChannel = (options as any)?.[RENAME]?.[channel] || channel;
273
290
  const scaled = usedScales[channel]
274
291
  ? scale === 'x'
275
292
  ? projectX(origChannel as 'x' | 'x1' | 'x2', plot.scales, value)
@@ -283,12 +300,12 @@
283
300
  out.valid = out.valid && (scale === 'color' || isValid(value));
284
301
 
285
302
  // apply dx/dy transform
286
- out[channel] =
303
+ (out as any)[channel] =
287
304
  Number.isFinite(scaled) && (scale === 'x' || scale === 'y')
288
305
  ? scaled + (scale === 'x' ? out.dx : out.dy)
289
306
  : scaled;
290
307
  } else if (defaults[channel]) {
291
- out[channel] = defaults[channel];
308
+ (out as any)[channel] = defaults[channel];
292
309
  }
293
310
  }
294
311
 
@@ -300,10 +317,10 @@
300
317
 
301
318
  function dodge<T>(data: ScaledDataRecord<Datum>[], options: BaseMarkProps<T>) {
302
319
  if (options.dodgeX) {
303
- return dodgeX({ data, ...options }, plot);
320
+ return dodgeX({ data, ...options } as any, plot) as ScaledDataRecord<Datum>[];
304
321
  }
305
322
  if (options.dodgeY) {
306
- return dodgeY({ data, ...options }, plot);
323
+ return dodgeY({ data, ...options } as any, plot) as ScaledDataRecord<Datum>[];
307
324
  }
308
325
  return data;
309
326
  }
@@ -1,5 +1,5 @@
1
1
  import { type Snippet } from 'svelte';
2
- import type { ScaledChannelName, MarkType, DataRecord, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
2
+ import type { ScaledChannelName, MarkType, DataRecord, GenericMarkOptions, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
3
3
  import { getUsedScales } from './helpers/scales.js';
4
4
  declare function $$render<Datum extends DataRecord>(): {
5
5
  props: Partial<Partial<{
@@ -13,6 +13,16 @@ declare function $$render<Datum extends DataRecord>(): {
13
13
  dodgeY: import("./transforms/dodge.js").DodgeYOptions;
14
14
  fill: ChannelAccessor<Datum>;
15
15
  fillOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
16
+ fontFamily: import("./types/index.js").ConstantAccessor<import("csstype").Property.FontFamily, Datum>;
17
+ fontSize: import("./types/index.js").ConstantAccessor<number | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "math" | (string & {}) | "large" | "medium" | "small" | "x-large" | "x-small" | "xx-large" | "xx-small" | "xxx-large" | "larger" | "smaller", Datum>;
18
+ fontStyle: import("./types/index.js").ConstantAccessor<import("csstype").Property.FontStyle, Datum>;
19
+ fontVariant: import("./types/index.js").ConstantAccessor<import("csstype").Property.FontVariant, Datum>;
20
+ fontWeight: import("./types/index.js").ConstantAccessor<import("csstype").Property.FontWeight, Datum>;
21
+ letterSpacing: import("./types/index.js").ConstantAccessor<import("csstype").Property.LetterSpacing<0 | (string & {})>, Datum>;
22
+ wordSpacing: import("./types/index.js").ConstantAccessor<import("csstype").Property.WordSpacing<0 | (string & {})>, Datum>;
23
+ textAnchor: import("./types/index.js").ConstantAccessor<import("csstype").Property.TextAnchor, Datum>;
24
+ textTransform: import("./types/index.js").ConstantAccessor<import("csstype").Property.TextTransform, Datum>;
25
+ textDecoration: import("./types/index.js").ConstantAccessor<import("csstype").Property.TextDecoration<0 | (string & {})>, Datum>;
16
26
  sort: ((a: RawValue, b: RawValue) => number) | {
17
27
  channel: string;
18
28
  order?: "ascending" | "descending";
@@ -26,45 +36,107 @@ declare function $$render<Datum extends DataRecord>(): {
26
36
  opacity: ChannelAccessor<Datum>;
27
37
  strokeDasharray: import("./types/index.js").ConstantAccessor<string, Datum>;
28
38
  strokeDashoffset: import("./types/index.js").ConstantAccessor<number, Datum>;
39
+ blend: import("./types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
29
40
  mixBlendMode: import("./types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
30
41
  clipPath: string;
31
42
  mask: string;
32
43
  imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
33
44
  shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
34
45
  paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
35
- onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
- ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
- ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
- ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
- ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
- ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
63
- oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
64
- onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
+ onclick: (event: Event & {
47
+ currentTarget: SVGPathElement;
48
+ }, datum: Datum, index: number) => void;
49
+ ondblclick: (event: Event & {
50
+ currentTarget: SVGPathElement;
51
+ }, datum: Datum, index: number) => void;
52
+ onmouseup: (event: Event & {
53
+ currentTarget: SVGPathElement;
54
+ }, datum: Datum, index: number) => void;
55
+ onmousedown: (event: Event & {
56
+ currentTarget: SVGPathElement;
57
+ }, datum: Datum, index: number) => void;
58
+ onmouseenter: (event: Event & {
59
+ currentTarget: SVGPathElement;
60
+ }, datum: Datum, index: number) => void;
61
+ onmousemove: (event: Event & {
62
+ currentTarget: SVGPathElement;
63
+ }, datum: Datum, index: number) => void;
64
+ onmouseleave: (event: Event & {
65
+ currentTarget: SVGPathElement;
66
+ }, datum: Datum, index: number) => void;
67
+ onmouseout: (event: Event & {
68
+ currentTarget: SVGPathElement;
69
+ }, datum: Datum, index: number) => void;
70
+ onmouseover: (event: Event & {
71
+ currentTarget: SVGPathElement;
72
+ }, datum: Datum, index: number) => void;
73
+ onpointercancel: (event: Event & {
74
+ currentTarget: SVGPathElement;
75
+ }, datum: Datum, index: number) => void;
76
+ onpointerdown: (event: Event & {
77
+ currentTarget: SVGPathElement;
78
+ }, datum: Datum, index: number) => void;
79
+ onpointerup: (event: Event & {
80
+ currentTarget: SVGPathElement;
81
+ }, datum: Datum, index: number) => void;
82
+ onpointerenter: (event: Event & {
83
+ currentTarget: SVGPathElement;
84
+ }, datum: Datum, index: number) => void;
85
+ onpointerleave: (event: Event & {
86
+ currentTarget: SVGPathElement;
87
+ }, datum: Datum, index: number) => void;
88
+ onpointermove: (event: Event & {
89
+ currentTarget: SVGPathElement;
90
+ }, datum: Datum, index: number) => void;
91
+ onpointerover: (event: Event & {
92
+ currentTarget: SVGPathElement;
93
+ }, datum: Datum, index: number) => void;
94
+ onpointerout: (event: Event & {
95
+ currentTarget: SVGPathElement;
96
+ }, datum: Datum, index: number) => void;
97
+ ondrag: (event: Event & {
98
+ currentTarget: SVGPathElement;
99
+ }, datum: Datum, index: number) => void;
100
+ ondrop: (event: Event & {
101
+ currentTarget: SVGPathElement;
102
+ }, datum: Datum, index: number) => void;
103
+ ondragstart: (event: Event & {
104
+ currentTarget: SVGPathElement;
105
+ }, datum: Datum, index: number) => void;
106
+ ondragenter: (event: Event & {
107
+ currentTarget: SVGPathElement;
108
+ }, datum: Datum, index: number) => void;
109
+ ondragleave: (event: Event & {
110
+ currentTarget: SVGPathElement;
111
+ }, datum: Datum, index: number) => void;
112
+ ondragover: (event: Event & {
113
+ currentTarget: SVGPathElement;
114
+ }, datum: Datum, index: number) => void;
115
+ ondragend: (event: Event & {
116
+ currentTarget: SVGPathElement;
117
+ }, datum: Datum, index: number) => void;
118
+ ontouchstart: (event: Event & {
119
+ currentTarget: SVGPathElement;
120
+ }, datum: Datum, index: number) => void;
121
+ ontouchmove: (event: Event & {
122
+ currentTarget: SVGPathElement;
123
+ }, datum: Datum, index: number) => void;
124
+ ontouchend: (event: Event & {
125
+ currentTarget: SVGPathElement;
126
+ }, datum: Datum, index: number) => void;
127
+ ontouchcancel: (event: Event & {
128
+ currentTarget: SVGPathElement;
129
+ }, datum: Datum, index: number) => void;
130
+ oncontextmenu: (event: Event & {
131
+ currentTarget: SVGPathElement;
132
+ }, datum: Datum, index: number) => void;
133
+ onwheel: (event: Event & {
134
+ currentTarget: SVGPathElement;
135
+ }, datum: Datum, index: number) => void;
65
136
  class: string;
66
137
  style: string;
67
138
  cursor: import("./types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
139
+ title: import("./types/index.js").ConstantAccessor<string, Datum>;
68
140
  }>> & {
69
141
  data?: Datum[];
70
142
  automatic?: boolean;
@@ -73,7 +145,14 @@ declare function $$render<Datum extends DataRecord>(): {
73
145
  required?: ScaledChannelName[];
74
146
  requiredScales?: Partial<Record<ScaleName, ScaleType[]>>;
75
147
  children?: Snippet<[{
76
- mark: any;
148
+ mark: {
149
+ id: symbol;
150
+ type: MarkType;
151
+ channels: ScaledChannelName[];
152
+ scales: Set<ScaleName>;
153
+ data: DataRecord[];
154
+ options: GenericMarkOptions;
155
+ };
77
156
  usedScales: ReturnType<typeof getUsedScales>;
78
157
  scaledData: ScaledDataRecord<Datum>[];
79
158
  }]>;
package/dist/Plot.svelte CHANGED
@@ -45,16 +45,16 @@
45
45
  if (
46
46
  projection &&
47
47
  typeof projection !== 'function' &&
48
- typeof projection?.type !== 'function'
48
+ typeof (projection as any)?.type !== 'function'
49
49
  ) {
50
50
  const { type: projFactory, aspectRatio } = namedProjection(
51
- isObject(projection) ? projection.type : projection
52
- );
51
+ isObject(projection) ? (projection as any).type : (projection as string)
52
+ ) as { type: any; aspectRatio: number };
53
53
  return {
54
54
  ...(isObject(projection) ? projection : {}),
55
55
  type: projFactory,
56
56
  aspectRatio
57
- };
57
+ } as any;
58
58
  }
59
59
  return projection;
60
60
  });
@@ -62,8 +62,9 @@
62
62
  const scales = $derived(
63
63
  Object.fromEntries(
64
64
  ['x', 'y', 'r', 'color', 'opacity', 'symbol', 'length', 'fx', 'fy'].map((scale) => {
65
- const scaleOpts = maybeScaleOptions(restOptions[scale]);
66
- const scaleFn = scaleOpts.scale || (scale === 'color' ? autoScaleColor : autoScale);
65
+ const scaleOpts = maybeScaleOptions((restOptions as any)[scale]);
66
+ const scaleFn =
67
+ (scaleOpts as any)?.scale || (scale === 'color' ? autoScaleColor : autoScale);
67
68
  return [scale, { ...scaleOpts, scale: scaleFn }];
68
69
  })
69
70
  )
@@ -72,9 +73,9 @@
72
73
  function maybeScaleOptions(
73
74
  scaleOptions: undefined | false | RawValue[] | object
74
75
  ): Partial<ScaleOptions> | undefined {
75
- if (scaleOptions === false) return { axis: false };
76
+ if (scaleOptions === false) return { axis: false } as any;
76
77
  if (Array.isArray(scaleOptions)) return { domain: scaleOptions };
77
- return scaleOptions || {};
78
+ return (scaleOptions as any) || {};
78
79
  }
79
80
  </script>
80
81
 
@@ -84,7 +85,7 @@
84
85
  <!-- also pass on user header -->
85
86
  {#if userHeader}{@render userHeader?.()}{/if}
86
87
  {#if restOptions.color?.legend}
87
- <ColorLegend />
88
+ <ColorLegend class={null} />
88
89
  {/if}
89
90
  {#if restOptions.symbol?.legend}
90
91
  <SymbolLegend />
@@ -110,8 +111,8 @@
110
111
  restOptions.color?.legend ||
111
112
  restOptions.symbol?.legend
112
113
  ? header
113
- : null}
114
- footer={userFooter || restOptions?.caption ? footer : null}
114
+ : undefined}
115
+ footer={userFooter || restOptions?.caption ? footer : undefined}
115
116
  projection={projectionOpts}
116
117
  implicitScales
117
118
  {...scales}>
@@ -157,11 +158,16 @@
157
158
  {@render parentChildren?.({
158
159
  options,
159
160
  scales,
161
+ hasProjection,
162
+ hasExplicitAxisX,
163
+ hasExplicitAxisY,
164
+ hasExplicitGridX,
165
+ hasExplicitGridY,
160
166
  ...restProps
161
167
  })}
162
- {#snippet failed(error, reset)}
168
+ {#snippet failed(error: unknown, reset: () => void)}
163
169
  <text class="error" transform="translate(10,10)">
164
- {#each error.message.split('\n') as line, i (i)}
170
+ {#each (error as Error).message.split('\n') as line, i (i)}
165
171
  <tspan x="0" dy={i ? 14 : 0}>{line}</tspan>
166
172
  {/each}
167
173
  </text>{/snippet}
@@ -171,8 +177,8 @@
171
177
  <FacetAxes />
172
178
  {/snippet}
173
179
  </Plot>
174
- {#snippet failed(error)}
175
- <div class="error">Error: {error.message}</div>
180
+ {#snippet failed(error: unknown)}
181
+ <div class="error">Error: {(error as Error).message}</div>
176
182
  {/snippet}
177
183
  </svelte:boundary>
178
184
 
@@ -31,7 +31,7 @@
31
31
 
32
32
  setContext('svelteplot/facet', {
33
33
  getTestFacet() {
34
- return (datum: DataRecord, options: Partial<BaseMarkProps>) => {
34
+ return (datum: DataRecord, options: Partial<BaseMarkProps<DataRecord>>) => {
35
35
  return (
36
36
  (options.fx == null || resolveChannel('fx', datum, options) === fx) &&
37
37
  (options.fy == null || resolveChannel('fy', datum, options) === fy)
@@ -23,13 +23,13 @@
23
23
  const facetXScale = $derived(
24
24
  scaleBand()
25
25
  .paddingInner(plot.options.fx?.paddingInner ?? plot.options.fx?.padding ?? 0.1)
26
- .domain(fxValues)
26
+ .domain(fxValues as string[])
27
27
  .rangeRound([0, plot.plotWidth])
28
28
  );
29
29
  const facetYScale = $derived(
30
30
  scaleBand()
31
31
  .paddingInner(plot.options.fy?.paddingInner ?? plot.options.fy?.padding ?? 0.1)
32
- .domain(fyValues)
32
+ .domain(fyValues as string[])
33
33
  .rangeRound([0, plot.plotHeight])
34
34
  );
35
35
  </script>
@@ -39,17 +39,20 @@
39
39
  <g transform="translate({plot.options.marginLeft}, 0)">
40
40
  <BaseAxisX
41
41
  class="facet-axis-x"
42
- scaleFn={facetXScale}
42
+ scaleFn={facetXScale as any}
43
43
  scaleType="band"
44
44
  ticks={fxValues}
45
- tickFormat={plot.options.fx.tickFormat || ((d) => d)}
45
+ tickFormat={(plot.options.fx.tickFormat || ((d: any) => d)) as any}
46
46
  tickFontSize={11}
47
47
  tickSize={0}
48
48
  tickPadding={plot.options.x.axis === plot.options.fx.axis ||
49
49
  plot.options.x.axis === 'both'
50
50
  ? 25
51
51
  : 5}
52
- anchor={plot.options.fx.axis}
52
+ anchor={plot.options.fx.axis === 'both'
53
+ ? 'top'
54
+ : (plot.options.fx.axis as 'top' | 'bottom' | undefined)}
55
+ title={null}
53
56
  options={plot.options.fx.axisOptions || {}}
54
57
  {...plot.options.fx.axisProps || {}}
55
58
  height={plot.plotHeight}
@@ -61,14 +64,16 @@
61
64
  <g transform="translate(0, {plot.options.marginTop})">
62
65
  <BaseAxisY
63
66
  class="facet-axis-y"
64
- scaleFn={facetYScale}
67
+ scaleFn={facetYScale as any}
65
68
  scaleType="band"
66
69
  ticks={fyValues}
67
- tickFormat={plot.options.fy.tickFormat || ((d) => d)}
70
+ tickFormat={(plot.options.fy.tickFormat || ((d: any) => d)) as any}
68
71
  tickFontSize={11}
69
72
  tickSize={0}
70
73
  tickPadding={5}
71
- anchor={plot.options.fy.axis}
74
+ anchor={plot.options.fy.axis === 'both'
75
+ ? 'right'
76
+ : (plot.options.fy.axis as 'left' | 'right' | undefined)}
72
77
  lineAnchor="center"
73
78
  options={plot.options.fy.axisOptions || {}}
74
79
  {...plot.options.fy.axisProps || {}}
@@ -43,7 +43,7 @@
43
43
  ? (plot.options.fx?.paddingInner ?? plot.options.fx?.padding ?? 0.1)
44
44
  : 0
45
45
  )
46
- .domain(fxValues)
46
+ .domain(fxValues as string[])
47
47
  .rangeRound([0, plot.plotWidth])
48
48
  );
49
49
  const facetYScale = $derived(
@@ -54,7 +54,7 @@
54
54
  ? (plot.options.fy?.paddingInner ?? plot.options.fy?.padding ?? 0.1)
55
55
  : 0
56
56
  )
57
- .domain(fyValues)
57
+ .domain(fyValues as string[])
58
58
  .rangeRound([0, plot.plotHeight])
59
59
  );
60
60
 
@@ -75,8 +75,8 @@
75
75
  data-facet={i * fyValues.length + j}
76
76
  fill="currentColor"
77
77
  style:display={emptyFacets.get(facetX)?.get(facetY) ? 'none' : 'block'}
78
- transform="translate({useFacetX ? facetXScale(facetX) : 0}, {useFacetY
79
- ? facetYScale(facetY)
78
+ transform="translate({useFacetX ? facetXScale(facetX as string) : 0}, {useFacetY
79
+ ? facetYScale(facetY as string)
80
80
  : 0})">
81
81
  <!-- facets need invisible rect -->
82
82
  <rect