svelteplot 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +2 -2
  2. package/dist/Mark.svelte +1 -1
  3. package/dist/Plot.svelte +1 -5
  4. package/dist/constants.js +9 -2
  5. package/dist/core/FacetAxes.svelte +14 -3
  6. package/dist/core/FacetGrid.svelte +15 -4
  7. package/dist/core/Plot.svelte +1 -5
  8. package/dist/helpers/autoProjection.d.ts +13 -8
  9. package/dist/helpers/autoProjection.js +1 -1
  10. package/dist/helpers/autoScales.d.ts +1 -1
  11. package/dist/helpers/autoTicks.d.ts +11 -2
  12. package/dist/helpers/autoTicks.js +3 -1
  13. package/dist/helpers/callWithProps.d.ts +1 -3
  14. package/dist/helpers/callWithProps.js +5 -3
  15. package/dist/helpers/colors.d.ts +4 -4
  16. package/dist/helpers/colors.js +4 -3
  17. package/dist/helpers/curves.d.ts +3 -3
  18. package/dist/helpers/getBaseStyles.d.ts +2 -3
  19. package/dist/helpers/getBaseStyles.js +2 -1
  20. package/dist/helpers/group.d.ts +1 -1
  21. package/dist/helpers/group.js +15 -14
  22. package/dist/helpers/math.d.ts +3 -3
  23. package/dist/helpers/math.js +7 -1
  24. package/dist/helpers/resolve.d.ts +1 -1
  25. package/dist/helpers/resolve.js +12 -7
  26. package/dist/helpers/symbols.d.ts +3 -1
  27. package/dist/helpers/typeChecks.d.ts +2 -2
  28. package/dist/marks/CellX.svelte +6 -4
  29. package/dist/marks/CellX.svelte.d.ts +92 -5
  30. package/dist/marks/CellY.svelte +6 -4
  31. package/dist/marks/CellY.svelte.d.ts +92 -5
  32. package/dist/marks/DotX.svelte +3 -2
  33. package/dist/marks/DotX.svelte.d.ts +12 -11
  34. package/dist/marks/WaffleX.svelte +1 -1
  35. package/dist/marks/helpers/BaseAxisX.svelte +3 -1
  36. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -0
  37. package/dist/marks/helpers/BaseAxisY.svelte +4 -2
  38. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -0
  39. package/dist/marks/helpers/Marker.svelte +1 -1
  40. package/dist/transforms/bollinger.d.ts +4 -73
  41. package/dist/transforms/index.d.ts +1 -1
  42. package/dist/transforms/index.js +1 -1
  43. package/dist/transforms/interval.js +1 -1
  44. package/dist/transforms/jitter.d.ts +12 -10
  45. package/dist/transforms/jitter.js +44 -28
  46. package/dist/transforms/map.js +2 -1
  47. package/dist/transforms/recordize.d.ts +5 -5
  48. package/dist/types/data.d.ts +1 -1
  49. package/dist/types/index.d.ts +2 -1
  50. package/dist/types/mark.d.ts +2 -1
  51. package/dist/types/plot.d.ts +2 -0
  52. package/dist/types/scale.d.ts +15 -15
  53. package/package.json +147 -147
@@ -2,13 +2,15 @@
2
2
  @component
3
3
  For arbitrary rectangles with fixed x position, requires band y scale
4
4
  -->
5
- <script lang="ts">
5
+ <script lang="ts" generics="Datum extends DataRow">
6
6
  import Cell from './Cell.svelte';
7
7
  import { recordizeX } from '../index.js';
8
8
  import type { ComponentProps } from 'svelte';
9
- import type { TransformArgsRow } from '../types/index.js';
9
+ import type { DataRow, TransformArgsRow } from '../types/index.js';
10
10
 
11
- interface CellYMarkProps extends Omit<ComponentProps<typeof Cell>, 'x'> {}
11
+ interface CellYMarkProps extends Omit<ComponentProps<typeof Cell>, 'x' | 'data'> {
12
+ data: Datum[];
13
+ }
12
14
 
13
15
  let { data = [{}], ...options }: CellYMarkProps = $props();
14
16
 
@@ -16,7 +18,7 @@
16
18
  recordizeX({
17
19
  data,
18
20
  ...options
19
- } as TransformArgsRow)
21
+ } as TransformArgsRow<Datum>)
20
22
  );
21
23
  </script>
22
24
 
@@ -1,8 +1,95 @@
1
- import Cell from './Cell.svelte';
2
- import type { ComponentProps } from 'svelte';
3
- interface CellYMarkProps extends Omit<ComponentProps<typeof Cell>, 'x'> {
1
+ import type { DataRow } from '../types/index.js';
2
+ declare function $$render<Datum extends DataRow>(): {
3
+ props: Omit<Partial<{
4
+ filter: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/index.js").RawValue>>;
5
+ facet: "auto" | "include" | "exclude";
6
+ fx: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
7
+ fy: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
8
+ dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
9
+ dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
10
+ dodgeX: import("../transforms/dodge").DodgeXOptions;
11
+ dodgeY: import("../transforms/dodge").DodgeYOptions;
12
+ fill: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
13
+ fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
14
+ sort: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
15
+ channel: string;
16
+ order?: "ascending" | "descending";
17
+ } | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Record<string | symbol, import("../types/index.js").RawValue>>;
18
+ stroke: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
19
+ strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
20
+ strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
21
+ strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Record<string | symbol, import("../types/index.js").RawValue>>;
22
+ strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Record<string | symbol, import("../types/index.js").RawValue>>;
23
+ strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
24
+ opacity: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
25
+ strokeDasharray: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
26
+ strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
27
+ mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/index.js").RawValue>>;
28
+ clipPath: string;
29
+ mask: string;
30
+ imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
31
+ shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/index.js").RawValue>>;
32
+ paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").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;
65
+ cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/index.js").RawValue>>;
66
+ }> & import("../types/index.js").LinkableMarkProps<Record<string | symbol, import("../types/index.js").RawValue>> & import("../types/index.js").BaseRectMarkProps<Record<string | symbol, import("../types/index.js").RawValue>> & {
67
+ data: Record<string | symbol, import("../types/index.js").RawValue>[];
68
+ x?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
69
+ y?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
70
+ }, "data" | "x"> & {
71
+ data: Datum[];
72
+ };
73
+ exports: {};
74
+ bindings: "";
75
+ slots: {};
76
+ events: {};
77
+ };
78
+ declare class __sveltets_Render<Datum extends DataRow> {
79
+ props(): ReturnType<typeof $$render<Datum>>['props'];
80
+ events(): ReturnType<typeof $$render<Datum>>['events'];
81
+ slots(): ReturnType<typeof $$render<Datum>>['slots'];
82
+ bindings(): "";
83
+ exports(): {};
84
+ }
85
+ interface $$IsomorphicComponent {
86
+ new <Datum extends DataRow>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Datum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Datum>['props']>, ReturnType<__sveltets_Render<Datum>['events']>, ReturnType<__sveltets_Render<Datum>['slots']>> & {
87
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
88
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
89
+ <Datum extends DataRow>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
90
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
4
91
  }
5
92
  /** For arbitrary rectangles with fixed x position, requires band y scale */
6
- declare const CellY: import("svelte").Component<CellYMarkProps, {}, "">;
7
- type CellY = ReturnType<typeof CellY>;
93
+ declare const CellY: $$IsomorphicComponent;
94
+ type CellY<Datum extends DataRow> = InstanceType<typeof CellY<Datum>>;
8
95
  export default CellY;
@@ -2,12 +2,13 @@
2
2
  Creates a horizontal dot plot with x values along a single y position
3
3
  -->
4
4
  <script lang="ts" generics="Datum extends DataRow">
5
- interface DotXMarkProps extends Omit<ComponentProps<typeof Dot>, 'y' | 'data'> {
5
+ interface DotXMarkProps extends Omit<ComponentProps<typeof Dot>, 'y' | 'x' | 'data'> {
6
6
  data: Datum[];
7
+ x?: ChannelAccessor<Datum>;
7
8
  }
8
9
  import Dot from './Dot.svelte';
9
10
  import { recordizeX } from '../index.js';
10
- import type { DataRow } from '../types/index.js';
11
+ import type { ChannelAccessor, DataRow } from '../types/index.js';
11
12
  import type { ComponentProps } from 'svelte';
12
13
 
13
14
  let { data = [{} as Datum], ...options }: DotXMarkProps = $props();
@@ -1,27 +1,27 @@
1
- import type { DataRow } from '../types/index.js';
1
+ import type { ChannelAccessor, DataRow } from '../types/index.js';
2
2
  declare function $$render<Datum extends DataRow>(): {
3
3
  props: Omit<Partial<{
4
4
  filter: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data").RawValue>>;
5
5
  facet: "auto" | "include" | "exclude";
6
- fx: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
7
- fy: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
6
+ fx: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
7
+ fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
8
8
  dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
9
9
  dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
10
10
  dodgeX: import("../transforms/dodge").DodgeXOptions;
11
11
  dodgeY: import("../transforms/dodge").DodgeYOptions;
12
- fill: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
12
+ fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
13
13
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
14
14
  sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
15
15
  channel: string;
16
16
  order?: "ascending" | "descending";
17
17
  } | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
18
- stroke: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
18
+ stroke: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
19
19
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
20
20
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
21
21
  strokeLinejoin: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Record<string | symbol, import("../types/data").RawValue>>;
22
22
  strokeLinecap: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Record<string | symbol, import("../types/data").RawValue>>;
23
23
  strokeMiterlimit: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
24
- opacity: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
24
+ opacity: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
25
25
  strokeDasharray: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
26
26
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
27
27
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
@@ -65,14 +65,15 @@ declare function $$render<Datum extends DataRow>(): {
65
65
  cursor: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/data").RawValue>>;
66
66
  }> & import("../types/mark").LinkableMarkProps<Record<string | symbol, import("../types/data").RawValue>> & {
67
67
  data: Record<string | symbol, import("../types/data").RawValue>[];
68
- x: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
69
- y: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
70
- r?: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
71
- symbol?: import("../types/channel").ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>> | import("svelte").Snippet<[number, string]>;
68
+ x: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
69
+ y: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
70
+ r?: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
71
+ symbol?: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>> | import("svelte").Snippet<[number, string]>;
72
72
  canvas?: boolean;
73
73
  dotClass?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
74
- }, "data" | "y"> & {
74
+ }, "data" | "x" | "y"> & {
75
75
  data: Datum[];
76
+ x?: ChannelAccessor<Datum>;
76
77
  };
77
78
  exports: {};
78
79
  bindings: "";
@@ -95,7 +95,7 @@
95
95
  <g class={['waffle-x', className]}>
96
96
  <pattern {...pattern}>
97
97
  {#if symbol}
98
- {@render symbol(rect)}
98
+ {@render symbol({ ...rect, style, styleClass, datum: d.datum })}
99
99
  {:else if hasBorderRadius}
100
100
  <path
101
101
  d={roundedRect(rect.x, rect.y, rect.width, rect.height, borderRadius)}
@@ -42,6 +42,7 @@
42
42
  };
43
43
  text: boolean;
44
44
  plot: PlotState;
45
+ class: string;
45
46
  };
46
47
 
47
48
  let {
@@ -59,6 +60,7 @@
59
60
  options,
60
61
  plot,
61
62
  title,
63
+ class: className = 'axis-x',
62
64
  text = true
63
65
  }: BaseAxisXProps = $props();
64
66
 
@@ -176,7 +178,7 @@
176
178
  });
177
179
  </script>
178
180
 
179
- <g class="axis-x">
181
+ <g class={className}>
180
182
  {#each positionedTicks as tick, t (tick[RAW_VALUE])}
181
183
  {#if testFilter(tick, options) && !tick.hidden}
182
184
  {@const tickClass_ = resolveProp(tickClass, tick)}
@@ -22,6 +22,7 @@ type BaseAxisXProps = {
22
22
  };
23
23
  text: boolean;
24
24
  plot: PlotState;
25
+ class: string;
25
26
  };
26
27
  declare const BaseAxisX: import("svelte").Component<BaseAxisXProps, {}, "">;
27
28
  type BaseAxisX = ReturnType<typeof BaseAxisX>;
@@ -36,6 +36,7 @@
36
36
  };
37
37
  plot: PlotState;
38
38
  text: boolean | null;
39
+ class: string;
39
40
  };
40
41
 
41
42
  let {
@@ -54,7 +55,8 @@
54
55
  title,
55
56
  plot,
56
57
  options,
57
- text = true
58
+ text = true,
59
+ class: className = 'axis-y'
58
60
  }: BaseAxisYProps = $props();
59
61
 
60
62
  const LINE_ANCHOR = {
@@ -153,7 +155,7 @@
153
155
  });
154
156
  </script>
155
157
 
156
- <g class="axis-y">
158
+ <g class={className}>
157
159
  {#each positionedTicks as tick, t (tick[RAW_VALUE])}
158
160
  {#if testFilter(tick, options) && !tick.hidden}
159
161
  {@const tickClass_ = resolveProp(tickClass, tick)}
@@ -20,6 +20,7 @@ type BaseAxisYProps = {
20
20
  };
21
21
  plot: PlotState;
22
22
  text: boolean | null;
23
+ class: string;
23
24
  };
24
25
  declare const BaseAxisY: import("svelte").Component<BaseAxisYProps, {}, "">;
25
26
  type BaseAxisY = ReturnType<typeof BaseAxisY>;
@@ -74,7 +74,7 @@
74
74
  const markerColors = $derived({
75
75
  fill: 'none',
76
76
  [MARKERS[shape].color]: color,
77
- ...(MARKERS[shape].bg ? { [MARKERS[shape].bg as string]: 'var(--svelteplot-bg)' } : {})
77
+ ...(MARKERS[shape].bg ? { [MARKERS[shape].bg as string]: 'var(--svp-bg)' } : {})
78
78
  });
79
79
  </script>
80
80
 
@@ -1,4 +1,4 @@
1
- import type { DataRecord, TransformArg } from '../types/index.js';
1
+ import type { TransformArg } from '../types/index.js';
2
2
  export type BollingerOptions = {
3
3
  /**
4
4
  * the window size (the window transform’s k option), an integer; defaults to 20
@@ -9,75 +9,6 @@ export type BollingerOptions = {
9
9
  */
10
10
  k?: number;
11
11
  };
12
- export declare function bollingerX(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
13
- export declare function bollingerY(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
14
- export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): {
15
- filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/index.js").RawValue>>;
16
- facet?: "auto" | "include" | "exclude" | undefined;
17
- fx?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
18
- fy?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
19
- dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
20
- dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
21
- dodgeX?: import("./dodge").DodgeXOptions | undefined;
22
- dodgeY?: import("./dodge").DodgeYOptions | undefined;
23
- fill?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
24
- fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
25
- sort?: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
26
- channel: string;
27
- order?: "ascending" | "descending";
28
- } | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Record<string | symbol, import("../types/index.js").RawValue>>;
29
- stroke?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
30
- strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
31
- strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
32
- strokeLinejoin?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Record<string | symbol, import("../types/index.js").RawValue>>;
33
- strokeLinecap?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Record<string | symbol, import("../types/index.js").RawValue>>;
34
- strokeMiterlimit?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
35
- opacity?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
36
- strokeDasharray?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
37
- strokeDashoffset?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
38
- mixBlendMode?: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/index.js").RawValue>>;
39
- clipPath?: string | undefined;
40
- mask?: string | undefined;
41
- imageFilter?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
42
- shapeRendering?: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/index.js").RawValue>>;
43
- paintOrder?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
44
- onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
45
- ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
46
- onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
47
- onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
48
- onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
49
- onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
50
- onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
51
- onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
52
- onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
53
- onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
54
- onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
55
- onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
56
- onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
57
- onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
58
- onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
59
- onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
60
- onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
61
- ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
62
- ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
63
- ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
64
- ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
65
- ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
66
- ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
67
- ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
68
- ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
69
- ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
70
- ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
71
- ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
72
- oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
73
- onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
74
- class?: string | undefined;
75
- style?: string | undefined;
76
- cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/index.js").RawValue>>;
77
- data: {
78
- __x: import("../types/index.js").RawValue;
79
- __lo: number;
80
- __avg: number;
81
- __hi: number;
82
- }[];
83
- };
12
+ export declare function bollingerX<T>(args: TransformArg<T>, options?: BollingerOptions): TransformArg<T>;
13
+ export declare function bollingerY<T>(args: TransformArg<T>, options?: BollingerOptions): TransformArg<T>;
14
+ export declare function bollingerDim<T>(dim: 'x' | 'y', { data, ...channels }: TransformArg<T>, options?: BollingerOptions): TransformArg<T>;
@@ -7,7 +7,7 @@ export { map, mapX, mapY } from './map.js';
7
7
  export { normalizeX, normalizeY, normalizeParallelX, normalizeParallelY } from './normalize.js';
8
8
  export { group, groupX, groupY, groupZ } from './group.js';
9
9
  export { intervalX, intervalY } from './interval.js';
10
- export { jitterX, jitterY } from './jitter.js';
10
+ export { jitter, jitterX, jitterY } from './jitter.js';
11
11
  export { recordizeX, recordizeY } from './recordize.js';
12
12
  export { renameChannels, replaceChannels } from './rename.js';
13
13
  export { select, selectFirst, selectLast, selectMaxX, selectMaxY, selectMinX, selectMinY } from './select.js';
@@ -7,7 +7,7 @@ export { map, mapX, mapY } from './map.js';
7
7
  export { normalizeX, normalizeY, normalizeParallelX, normalizeParallelY } from './normalize.js';
8
8
  export { group, groupX, groupY, groupZ } from './group.js';
9
9
  export { intervalX, intervalY } from './interval.js';
10
- export { jitterX, jitterY } from './jitter.js';
10
+ export { jitter, jitterX, jitterY } from './jitter.js';
11
11
  export { recordizeX, recordizeY } from './recordize.js';
12
12
  export { renameChannels, replaceChannels } from './rename.js';
13
13
  export { select, selectFirst, selectLast, selectMaxX, selectMaxY, selectMinX, selectMinY } from './select.js';
@@ -12,7 +12,7 @@ function interval(dim, plot, { data, ...options }) {
12
12
  options[`${dim}1`] == null &&
13
13
  options[`${dim}2`] == null) {
14
14
  // derive x1 and x2 from x+interval
15
- const interval = maybeInterval(options.interval, plot.scales[dim].type);
15
+ const interval = maybeInterval(options.interval);
16
16
  const newData = data.map((row) => {
17
17
  const val = resolveChannel(dim, row, options);
18
18
  return {
@@ -1,17 +1,19 @@
1
- import type { Channels, DataRecord, TransformArg } from '../types/index.js';
1
+ import type { TransformArg, TransformReturn } from '../types/index.js';
2
2
  type JitterOptions = {
3
- type: 'uniform' | 'normal';
4
- /** width for uniform jittering */
5
- width: number;
6
- /** standard deviation for normal jittering */
7
- std: number;
8
3
  /**
9
4
  * optional random number source that produces values in range [0,1)
10
5
  * useful for testing with a deterministic source
11
6
  */
12
7
  source?: () => number;
13
- };
14
- export declare function jitterX({ data, ...channels }: TransformArg<DataRecord>, options: JitterOptions): TransformArg<DataRecord>;
15
- export declare function jitterY({ data, ...channels }: TransformArg<DataRecord>, options: JitterOptions): TransformArg<DataRecord>;
16
- export declare function jitter(channel: 'x' | 'y', data: DataRecord[], channels: Channels, options: JitterOptions): TransformArg<DataRecord>;
8
+ } & ({
9
+ type: 'uniform';
10
+ width?: number | string;
11
+ } | {
12
+ type: 'normal';
13
+ std?: number | string;
14
+ });
15
+ export declare function jitterX<T>(args: TransformArg<T>, options: JitterOptions): TransformReturn<T, 'x'>;
16
+ export declare function jitterY<T>(args: TransformArg<T>, options: JitterOptions): TransformReturn<T, 'y'>;
17
+ type PositionalScale = 'x' | 'x1' | 'x2' | 'y' | 'y1' | 'y2';
18
+ export declare function jitter<T, C extends TransformArg<T>>({ data, ...channels }: C, options: Partial<Record<PositionalScale, JitterOptions>>): TransformReturn<C, T>;
17
19
  export {};
@@ -2,46 +2,62 @@ import { resolveChannel } from '../helpers/resolve.js';
2
2
  import { randomUniform, randomNormal } from 'd3-random';
3
3
  import { isDate } from '../helpers/typeChecks.js';
4
4
  import { durations, parseTimeInterval } from '../helpers/time.js';
5
- const JITTER_X = Symbol('jitterX');
6
- const JITTER_Y = Symbol('jitterY');
7
- export function jitterX({ data, ...channels }, options) {
8
- return jitter('x', data, channels, options);
5
+ const JITTER = {
6
+ x: Symbol('jitterX'),
7
+ x1: Symbol('jitterX1'),
8
+ x2: Symbol('jitterX2'),
9
+ y: Symbol('jitterY'),
10
+ y1: Symbol('jitterY1'),
11
+ y2: Symbol('jitterY2')
12
+ };
13
+ export function jitterX(args, options) {
14
+ return jitter(args, { x: options });
9
15
  }
10
- export function jitterY({ data, ...channels }, options) {
11
- return jitter('y', data, channels, options);
16
+ export function jitterY(args, options) {
17
+ return jitter(args, { y: options });
12
18
  }
13
- export function jitter(channel, data, channels, options) {
14
- if (channels[channel]) {
15
- const type = options?.type ?? 'uniform';
16
- const width = parseNumber(options?.width ?? 0.35);
17
- const std = parseNumber(options?.std ?? 0.15);
19
+ export function jitter({ data, ...channels }, options) {
20
+ const jitterChannels = Object.keys(options).filter((ch) => channels[ch]);
21
+ // if no jitter channels are defined return early
22
+ if (!jitterChannels.length)
23
+ return {
24
+ data,
25
+ ...channels
26
+ };
27
+ // construct jitter functions
28
+ const jitterFns = Object.fromEntries(Object.entries(options).map(([key, opts]) => {
29
+ opts.type = opts.type ?? 'uniform';
30
+ const width = opts?.type === 'uniform' ? parseNumber(opts?.width ?? 0.35) : 0;
31
+ const std = opts?.type === 'normal' ? parseNumber(opts?.std ?? 0.15) : 0;
18
32
  // @todo support time interval strings as width/std parameters
19
33
  // Use the provided source or default to Math.random
20
- const rng = options?.source ?? Math.random;
21
- const random = type === 'uniform'
34
+ const rng = opts?.source ?? Math.random;
35
+ const random = opts?.type === 'uniform'
22
36
  ? randomUniform.source(rng)(-width, width)
23
37
  : randomNormal.source(rng)(0, std);
24
- const accKey = channel === 'x' ? JITTER_X : JITTER_Y;
25
- return {
26
- data: data.map((row) => {
38
+ return [key, random];
39
+ }));
40
+ return {
41
+ data: data.map((row) => {
42
+ let newRow = { ...row };
43
+ jitterChannels.forEach((channel) => {
27
44
  const value = resolveChannel(channel, row, channels);
28
- return {
29
- ...row,
45
+ const random = jitterFns[channel];
46
+ const accKey = JITTER[channel];
47
+ newRow = {
48
+ ...newRow,
30
49
  [accKey]: typeof value === 'number'
31
50
  ? value + random()
32
51
  : isDate(value)
33
52
  ? new Date(value.getTime() + random())
34
53
  : value
35
54
  };
36
- }),
37
- ...channels,
38
- // point channel to new accessor symbol
39
- [channel]: accKey
40
- };
41
- }
42
- return {
43
- data,
44
- ...channels
55
+ });
56
+ return newRow;
57
+ }),
58
+ ...channels,
59
+ // point the jittered channels to new accessor symbols
60
+ ...Object.fromEntries(jitterChannels.map((channel) => [channel, JITTER[channel]]))
45
61
  };
46
62
  }
47
63
  function parseNumber(value) {
@@ -50,7 +66,7 @@ function parseNumber(value) {
50
66
  if (typeof value === 'string') {
51
67
  try {
52
68
  const [name, period] = parseTimeInterval(value);
53
- return durations.get(name) * period;
69
+ return (durations.get(name) ?? 0) * period;
54
70
  }
55
71
  catch (err) {
56
72
  return 0;
@@ -2,8 +2,9 @@ import { identity } from '../helpers/index.js';
2
2
  import { count, rank } from 'd3-array';
3
3
  import { groupFacetsAndZ } from '../helpers/group.js';
4
4
  import { resolveChannel } from '../helpers/resolve.js';
5
+ import { sort } from './sort';
5
6
  export function map(args, options) {
6
- const { data, ...channels } = args;
7
+ const { data, ...channels } = sort(args);
7
8
  const newChannels = {};
8
9
  const newData = [];
9
10
  groupFacetsAndZ(data, channels, (groupedData) => {
@@ -1,4 +1,4 @@
1
- import type { TransformArgsRow, TransformArgsRecord } from '../types/index.js';
1
+ import type { TransformArgsRow, TransformArgsRecord, DataRecord, DataRow } from '../types/index.js';
2
2
  import { INDEX } from '../constants';
3
3
  export declare const X: unique symbol;
4
4
  export declare const Y: unique symbol;
@@ -6,12 +6,12 @@ export declare const RAW_VALUE: unique symbol;
6
6
  export declare function indexData<T extends object>(data: T[]): (T & {
7
7
  [INDEX]: number;
8
8
  })[];
9
- export declare function recordizeX<T>({ data, ...channels }: TransformArgsRow<T>, { withIndex }?: {
9
+ export declare function recordizeX<T>({ data, ...channels }: TransformArgsRow<DataRow>, { withIndex }?: {
10
10
  withIndex: boolean;
11
- }): TransformArgsRecord<T>;
12
- export declare function recordizeY<T>({ data, ...channels }: TransformArgsRow<T>, { withIndex }?: {
11
+ }): TransformArgsRecord<DataRecord>;
12
+ export declare function recordizeY<T>({ data, ...channels }: TransformArgsRow<DataRow>, { withIndex }?: {
13
13
  withIndex: boolean;
14
- }): TransformArgsRecord<T>;
14
+ }): TransformArgsRecord<DataRecord>;
15
15
  /**
16
16
  * This transform is used to allow users to pass an [[x0, y0], [x1, y1], ...] array
17
17
  * as dataset to marks that support it. It transforms the arrays into records, so
@@ -1,5 +1,5 @@
1
1
  import type { ScaledChannelName, ScaledChannelType } from './channel.js';
2
- export type RawValue = number | Date | boolean | string | symbol | object;
2
+ export type RawValue = number | Date | boolean | string | symbol | object | null;
3
3
  export type DataRecord<T = Record<string | symbol, RawValue>> = T;
4
4
  export type ResolvedDataRecord<T = Record<string | symbol, RawValue>> = Partial<Record<ScaledChannelName, any>> & {
5
5
  datum: DataRecord<T>;
@@ -31,12 +31,13 @@ export type TransformArg<T> = Channels<T> & BaseMarkProps<T> & {
31
31
  export type MapArg<T> = Channels<T> & {
32
32
  data: T[];
33
33
  };
34
- export type TransformArgsRow<T extends RawValue & object> = Partial<Channels<T>> & {
34
+ export type TransformArgsRow<T extends RawValue | object> = Partial<Channels<T>> & {
35
35
  data: T[];
36
36
  };
37
37
  export type TransformArgsRecord<T extends object> = Partial<Channels<T>> & {
38
38
  data: T[];
39
39
  };
40
+ export type TransformReturn<C extends TransformArg<T>, T> = C & Required<Pick<Channels<T>, 'data'>>;
40
41
  export type AutoMarginStores = {
41
42
  autoMarginTop: Writable<Map<string, number>>;
42
43
  autoMarginLeft: Writable<Map<string, number>>;
@@ -11,7 +11,8 @@ export type MarkStyleProps = 'strokeDasharray' | 'strokeLinejoin' | 'strokeLinec
11
11
  import type { MouseEventHandler } from 'svelte/elements';
12
12
  import type { ChannelAccessor, ConstantAccessor, DataRecord, RawValue } from './index.js';
13
13
  import type * as CSS from 'csstype';
14
- import type { ScaledChannelName, ScaleName } from './scale.js';
14
+ import type { ScaledChannelName } from './channel.js';
15
+ import type { ScaleName } from './scale.js';
15
16
  import type { DodgeXOptions, DodgeYOptions } from '../transforms/dodge.js';
16
17
  export type BaseMarkProps<T> = Partial<{
17
18
  /**