svelteplot 0.4.5-pr-208.4 → 0.4.5

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 (87) hide show
  1. package/dist/Mark.svelte +73 -87
  2. package/dist/Mark.svelte.d.ts +34 -37
  3. package/dist/helpers/colors.d.ts +1 -1
  4. package/dist/helpers/index.d.ts +2 -2
  5. package/dist/helpers/scales.d.ts +2 -2
  6. package/dist/helpers/scales.js +10 -21
  7. package/dist/helpers/typeChecks.d.ts +4 -4
  8. package/dist/marks/Area.svelte.d.ts +34 -37
  9. package/dist/marks/AreaX.svelte.d.ts +35 -38
  10. package/dist/marks/AreaY.svelte.d.ts +35 -38
  11. package/dist/marks/Arrow.svelte.d.ts +34 -37
  12. package/dist/marks/AxisX.svelte +2 -2
  13. package/dist/marks/AxisX.svelte.d.ts +36 -39
  14. package/dist/marks/AxisY.svelte.d.ts +35 -38
  15. package/dist/marks/BarX.svelte.d.ts +35 -38
  16. package/dist/marks/BarY.svelte.d.ts +34 -37
  17. package/dist/marks/BollingerX.svelte.d.ts +74 -2
  18. package/dist/marks/BollingerY.svelte.d.ts +74 -2
  19. package/dist/marks/Cell.svelte.d.ts +34 -37
  20. package/dist/marks/CustomMark.svelte.d.ts +81 -2
  21. package/dist/marks/DifferenceY.svelte.d.ts +67 -7
  22. package/dist/marks/Dot.svelte +1 -1
  23. package/dist/marks/Dot.svelte.d.ts +34 -37
  24. package/dist/marks/DotX.svelte.d.ts +34 -37
  25. package/dist/marks/DotY.svelte.d.ts +34 -37
  26. package/dist/marks/Geo.svelte.d.ts +34 -37
  27. package/dist/marks/GridX.svelte.d.ts +34 -37
  28. package/dist/marks/GridY.svelte.d.ts +34 -37
  29. package/dist/marks/Line.svelte.d.ts +36 -39
  30. package/dist/marks/LineX.svelte.d.ts +35 -38
  31. package/dist/marks/LineY.svelte.d.ts +35 -38
  32. package/dist/marks/Link.svelte.d.ts +34 -37
  33. package/dist/marks/Rect.svelte.d.ts +34 -37
  34. package/dist/marks/RuleX.svelte.d.ts +34 -37
  35. package/dist/marks/RuleY.svelte.d.ts +34 -37
  36. package/dist/marks/Spike.svelte.d.ts +34 -36
  37. package/dist/marks/Text.svelte.d.ts +34 -37
  38. package/dist/marks/TickX.svelte.d.ts +34 -37
  39. package/dist/marks/TickY.svelte.d.ts +34 -37
  40. package/dist/marks/Vector.svelte.d.ts +34 -37
  41. package/dist/marks/helpers/BaseAxisX.svelte +0 -10
  42. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +0 -1
  43. package/dist/marks/helpers/RectPath.svelte.d.ts +63 -3
  44. package/dist/marks/helpers/Regression.svelte +1 -1
  45. package/dist/transforms/bollinger.d.ts +67 -1
  46. package/dist/transforms/group.d.ts +12 -4
  47. package/dist/transforms/interval.d.ts +124 -2
  48. package/dist/transforms/recordize.d.ts +4 -1
  49. package/dist/transforms/select.d.ts +434 -7
  50. package/dist/transforms/sort.d.ts +246 -3
  51. package/dist/transforms/stack.d.ts +23 -3
  52. package/dist/transforms/window.d.ts +130 -2
  53. package/dist/types/mark.d.ts +34 -37
  54. package/dist/types/scale.d.ts +0 -6
  55. package/package.json +128 -129
  56. package/dist/regression/exponential.d.ts +0 -17
  57. package/dist/regression/exponential.js +0 -56
  58. package/dist/regression/index.d.ts +0 -10
  59. package/dist/regression/index.js +0 -10
  60. package/dist/regression/linear.d.ts +0 -17
  61. package/dist/regression/linear.js +0 -59
  62. package/dist/regression/loess.d.ts +0 -14
  63. package/dist/regression/loess.js +0 -122
  64. package/dist/regression/logarithmic.d.ts +0 -20
  65. package/dist/regression/logarithmic.js +0 -60
  66. package/dist/regression/polynomial.d.ts +0 -21
  67. package/dist/regression/polynomial.js +0 -160
  68. package/dist/regression/power.d.ts +0 -18
  69. package/dist/regression/power.js +0 -56
  70. package/dist/regression/quadratic.d.ts +0 -19
  71. package/dist/regression/quadratic.js +0 -70
  72. package/dist/regression/types.d.ts +0 -4
  73. package/dist/regression/types.js +0 -1
  74. package/dist/regression/utils/determination.d.ts +0 -6
  75. package/dist/regression/utils/determination.js +0 -16
  76. package/dist/regression/utils/geometry.d.ts +0 -9
  77. package/dist/regression/utils/geometry.js +0 -12
  78. package/dist/regression/utils/interpose.d.ts +0 -6
  79. package/dist/regression/utils/interpose.js +0 -37
  80. package/dist/regression/utils/median.d.ts +0 -4
  81. package/dist/regression/utils/median.js +0 -8
  82. package/dist/regression/utils/ols.d.ts +0 -6
  83. package/dist/regression/utils/ols.js +0 -9
  84. package/dist/regression/utils/points.d.ts +0 -11
  85. package/dist/regression/utils/points.js +0 -45
  86. package/dist/transforms/dodge.d.ts +0 -17
  87. package/dist/transforms/dodge.js +0 -128
package/dist/Mark.svelte CHANGED
@@ -41,7 +41,6 @@
41
41
  import { testFilter, isValid } from './helpers/index.js';
42
42
  import { resolveChannel, resolveProp } from './helpers/resolve.js';
43
43
  import { RENAME } from './transforms/rename.js';
44
- import { dodgeX, dodgeY } from './transforms/dodge.js';
45
44
 
46
45
  let {
47
46
  data = [],
@@ -208,98 +207,85 @@
208
207
  * elements to the scales
209
208
  */
210
209
  const scaledData = $derived(
211
- dodge(
212
- resolvedData.flatMap((row) => {
213
- const out: ScaledDataRecord<Datum> = {
214
- datum: row.datum,
215
- index: row[INDEX],
216
- valid: true
217
- };
218
- // compute dx/dy
219
- out.dx = Number(resolveProp<number>(options.dx, out.datum, 0));
220
- out.dy = Number(resolveProp<number>(options.dy, out.datum, 0));
221
-
222
- // special handling if there's a projection, e.g. a line mark
223
- if (plot.scales.projection && mark.type !== 'geo') {
224
- for (const suffix of ['', '1', '2']) {
225
- if (
226
- options?.[`x${suffix}`] !== undefined &&
227
- options?.[`y${suffix}`] !== undefined
228
- ) {
229
- // we have two-dimensional accessors
230
- // for the x and y channels
231
- const [x, y] =
232
- mark.type === 'line'
233
- ? [row.x, row.y] // line paths are projected later
234
- : projectXY(
235
- plot.scales,
236
- row.x,
237
- row.y,
238
- usedScales.x,
239
- usedScales.y,
240
- suffix
241
- );
242
-
243
- out[`x${suffix}`] = x;
244
- out[`y${suffix}`] = y;
245
- out.valid =
246
- out.valid &&
247
- isValid(row.x) &&
248
- isValid(row.y) &&
249
- isValid(x) &&
250
- isValid(y);
251
- }
210
+ resolvedData.flatMap((row) => {
211
+ const out: ScaledDataRecord<Datum> = {
212
+ datum: row.datum,
213
+ index: row[INDEX],
214
+ valid: true
215
+ };
216
+ // compute dx/dy
217
+ out.dx = Number(resolveProp<number>(options.dx, out.datum, 0));
218
+ out.dy = Number(resolveProp<number>(options.dy, out.datum, 0));
219
+
220
+ // special handling if there's a projection, e.g. a line mark
221
+ if (plot.scales.projection && mark.type !== 'geo') {
222
+ for (const suffix of ['', '1', '2']) {
223
+ if (
224
+ options?.[`x${suffix}`] !== undefined &&
225
+ options?.[`y${suffix}`] !== undefined
226
+ ) {
227
+ // we have two-dimensional accessors
228
+ // for the x and y channels
229
+ const [x, y] =
230
+ mark.type === 'line'
231
+ ? [row.x, row.y] // line paths are projected later
232
+ : projectXY(
233
+ plot.scales,
234
+ row.x,
235
+ row.y,
236
+ usedScales.x,
237
+ usedScales.y,
238
+ suffix
239
+ );
240
+
241
+ out[`x${suffix}`] = x;
242
+ out[`y${suffix}`] = y;
243
+ out.valid =
244
+ out.valid &&
245
+ isValid(row.x) &&
246
+ isValid(row.y) &&
247
+ isValid(x) &&
248
+ isValid(y);
252
249
  }
253
250
  }
251
+ }
254
252
 
255
- // iterate over all scaled channels
256
- for (const [channel, scale] of Object.entries(CHANNEL_SCALE) as [
257
- ScaledChannelName,
258
- ScaleName
259
- ][]) {
260
- // check if the mark has defined an accessor for this channel
261
- if (options?.[channel] != null && out[channel] === undefined) {
262
- // resolve value
263
- const value = row[channel];
264
- // if this channel was renamed, use the original channel for scaling
265
- const origChannel = options?.[RENAME]?.[channel] || channel;
266
- const scaled = usedScales[channel]
267
- ? scale === 'x'
268
- ? projectX(origChannel as 'x' | 'x1' | 'x2', plot.scales, value)
269
- : scale === 'y'
270
- ? projectY(origChannel as 'y' | 'y1' | 'y2', plot.scales, value)
271
- : scale === 'color' && !isValid(value)
272
- ? plot.options.color.unknown
273
- : plot.scales[scale].fn(value)
274
- : value;
275
-
276
- out.valid = out.valid && (scale === 'color' || isValid(value));
277
-
278
- // apply dx/dy transform
279
- out[channel] =
280
- Number.isFinite(scaled) && (scale === 'x' || scale === 'y')
281
- ? scaled + (scale === 'x' ? out.dx : out.dy)
282
- : scaled;
283
- } else if (defaults[channel]) {
284
- out[channel] = defaults[channel];
285
- }
253
+ // iterate over all scaled channels
254
+ for (const [channel, scale] of Object.entries(CHANNEL_SCALE) as [
255
+ ScaledChannelName,
256
+ ScaleName
257
+ ][]) {
258
+ // check if the mark has defined an accessor for this channel
259
+ if (options?.[channel] != null && out[channel] === undefined) {
260
+ // resolve value
261
+ const value = row[channel];
262
+ // if this channel was renamed, use the original channel for scaling
263
+ const origChannel = options?.[RENAME]?.[channel] || channel;
264
+ const scaled = usedScales[channel]
265
+ ? scale === 'x'
266
+ ? projectX(origChannel as 'x' | 'x1' | 'x2', plot.scales, value)
267
+ : scale === 'y'
268
+ ? projectY(origChannel as 'y' | 'y1' | 'y2', plot.scales, value)
269
+ : scale === 'color' && !isValid(value)
270
+ ? plot.options.color.unknown
271
+ : plot.scales[scale].fn(value)
272
+ : value;
273
+
274
+ out.valid = out.valid && (scale === 'color' || isValid(value));
275
+
276
+ // apply dx/dy transform
277
+ out[channel] =
278
+ Number.isFinite(scaled) && (scale === 'x' || scale === 'y')
279
+ ? scaled + (scale === 'x' ? out.dx : out.dy)
280
+ : scaled;
281
+ } else if (defaults[channel]) {
282
+ out[channel] = defaults[channel];
286
283
  }
284
+ }
287
285
 
288
- return [out];
289
- }),
290
- options
291
- )
286
+ return [out];
287
+ })
292
288
  );
293
-
294
- function dodge<T>(data: ScaledDataRecord<Datum>[], options: BaseMarkProps<T>) {
295
- if (options.dodgeX) {
296
- return dodgeX({ data, ...options }, plot);
297
- }
298
- if (options.dodgeY) {
299
- return dodgeY({ data, ...options }, plot);
300
- }
301
- return data;
302
- }
303
289
  </script>
304
290
 
305
291
  {#if errors.length}
@@ -1,17 +1,14 @@
1
1
  import { type Snippet } from 'svelte';
2
- import { CHANNEL_SCALE } from './constants.js';
3
2
  import type { ScaledChannelName, MarkType, DataRecord, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
4
3
  import { getUsedScales } from './helpers/scales.js';
5
4
  declare class __sveltets_Render<Datum extends DataRecord> {
6
5
  props(): Partial<Partial<{
7
- filter: import("./types/index.js").ConstantAccessor<boolean, Datum>;
8
- facet: "auto" | "include" | "exclude";
6
+ filter?: import("./types/index.js").ConstantAccessor<boolean, Datum>;
7
+ facet?: "auto" | "include" | "exclude";
9
8
  fx: ChannelAccessor<Datum>;
10
9
  fy: ChannelAccessor<Datum>;
11
10
  dx: import("./types/index.js").ConstantAccessor<number, Datum>;
12
11
  dy: import("./types/index.js").ConstantAccessor<number, Datum>;
13
- dodgeX: CHANNEL_SCALE;
14
- dodgeY: CHANNEL_SCALE;
15
12
  fill: ChannelAccessor<Datum>;
16
13
  fillOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
17
14
  sort: {
@@ -32,38 +29,38 @@ declare class __sveltets_Render<Datum extends DataRecord> {
32
29
  imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
33
30
  shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
34
31
  paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
35
- onclick: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
36
- ondblclick: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
37
- onmouseup: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
38
- onmousedown: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
39
- onmouseenter: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
40
- onmousemove: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
41
- onmouseleave: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
42
- onmouseout: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
43
- onmouseover: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
44
- onpointercancel: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
45
- onpointerdown: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
46
- onpointerup: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
47
- onpointerenter: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
48
- onpointerleave: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
49
- onpointermove: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
50
- onpointerover: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
51
- onpointerout: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
52
- ondrag: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
53
- ondrop: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
54
- ondragstart: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
55
- ondragenter: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
56
- ondragleave: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
57
- ondragover: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
58
- ondragend: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
59
- ontouchstart: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
60
- ontouchmove: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
61
- ontouchend: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
62
- ontouchcancel: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
63
- oncontextmenu: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
64
- onwheel: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
65
- class: string;
66
- style: string;
32
+ onclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
33
+ ondblclick?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
34
+ onmouseup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
35
+ onmousedown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
36
+ onmouseenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
37
+ onmousemove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
38
+ onmouseleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
39
+ onmouseout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
40
+ onmouseover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
41
+ onpointercancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
42
+ onpointerdown?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
43
+ onpointerup?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
44
+ onpointerenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
45
+ onpointerleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
46
+ onpointermove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
47
+ onpointerover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
48
+ onpointerout?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
49
+ ondrag?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
50
+ ondrop?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
51
+ ondragstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
52
+ ondragenter?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
53
+ ondragleave?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
54
+ ondragover?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
55
+ ondragend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
56
+ ontouchstart?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
57
+ ontouchmove?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
58
+ ontouchend?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
59
+ ontouchcancel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
60
+ oncontextmenu?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
61
+ onwheel?: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
62
+ class?: string;
63
+ style?: string;
67
64
  cursor: import("./types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
68
65
  }>> & {
69
66
  data?: Datum[] | undefined;
@@ -6,7 +6,7 @@ type SchemeGetter = (n: number) => readonly string[];
6
6
  export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
7
7
  export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
8
8
  export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
9
- export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
9
+ export declare function maybeBooleanRange(domain: boolean[], scheme?: string): unknown[] | undefined;
10
10
  export declare function isQuantitativeScheme(scheme: string): boolean;
11
11
  export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
12
12
  export declare function isDivergingScheme(scheme: string): boolean;
@@ -3,8 +3,8 @@ import type { Snippet } from 'svelte';
3
3
  /**
4
4
  * Returns first argument that is not null or undefined
5
5
  */
6
- export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
7
- export declare function testFilter<T>(datum: T, options: Channels<T>): any;
6
+ export declare function coalesce(...args: (RawValue | undefined | null)[]): RawValue | null;
7
+ export declare function testFilter<T>(datum: T, options: Channels<T>): true | T | null;
8
8
  export declare function randomId(): string;
9
9
  export declare function isSnippet(value: unknown): value is Snippet;
10
10
  export declare function isValid(value: RawValue | undefined): value is number | Date | string;
@@ -15,7 +15,7 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
15
15
  autoTitle?: undefined;
16
16
  } | {
17
17
  type: ScaleType;
18
- domain: any;
18
+ domain: RawValue[] | [undefined, undefined];
19
19
  range: any;
20
20
  fn: any;
21
21
  skip: Map<ScaledChannelName, Set<symbol>>;
@@ -28,7 +28,7 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
28
28
  * Infer a scale type based on the scale name, the data values mapped to it and
29
29
  * the mark types that are bound to the scale
30
30
  */
31
- export declare function inferScaleType(name: ScaleName, dataValues: RawValue[], markTypes: Set<MarkType>, scaleOptions?: Partial<ScaleOptions>): ScaleType;
31
+ export declare function inferScaleType(name: ScaleName, dataValues: RawValue[], markTypes: Set<MarkType>): ScaleType;
32
32
  /**
33
33
  * Mark channels can explicitly or implicitly be exempt from being
34
34
  * mapped to a scale, so everywhere where values are being mapped to
@@ -1,5 +1,5 @@
1
1
  import { extent, ascending } from 'd3-array';
2
- import { isColorOrNull, isDate, isDateOrNull, isNumberOrNull, isNumberOrNullOrNaN, isStringOrNull } from './typeChecks.js';
2
+ import { isColorOrNull, isDateOrNull, isNumberOrNull, isNumberOrNullOrNaN, isStringOrNull } from './typeChecks.js';
3
3
  import { CHANNEL_SCALE, VALID_SCALE_TYPES } from '../constants.js';
4
4
  import { isSymbolOrNull } from './typeChecks.js';
5
5
  import { resolveProp, toChannelOption } from './resolve.js';
@@ -146,7 +146,7 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
146
146
  // construct domain from data values
147
147
  const valueArr = [...dataValues.values(), ...(scaleOptions.domain || [])].filter((d) => d != null);
148
148
  const type = scaleOptions.type === 'auto'
149
- ? inferScaleType(name, valueArr, markTypes, scaleOptions)
149
+ ? inferScaleType(name, valueArr, markTypes)
150
150
  : scaleOptions.type;
151
151
  if (VALID_SCALE_TYPES[name] && !VALID_SCALE_TYPES[name].has(type)) {
152
152
  throw new Error(`Invalid scale type ${type} for scale
@@ -217,15 +217,11 @@ function domainFromInterval(domain, interval, name) {
217
217
  const out = interval_.range(lo, interval_.offset(hi));
218
218
  return name === 'y' ? out.toReversed() : out;
219
219
  }
220
- const markTypesWithBandDefault = {
221
- x: new Set(['barY', 'cell', 'tickY']),
222
- y: new Set(['barX', 'cell', 'tickX'])
223
- };
224
220
  /**
225
221
  * Infer a scale type based on the scale name, the data values mapped to it and
226
222
  * the mark types that are bound to the scale
227
223
  */
228
- export function inferScaleType(name, dataValues, markTypes, scaleOptions = {}) {
224
+ export function inferScaleType(name, dataValues, markTypes) {
229
225
  if (name === 'color') {
230
226
  if (!dataValues.length)
231
227
  return 'ordinal';
@@ -239,22 +235,15 @@ export function inferScaleType(name, dataValues, markTypes, scaleOptions = {}) {
239
235
  }
240
236
  if (name === 'symbol')
241
237
  return 'ordinal';
238
+ // for positional scales, try to pick a scale that's required by the mark types
242
239
  if (name === 'x' || name === 'y') {
243
- // if for a positional scale we may infer the scale type from the scale options
244
- if (scaleOptions.nice || scaleOptions.zero)
245
- return 'linear';
246
- if (scaleOptions.domain && scaleOptions.domain.length === 2) {
247
- if (scaleOptions.domain.every(Number.isFinite))
248
- return 'linear';
249
- if (scaleOptions.domain.every(isDate))
250
- return 'time';
251
- }
240
+ if (name === 'y' &&
241
+ (markTypes.has('barX') || markTypes.has('tickX') || markTypes.has('cell')))
242
+ return 'band';
243
+ if (name === 'x' &&
244
+ (markTypes.has('barY') || markTypes.has('tickY') || markTypes.has('cell')))
245
+ return 'band';
252
246
  }
253
- // for positional scales, try to pick a scale that's required by the mark types
254
- if (name === 'y' && Array.from(markTypes).some((d) => markTypesWithBandDefault.y.has(d)))
255
- return 'band';
256
- if (name === 'x' && Array.from(markTypes).some((d) => markTypesWithBandDefault.x.has(d)))
257
- return 'band';
258
247
  if (!dataValues.length)
259
248
  return 'linear';
260
249
  if (dataValues.length === 1)
@@ -1,10 +1,10 @@
1
1
  import type { RawValue } from '../types/index.js';
2
- export declare function isBooleanOrNull(v: RawValue): boolean;
2
+ export declare function isBooleanOrNull(v: RawValue): v is boolean;
3
3
  export declare function isDate(v: RawValue): v is Date;
4
- export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
4
+ export declare function isDateOrNull(v: RawValue | null | undefined): v is Date | null | undefined;
5
5
  export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
6
6
  export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
7
- export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
7
+ export declare function isStringOrNull(v: RawValue | null | undefined): v is string | null | undefined;
8
8
  export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
9
- export declare function isColorOrNull(v: RawValue | null | undefined): any;
9
+ export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
10
10
  export declare function isOpacityOrNull(v: RawValue): boolean;
@@ -1,17 +1,14 @@
1
1
  import { type CurveFactory } from 'd3-shape';
2
- import callWithProps from '../helpers/callWithProps.js';
3
2
  import type { CurveName, DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps, RawValue } from '../types/index.js';
4
3
  import type { StackOptions } from '../transforms/stack.js';
5
4
  declare class __sveltets_Render<Datum extends DataRecord> {
6
5
  props(): Partial<{
7
- filter: ConstantAccessor<boolean, Datum>;
8
- facet: "auto" | "include" | "exclude";
6
+ filter?: ConstantAccessor<boolean, Datum>;
7
+ facet?: "auto" | "include" | "exclude";
9
8
  fx: ChannelAccessor<Datum>;
10
9
  fy: ChannelAccessor<Datum>;
11
10
  dx: ConstantAccessor<number, Datum>;
12
11
  dy: ConstantAccessor<number, Datum>;
13
- dodgeX: callWithProps;
14
- dodgeY: callWithProps;
15
12
  fill: ChannelAccessor<Datum>;
16
13
  fillOpacity: ConstantAccessor<number, Datum>;
17
14
  sort: {
@@ -32,38 +29,38 @@ declare class __sveltets_Render<Datum extends DataRecord> {
32
29
  imageFilter: ConstantAccessor<string, Datum>;
33
30
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
34
31
  paintOrder: 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>;
65
- class: string;
66
- style: string;
32
+ onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
33
+ ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
+ onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
+ onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
+ onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
+ onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
+ onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
+ onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
+ onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
+ onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
+ onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
+ onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
+ onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
+ onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
+ onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
+ onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
+ onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
+ ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
+ ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
+ ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
+ ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
+ ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
+ ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
+ ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
+ ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
+ ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
+ ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
+ ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
+ oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
+ onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
+ class?: string;
63
+ style?: string;
67
64
  cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
68
65
  }> & LinkableMarkProps<Datum> & {
69
66
  data: Datum[];
@@ -1,15 +1,12 @@
1
- import { renameChannels } from '../transforms/rename.js';
2
1
  import type { ChannelAccessor, DataRow } from '../types/index.js';
3
2
  declare class __sveltets_Render<Datum extends DataRow> {
4
3
  props(): Omit<Partial<{
5
- filter: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data").RawValue>>;
6
- facet: "auto" | "include" | "exclude";
4
+ filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data").RawValue>>;
5
+ facet?: "auto" | "include" | "exclude";
7
6
  fx: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
8
7
  fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
9
8
  dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
10
9
  dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
11
- dodgeX: renameChannels;
12
- dodgeY: renameChannels;
13
10
  fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
14
11
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
15
12
  sort: {
@@ -30,38 +27,38 @@ declare class __sveltets_Render<Datum extends DataRow> {
30
27
  imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
31
28
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
32
29
  paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
33
- onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
- ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
- onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
- onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
- onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
- onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
- onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
- onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
- onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
- onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
- onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
- onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
- onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
- onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
- onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
- onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
- onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
- ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
- ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
- ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
- ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
- ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
- ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
- ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
- ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
- ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
- ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
- ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
- oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
- onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
63
- class: string;
64
- style: string;
30
+ onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
31
+ ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
32
+ onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
33
+ onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
+ onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
+ onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
+ onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
+ onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
+ onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
+ onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
+ onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
+ onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
+ onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
+ onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
+ onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
+ onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
+ onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
+ ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
+ ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
+ ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
+ ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
+ ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
+ ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
+ ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
+ ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
+ ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
+ ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
+ ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
+ oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
+ onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
+ class?: string;
61
+ style?: string;
65
62
  cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/data").RawValue>>;
66
63
  }> & import("../types/mark").LinkableMarkProps<Record<string | symbol, import("../types/data").RawValue>> & {
67
64
  data: Record<string | symbol, import("../types/data").RawValue>[];
@@ -75,7 +72,7 @@ declare class __sveltets_Render<Datum extends DataRow> {
75
72
  sort?: import("../types/index.js").ConstantAccessor<import("../types/data").RawValue> | {
76
73
  channel: "stroke" | "fill";
77
74
  };
78
- stack?: Partial<renameChannels>;
75
+ stack?: Partial<import("../transforms/stack.js").StackOptions>;
79
76
  canvas?: boolean;
80
77
  }, "y1" | "y2"> & {
81
78
  x?: ChannelAccessor<Datum>;