svelteplot 0.4.6 → 0.4.7-pr-219.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 (107) hide show
  1. package/dist/core/Plot.svelte +54 -31
  2. package/dist/helpers/colors.d.ts +1 -1
  3. package/dist/helpers/index.d.ts +2 -2
  4. package/dist/helpers/scales.d.ts +2 -2
  5. package/dist/helpers/scales.js +21 -10
  6. package/dist/helpers/typeChecks.d.ts +4 -4
  7. package/dist/hooks/plotDefaults.d.ts +3 -0
  8. package/dist/hooks/plotDefaults.js +16 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +2 -0
  11. package/dist/marks/Area.svelte +2 -1
  12. package/dist/marks/AreaX.svelte +4 -3
  13. package/dist/marks/AreaX.svelte.d.ts +2 -1
  14. package/dist/marks/AreaY.svelte +4 -5
  15. package/dist/marks/Arrow.svelte +3 -2
  16. package/dist/marks/AxisX.svelte +3 -4
  17. package/dist/marks/AxisX.svelte.d.ts +1 -1
  18. package/dist/marks/AxisY.svelte +3 -4
  19. package/dist/marks/AxisY.svelte.d.ts +6 -7
  20. package/dist/marks/BarX.svelte +4 -4
  21. package/dist/marks/BarX.svelte.d.ts +1 -1
  22. package/dist/marks/BarY.svelte +3 -3
  23. package/dist/marks/BollingerX.svelte.d.ts +2 -74
  24. package/dist/marks/BollingerY.svelte.d.ts +2 -74
  25. package/dist/marks/BoxX.svelte +4 -4
  26. package/dist/marks/BoxY.svelte +4 -4
  27. package/dist/marks/BoxY.svelte.d.ts +1 -0
  28. package/dist/marks/Brush.svelte +13 -7
  29. package/dist/marks/Brush.svelte.d.ts +10 -1
  30. package/dist/marks/BrushX.svelte +4 -4
  31. package/dist/marks/BrushY.svelte +4 -4
  32. package/dist/marks/Cell.svelte +3 -4
  33. package/dist/marks/ColorLegend.svelte +5 -4
  34. package/dist/marks/CustomMark.svelte.d.ts +2 -81
  35. package/dist/marks/DifferenceY.svelte +3 -3
  36. package/dist/marks/DifferenceY.svelte.d.ts +7 -67
  37. package/dist/marks/Dot.svelte +2 -2
  38. package/dist/marks/Frame.svelte +2 -2
  39. package/dist/marks/Geo.svelte +2 -2
  40. package/dist/marks/Graticule.svelte +3 -3
  41. package/dist/marks/GridX.svelte +3 -3
  42. package/dist/marks/GridY.svelte +4 -9
  43. package/dist/marks/Line.svelte +3 -2
  44. package/dist/marks/Line.svelte.d.ts +2 -2
  45. package/dist/marks/LineX.svelte.d.ts +2 -1
  46. package/dist/marks/LineY.svelte.d.ts +2 -1
  47. package/dist/marks/Link.svelte +3 -3
  48. package/dist/marks/Pointer.svelte +3 -3
  49. package/dist/marks/Rect.svelte +2 -3
  50. package/dist/marks/RectX.svelte +4 -3
  51. package/dist/marks/RectY.svelte +4 -3
  52. package/dist/marks/RuleX.svelte +3 -3
  53. package/dist/marks/RuleY.svelte +4 -4
  54. package/dist/marks/Sphere.svelte +2 -2
  55. package/dist/marks/Spike.svelte +4 -3
  56. package/dist/marks/Text.svelte +4 -4
  57. package/dist/marks/TickX.svelte +3 -3
  58. package/dist/marks/TickY.svelte +4 -4
  59. package/dist/marks/Vector.svelte +3 -3
  60. package/dist/marks/helpers/CanvasLayer.svelte +1 -1
  61. package/dist/marks/helpers/Marker.svelte +2 -1
  62. package/dist/marks/helpers/MarkerPath.svelte +4 -4
  63. package/dist/marks/helpers/MarkerPath.svelte.d.ts +17 -2
  64. package/dist/marks/helpers/RectPath.svelte.d.ts +3 -63
  65. package/dist/marks/helpers/Regression.svelte +1 -1
  66. package/dist/regression/exponential.d.ts +17 -0
  67. package/dist/regression/exponential.js +56 -0
  68. package/dist/regression/index.d.ts +10 -0
  69. package/dist/regression/index.js +10 -0
  70. package/dist/regression/linear.d.ts +17 -0
  71. package/dist/regression/linear.js +59 -0
  72. package/dist/regression/loess.d.ts +14 -0
  73. package/dist/regression/loess.js +122 -0
  74. package/dist/regression/logarithmic.d.ts +20 -0
  75. package/dist/regression/logarithmic.js +60 -0
  76. package/dist/regression/polynomial.d.ts +21 -0
  77. package/dist/regression/polynomial.js +160 -0
  78. package/dist/regression/power.d.ts +18 -0
  79. package/dist/regression/power.js +56 -0
  80. package/dist/regression/quadratic.d.ts +19 -0
  81. package/dist/regression/quadratic.js +70 -0
  82. package/dist/regression/types.d.ts +4 -0
  83. package/dist/regression/types.js +1 -0
  84. package/dist/regression/utils/determination.d.ts +6 -0
  85. package/dist/regression/utils/determination.js +16 -0
  86. package/dist/regression/utils/geometry.d.ts +9 -0
  87. package/dist/regression/utils/geometry.js +12 -0
  88. package/dist/regression/utils/interpose.d.ts +6 -0
  89. package/dist/regression/utils/interpose.js +37 -0
  90. package/dist/regression/utils/median.d.ts +4 -0
  91. package/dist/regression/utils/median.js +8 -0
  92. package/dist/regression/utils/ols.d.ts +6 -0
  93. package/dist/regression/utils/ols.js +9 -0
  94. package/dist/regression/utils/points.d.ts +11 -0
  95. package/dist/regression/utils/points.js +45 -0
  96. package/dist/transforms/bollinger.d.ts +1 -67
  97. package/dist/transforms/group.d.ts +4 -12
  98. package/dist/transforms/interval.d.ts +2 -124
  99. package/dist/transforms/recordize.d.ts +1 -4
  100. package/dist/transforms/select.d.ts +7 -434
  101. package/dist/transforms/sort.d.ts +3 -246
  102. package/dist/transforms/stack.d.ts +3 -23
  103. package/dist/transforms/window.d.ts +2 -130
  104. package/dist/types/plot.d.ts +15 -8
  105. package/dist/types/scale.d.ts +6 -0
  106. package/package.json +128 -128
  107. package/dist/marks/AreaY.svelte.d.ts +0 -99
@@ -8,7 +8,7 @@
8
8
  this component.
9
9
  -->
10
10
  <script lang="ts">
11
- import { getContext, setContext } from 'svelte';
11
+ import { setContext } from 'svelte';
12
12
  import { SvelteMap } from 'svelte/reactivity';
13
13
  import { writable } from 'svelte/store';
14
14
 
@@ -21,13 +21,15 @@
21
21
  PlotScale,
22
22
  PlotDefaults,
23
23
  PlotState,
24
- RawValue
24
+ RawValue,
25
+ PlotMargin
25
26
  } from '../types/index.js';
26
27
  import FacetGrid from './FacetGrid.svelte';
27
28
 
28
29
  import mergeDeep from '../helpers/mergeDeep.js';
29
30
  import { computeScales, projectXY } from '../helpers/scales.js';
30
31
  import { CHANNEL_SCALE, SCALES } from '../constants.js';
32
+ import { getPlotDefaults, setPlotDefaults } from '../hooks/plotDefaults.js';
31
33
 
32
34
  // automatic margins can be applied by the marks, registered
33
35
  // with their respective unique identifier as keys
@@ -51,7 +53,7 @@
51
53
  const maxMarginBottom = $derived(Math.max(...$autoMarginBottom.values()));
52
54
  const maxMarginTop = $derived(Math.max(...$autoMarginTop.values()));
53
55
 
54
- const USER_DEFAULTS = getContext<Partial<PlotDefaults>>('svelteplot/defaults') || {};
56
+ const USER_DEFAULTS = getPlotDefaults();
55
57
 
56
58
  // default settings in the plot and marks can be overwritten by
57
59
  // defining the svelteplot/defaults context outside of Plot
@@ -59,6 +61,7 @@
59
61
  height: 350,
60
62
  initialWidth: 500,
61
63
  inset: 0,
64
+ margin: 'auto',
62
65
  colorScheme: 'turbo',
63
66
  unknown: '#cccccc99',
64
67
 
@@ -115,14 +118,14 @@
115
118
 
116
119
  let width = $state(DEFAULTS.initialWidth);
117
120
 
118
- setContext('svelteplot/_defaults', DEFAULTS);
121
+ setPlotDefaults(DEFAULTS);
119
122
 
120
123
  // information that influences the default plot options
121
124
  type PlotOptionsParameters = {
122
125
  explicitScales: Set<ScaleName>;
123
126
  explicitDomains: Set<ScaleName>;
124
127
  hasProjection: boolean;
125
- margins?: number;
128
+ margin?: number | 'auto';
126
129
  inset?: number;
127
130
  };
128
131
 
@@ -173,7 +176,7 @@
173
176
  explicitScales,
174
177
  explicitDomains,
175
178
  hasProjection: !!initialOpts.projection,
176
- margins: initialOpts.margins,
179
+ margin: initialOpts.margin,
177
180
  inset: initialOpts.inset
178
181
  })
179
182
  );
@@ -363,6 +366,38 @@
363
366
  return mergeDeep<PlotOptions>({}, smartDefaultPlotOptions(opts), initialOpts);
364
367
  }
365
368
 
369
+ function maybeMargin(
370
+ // the margin option provided to the <Plot> component
371
+ margin: number | 'auto' | PlotMargin | undefined,
372
+ // direction to extract from the margin object
373
+ direction: 'left' | 'right' | 'top' | 'bottom',
374
+ // the margin option defined in the plot defaults
375
+ defaultValue: PlotMargin | number | 'auto',
376
+ // automatic margins computed from the marks
377
+ autoMargins: {
378
+ left: number;
379
+ right: number;
380
+ top: number;
381
+ bottom: number;
382
+ }
383
+ ): number {
384
+ // direction-specific margin value takes precedence
385
+ const marginValue =
386
+ typeof margin === 'object' && margin[direction] != null
387
+ ? margin[direction]
388
+ : // use the margin value if it's a number
389
+ typeof margin === 'number' || margin === 'auto'
390
+ ? margin
391
+ : // use direction-specific default value if defined
392
+ typeof defaultValue === 'object' && defaultValue[direction] != null
393
+ ? defaultValue[direction]
394
+ : typeof defaultValue === 'number' || defaultValue === 'auto'
395
+ ? defaultValue
396
+ : 'auto';
397
+
398
+ return marginValue === 'auto' ? autoMargins[direction] : marginValue;
399
+ }
400
+
366
401
  /**
367
402
  * compute smart default options for the plot based on the scales and marks
368
403
  */
@@ -370,43 +405,31 @@
370
405
  explicitScales,
371
406
  explicitDomains,
372
407
  hasProjection,
373
- margins
408
+ margin
374
409
  }: PlotOptionsParameters): PlotOptions {
375
410
  const autoXAxis = explicitScales.has('x') || explicitDomains.has('x');
376
411
  const autoYAxis = explicitScales.has('y') || explicitDomains.has('y');
377
412
  const isOneDimensional = autoXAxis !== autoYAxis;
378
413
  const oneDimX = autoXAxis && !autoYAxis;
379
414
  const oneDimY = autoYAxis && !autoXAxis;
415
+
416
+ const autoMargins = {
417
+ left: hasProjection ? 0 : Math.max(maxMarginLeft + 1, 1),
418
+ right: hasProjection ? 0 : oneDimY ? 0 : Math.max(maxMarginRight + 1, 4),
419
+ top: hasProjection ? 0 : oneDimX ? 0 : Math.max(5, maxMarginTop),
420
+ bottom: hasProjection ? 0 : Math.max(5, maxMarginBottom)
421
+ };
422
+
380
423
  return {
381
424
  title: '',
382
425
  subtitle: '',
383
426
  caption: '',
384
427
  height: 'auto',
385
428
  // maxWidth: oneDimY ? `${60 * e}px` : undefined,
386
- marginLeft: hasProjection
387
- ? 0
388
- : margins != null
389
- ? margins
390
- : Math.max(maxMarginLeft + 1, 1),
391
- marginRight: hasProjection
392
- ? 0
393
- : margins != null
394
- ? margins
395
- : oneDimY
396
- ? 0
397
- : Math.max(maxMarginRight + 1, 4),
398
- marginTop: hasProjection
399
- ? 0
400
- : margins != null
401
- ? margins
402
- : oneDimX
403
- ? 0
404
- : Math.max(5, maxMarginTop),
405
- marginBottom: hasProjection
406
- ? 0
407
- : margins != null
408
- ? margins
409
- : Math.max(5, maxMarginBottom),
429
+ marginLeft: maybeMargin(margin, 'left', DEFAULTS.margin, autoMargins),
430
+ marginRight: maybeMargin(margin, 'right', DEFAULTS.margin, autoMargins),
431
+ marginTop: maybeMargin(margin, 'top', DEFAULTS.margin, autoMargins),
432
+ marginBottom: maybeMargin(margin, 'bottom', DEFAULTS.margin, autoMargins),
410
433
  inset: isOneDimensional ? 10 : DEFAULTS.inset,
411
434
  grid: (DEFAULTS.gridX?.implicit ?? false) && (DEFAULTS.gridY?.implicit ?? false),
412
435
  axes: (DEFAULTS.axisX?.implicit ?? false) && (DEFAULTS.axisY?.implicit ?? false),
@@ -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): unknown[] | undefined;
9
+ export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | 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)[]): RawValue | null;
7
- export declare function testFilter<T>(datum: T, options: Channels<T>): true | T | null;
6
+ export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
7
+ export declare function testFilter<T>(datum: T, options: Channels<T>): any;
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: RawValue[] | [undefined, undefined];
18
+ domain: any;
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>): ScaleType;
31
+ export declare function inferScaleType(name: ScaleName, dataValues: RawValue[], markTypes: Set<MarkType>, scaleOptions?: Partial<ScaleOptions>): 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, isDateOrNull, isNumberOrNull, isNumberOrNullOrNaN, isStringOrNull } from './typeChecks.js';
2
+ import { isColorOrNull, isDate, 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)
149
+ ? inferScaleType(name, valueArr, markTypes, scaleOptions)
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,11 +217,15 @@ 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
+ };
220
224
  /**
221
225
  * Infer a scale type based on the scale name, the data values mapped to it and
222
226
  * the mark types that are bound to the scale
223
227
  */
224
- export function inferScaleType(name, dataValues, markTypes) {
228
+ export function inferScaleType(name, dataValues, markTypes, scaleOptions = {}) {
225
229
  if (name === 'color') {
226
230
  if (!dataValues.length)
227
231
  return 'ordinal';
@@ -235,15 +239,22 @@ export function inferScaleType(name, dataValues, markTypes) {
235
239
  }
236
240
  if (name === 'symbol')
237
241
  return 'ordinal';
238
- // for positional scales, try to pick a scale that's required by the mark types
239
242
  if (name === 'x' || name === 'y') {
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';
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
+ }
246
252
  }
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';
247
258
  if (!dataValues.length)
248
259
  return 'linear';
249
260
  if (dataValues.length === 1)
@@ -1,10 +1,10 @@
1
1
  import type { RawValue } from '../types/index.js';
2
- export declare function isBooleanOrNull(v: RawValue): v is boolean;
2
+ export declare function isBooleanOrNull(v: RawValue): boolean;
3
3
  export declare function isDate(v: RawValue): v is Date;
4
- export declare function isDateOrNull(v: RawValue | null | undefined): v is Date | null | undefined;
4
+ export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
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): v is string | null | undefined;
7
+ export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
8
8
  export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
9
- export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
9
+ export declare function isColorOrNull(v: RawValue | null | undefined): any;
10
10
  export declare function isOpacityOrNull(v: RawValue): boolean;
@@ -0,0 +1,3 @@
1
+ import type { PlotDefaults } from '../types';
2
+ export declare function setPlotDefaults(plotDefaults: Partial<PlotDefaults>): void;
3
+ export declare function getPlotDefaults(): Partial<PlotDefaults>;
@@ -0,0 +1,16 @@
1
+ import { getContext, hasContext, setContext } from 'svelte';
2
+ const PLOT_DEFAULTS_KEY = Symbol('svelteplot/defaults');
3
+ export function setPlotDefaults(plotDefaults) {
4
+ const existingDefaults = getPlotDefaults();
5
+ const mergedDefaults = { ...existingDefaults, ...plotDefaults };
6
+ setContext(PLOT_DEFAULTS_KEY, mergedDefaults);
7
+ }
8
+ export function getPlotDefaults() {
9
+ return hasContext(PLOT_DEFAULTS_KEY)
10
+ ? getContext(PLOT_DEFAULTS_KEY)
11
+ : // Fallback for backward compatibility
12
+ hasContext('svelteplot/defaults')
13
+ ? (console.error(`svelteplot: Please use new setPlotDefaults hook instead of 'svelteplot/defaults' context`),
14
+ getContext('svelteplot/defaults'))
15
+ : {};
16
+ }
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export { default as PlotCore } from './core/Plot.svelte';
3
3
  export * from './marks/index.js';
4
4
  export * from './transforms/index.js';
5
5
  export { formatMonth } from './helpers/formats.js';
6
+ export * from './hooks/plotDefaults.js';
package/dist/index.js CHANGED
@@ -4,3 +4,5 @@ export * from './marks/index.js';
4
4
  export * from './transforms/index.js';
5
5
  // helpers
6
6
  export { formatMonth } from './helpers/formats.js';
7
+ // hooks
8
+ export * from './hooks/plotDefaults.js';
@@ -42,6 +42,7 @@
42
42
  } from '../types/index.js';
43
43
  import type { StackOptions } from '../transforms/stack.js';
44
44
  import { addEventHandlers } from './helpers/events';
45
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
45
46
 
46
47
  let markProps: AreaMarkProps = $props();
47
48
 
@@ -49,7 +50,7 @@
49
50
  fill: 'currentColor',
50
51
  curve: 'linear' as CurveName,
51
52
  tension: 0,
52
- ...getContext<PlotDefaults>('svelteplot/_defaults').area
53
+ ...getPlotDefaults().area
53
54
  };
54
55
 
55
56
  const {
@@ -11,12 +11,13 @@
11
11
  import { renameChannels } from '../transforms/rename.js';
12
12
  import { stackX } from '../transforms/stack.js';
13
13
  import { recordizeX } from '../transforms/recordize.js';
14
- import type { ChannelAccessor, DataRow, PlotDefaults } from '../types/index.js';
15
- import { getContext, type ComponentProps } from 'svelte';
14
+ import type { ChannelAccessor, DataRow } from '../types/index.js';
15
+ import { type ComponentProps } from 'svelte';
16
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
16
17
 
17
18
  let markProps: AreaXMarkProps = $props();
18
19
 
19
- const DEFAULTS = getContext<PlotDefaults>('svelteplot/_defaults').areaX;
20
+ const DEFAULTS = getPlotDefaults().areaX;
20
21
 
21
22
  const { data, stack, ...options }: AreaXMarkProps = $derived({
22
23
  ...(markProps.x == undefined ? { x1: 0, x2: 0 } : {}),
@@ -1,3 +1,4 @@
1
+ import { renameChannels } from '../transforms/rename.js';
1
2
  import type { ChannelAccessor, DataRow } from '../types/index.js';
2
3
  declare class __sveltets_Render<Datum extends DataRow> {
3
4
  props(): Omit<Partial<{
@@ -72,7 +73,7 @@ declare class __sveltets_Render<Datum extends DataRow> {
72
73
  sort?: import("../types/index.js").ConstantAccessor<import("../types/data").RawValue> | {
73
74
  channel: "stroke" | "fill";
74
75
  };
75
- stack?: Partial<import("../transforms/stack.js").StackOptions>;
76
+ stack?: Partial<renameChannels>;
76
77
  canvas?: boolean;
77
78
  }, "y1" | "y2"> & {
78
79
  x?: ChannelAccessor<Datum>;
@@ -10,14 +10,13 @@
10
10
  import Area from './Area.svelte';
11
11
  import { renameChannels } from '../transforms/rename.js';
12
12
  import { stackY } from '../transforms/stack.js';
13
- import { RAW_VALUE, recordizeY } from '../transforms/recordize.js';
14
- import type { ChannelAccessor, DataRow, PlotDefaults } from '../types/index.js';
15
- import { getContext, type Component, type ComponentProps } from 'svelte';
16
- import { area } from 'd3-shape';
13
+ import { recordizeY } from '../transforms/recordize.js';
14
+ import type { ChannelAccessor, DataRow } from '../types/index.js';
15
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
17
16
 
18
17
  let markProps: AreaYMarkProps = $props();
19
18
 
20
- const DEFAULTS = getContext<PlotDefaults>('svelteplot/_defaults').areaY;
19
+ const DEFAULTS = getPlotDefaults().areaY;
21
20
 
22
21
  const { data, stack, ...options }: AreaYMarkProps = $derived({
23
22
  ...(markProps.y == undefined ? { y1: 0, y2: 0 } : {}),
@@ -47,7 +47,7 @@
47
47
  RawValue,
48
48
  PlotDefaults
49
49
  } from '../types/index.js';
50
- import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
50
+ import { resolveProp, resolveStyles } from '../helpers/resolve.js';
51
51
  import { coalesce, maybeNumber } from '../helpers/index.js';
52
52
  import Mark from '../Mark.svelte';
53
53
  import { arrowPath, maybeSweep, type SweepOption } from '../helpers/arrowPath.js';
@@ -56,6 +56,7 @@
56
56
  import GroupMultiple from './helpers/GroupMultiple.svelte';
57
57
  import { sort } from '../transforms/sort.js';
58
58
  import { indexData } from '../transforms/recordize.js';
59
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
59
60
 
60
61
  let markProps: ArrowMarkProps = $props();
61
62
 
@@ -63,7 +64,7 @@
63
64
  headAngle: 60,
64
65
  headLength: 8,
65
66
  inset: 0,
66
- ...getContext<PlotDefaults>('svelteplot/_defaults').arrow
67
+ ...getPlotDefaults().arrow
67
68
  };
68
69
 
69
70
  const {
@@ -11,14 +11,13 @@
11
11
  RawValue,
12
12
  ConstantAccessor,
13
13
  FacetContext,
14
- PlotDefaults,
15
14
  ChannelName
16
15
  } from '../types/index.js';
17
16
  import type * as CSS from 'csstype';
18
17
  import autoTimeFormat from '../helpers/autoTimeFormat.js';
19
- import { derived } from 'svelte/store';
20
18
  import { autoTicks } from '../helpers/autoTicks.js';
21
19
  import { resolveScaledStyles } from '../helpers/resolve.js';
20
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
22
21
 
23
22
  interface AxisXMarkProps
24
23
  extends Omit<
@@ -64,8 +63,8 @@
64
63
  textAnchor: 'auto',
65
64
  opacity: 0.8,
66
65
  anchor: 'bottom',
67
- ...getContext<PlotDefaults>('svelteplot/_defaults').axis,
68
- ...getContext<PlotDefaults>('svelteplot/_defaults').axisX
66
+ ...getPlotDefaults().axis,
67
+ ...getPlotDefaults().axisX
69
68
  };
70
69
 
71
70
  const {
@@ -61,7 +61,7 @@ declare class __sveltets_Render<Datum extends RawValue> {
61
61
  class?: string;
62
62
  style?: string;
63
63
  cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
64
- }>, "fillOpacity" | "href" | "target" | "paintOrder" | "title"> & {
64
+ }>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
65
65
  data?: Datum[] | undefined;
66
66
  automatic?: boolean;
67
67
  title?: string | false | null;
@@ -10,14 +10,13 @@
10
10
  BaseMarkProps,
11
11
  RawValue,
12
12
  FacetContext,
13
- PlotDefaults,
14
13
  ChannelName,
15
14
  ConstantAccessor
16
15
  } from '../types/index.js';
17
- import type * as CSS from 'csstype';
18
16
  import autoTimeFormat from '../helpers/autoTimeFormat.js';
19
17
  import { autoTicks } from '../helpers/autoTicks.js';
20
18
  import { resolveScaledStyles } from '../helpers/resolve.js';
19
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
21
20
 
22
21
  interface AxisYMarkProps
23
22
  extends Omit<
@@ -62,8 +61,8 @@
62
61
  opacity: 0.8,
63
62
  anchor: 'left',
64
63
  textAnchor: 'auto',
65
- ...getContext<PlotDefaults>('svelteplot/_defaults').axis,
66
- ...getContext<PlotDefaults>('svelteplot/_defaults').axisY
64
+ ...getPlotDefaults().axis,
65
+ ...getPlotDefaults().axisY
67
66
  };
68
67
 
69
68
  const {
@@ -1,5 +1,4 @@
1
1
  import type { RawValue, ConstantAccessor } from '../types/index.js';
2
- import type * as CSS from 'csstype';
3
2
  declare class __sveltets_Render<Datum extends RawValue> {
4
3
  props(): Omit<Partial<{
5
4
  filter?: ConstantAccessor<boolean, Datum>;
@@ -17,16 +16,16 @@ declare class __sveltets_Render<Datum extends RawValue> {
17
16
  stroke: import("../types/channel").ChannelAccessor<Datum>;
18
17
  strokeWidth: ConstantAccessor<number, Datum>;
19
18
  strokeOpacity: ConstantAccessor<number, Datum>;
20
- strokeLinejoin: ConstantAccessor<CSS.Property.StrokeLinejoin, Datum>;
21
- strokeLinecap: ConstantAccessor<CSS.Property.StrokeLinecap, Datum>;
19
+ strokeLinejoin: ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
20
+ strokeLinecap: ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
22
21
  strokeMiterlimit: ConstantAccessor<number, Datum>;
23
22
  opacity: import("../types/channel").ChannelAccessor<Datum>;
24
23
  strokeDasharray: ConstantAccessor<string, Datum>;
25
24
  strokeDashoffset: ConstantAccessor<number, Datum>;
26
- mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
25
+ mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
27
26
  clipPath: string;
28
27
  imageFilter: ConstantAccessor<string, Datum>;
29
- shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
28
+ shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
30
29
  paintOrder: ConstantAccessor<string, Datum>;
31
30
  onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
32
31
  ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
@@ -60,8 +59,8 @@ declare class __sveltets_Render<Datum extends RawValue> {
60
59
  onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
60
  class?: string;
62
61
  style?: string;
63
- cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
64
- }>, "fillOpacity" | "href" | "target" | "paintOrder" | "title"> & {
62
+ cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
63
+ }>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
65
64
  data?: Datum[] | undefined;
66
65
  automatic?: boolean;
67
66
  title?: string | false | null;
@@ -33,14 +33,14 @@
33
33
  BaseMarkProps,
34
34
  BaseRectMarkProps,
35
35
  ChannelAccessor,
36
- LinkableMarkProps,
37
- PlotDefaults
36
+ LinkableMarkProps
38
37
  } from '../types/index.js';
38
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
39
39
 
40
40
  const DEFAULTS = {
41
41
  fill: 'currentColor',
42
- ...getContext<PlotDefaults>('svelteplot/_defaults').bar,
43
- ...getContext<PlotDefaults>('svelteplot/_defaults').barX
42
+ ...getPlotDefaults().bar,
43
+ ...getPlotDefaults().barX
44
44
  };
45
45
 
46
46
  let markProps: BarXMarkProps = $props();
@@ -14,7 +14,7 @@ declare class __sveltets_Render<Datum extends DataRow> {
14
14
  sort: {
15
15
  channel: string;
16
16
  order?: "ascending" | "descending";
17
- } | ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Datum>;
17
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Datum>;
18
18
  stroke: ChannelAccessor<Datum>;
19
19
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
20
20
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
@@ -34,16 +34,16 @@
34
34
  BaseRectMarkProps,
35
35
  ChannelAccessor,
36
36
  DataRow,
37
- PlotDefaults,
38
37
  LinkableMarkProps
39
38
  } from '../types/index.js';
39
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
40
40
 
41
41
  const { getPlotState } = getContext<PlotContext>('svelteplot');
42
42
  const plot = $derived(getPlotState());
43
43
 
44
44
  const DEFAULTS = {
45
- ...getContext<PlotDefaults>('svelteplot/_defaults').bar,
46
- ...getContext<PlotDefaults>('svelteplot/_defaults').barY
45
+ ...getPlotDefaults().bar,
46
+ ...getPlotDefaults().barY
47
47
  };
48
48
 
49
49
  let markProps: BarYMarkProps = $props();