svelteplot 0.9.1-pr-322.5 → 0.9.1-pr-322.7

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.
@@ -55,8 +55,7 @@
55
55
  stackX(
56
56
  intervalX(
57
57
  // by default, sort by y channel (the ordinal labels)
58
- sort(recordizeX({ data, ...options })),
59
- { plot }
58
+ sort(recordizeX({ data, ...options }))
60
59
  ),
61
60
  stack
62
61
  )
@@ -55,8 +55,7 @@
55
55
  stackY(
56
56
  intervalY(
57
57
  // by default, sort by x channel (the ordinal labels)
58
- sort(recordizeY({ data, ...options })),
59
- { plot }
58
+ sort(recordizeY({ data, ...options }))
60
59
  ),
61
60
  stack
62
61
  )
@@ -47,9 +47,7 @@
47
47
 
48
48
  const plot = usePlot();
49
49
 
50
- const args = $derived(
51
- intervalY(intervalX({ data, ...options }, { plot }), { plot }) as RectMarkProps
52
- );
50
+ const args = $derived(intervalY(intervalX({ data, ...options })) as RectMarkProps);
53
51
  </script>
54
52
 
55
53
  <Mark
@@ -33,7 +33,7 @@
33
33
 
34
34
  const plot = usePlot();
35
35
 
36
- const args = $derived(stackX(intervalY(recordizeX({ data, ...options }), { plot }), stack));
36
+ const args = $derived(stackX(intervalY(recordizeX({ data, ...options })), stack));
37
37
  </script>
38
38
 
39
39
  <Rect {...args}></Rect>
@@ -31,7 +31,7 @@
31
31
 
32
32
  const plot = usePlot();
33
33
 
34
- const args = $derived(stackY(intervalX(recordizeY({ data, ...options }), { plot }), stack));
34
+ const args = $derived(stackY(intervalX(recordizeY({ data, ...options })), stack));
35
35
  </script>
36
36
 
37
37
  <Rect {...args}></Rect>
@@ -64,8 +64,7 @@
64
64
  stackX(
65
65
  intervalX(
66
66
  // by default, sort by y channel (the ordinal labels)
67
- sort(recordizeX({ data, ...options })),
68
- { plot }
67
+ sort(recordizeX({ data, ...options }))
69
68
  ),
70
69
  stack
71
70
  )
@@ -61,8 +61,7 @@
61
61
  stackY(
62
62
  intervalY(
63
63
  // by default, sort by y channel (the ordinal labels)
64
- sort(recordizeY({ data, ...options })),
65
- { plot }
64
+ sort(recordizeY({ data, ...options }))
66
65
  ),
67
66
  stack
68
67
  )
@@ -1,2 +1,5 @@
1
1
  import type { TransformArg } from '../types/index.js';
2
+ /**
3
+ * Filters data based on a function provided via `filter` channels.
4
+ */
2
5
  export declare function filter<T>({ data, ...channels }: TransformArg<T>): TransformArg<T>;
@@ -1,4 +1,7 @@
1
1
  import { testFilter } from '../helpers/index.js';
2
+ /**
3
+ * Filters data based on a function provided via `filter` channels.
4
+ */
2
5
  export function filter({ data, ...channels }) {
3
6
  return {
4
7
  data: data.filter((d) => testFilter(d, channels)),
@@ -1,7 +1,9 @@
1
- import type { PlotState, TransformArg } from '../types/index.js';
2
- export declare function intervalX<T>(args: TransformArg<T>, { plot }: {
3
- plot: PlotState;
4
- }): any;
5
- export declare function intervalY<T>(args: TransformArg<T>, { plot }: {
6
- plot: PlotState;
7
- }): any;
1
+ import type { TransformArg } from '../types/index.js';
2
+ /**
3
+ * Derives interval channels x1 and x2 from the x channel and interval channel.
4
+ */
5
+ export declare function intervalX<T>(args: TransformArg<T>): any;
6
+ /**
7
+ * Derives interval channels y1 and y2 from the y channel and interval channel.
8
+ */
9
+ export declare function intervalY<T>(args: TransformArg<T>): any;
@@ -1,12 +1,18 @@
1
1
  import { maybeInterval } from '../helpers/autoTicks.js';
2
2
  import { resolveChannel } from '../helpers/resolve.js';
3
- export function intervalX(args, { plot }) {
4
- return interval('x', plot, args);
3
+ /**
4
+ * Derives interval channels x1 and x2 from the x channel and interval channel.
5
+ */
6
+ export function intervalX(args) {
7
+ return interval('x', args);
5
8
  }
6
- export function intervalY(args, { plot }) {
7
- return interval('y', plot, args);
9
+ /**
10
+ * Derives interval channels y1 and y2 from the y channel and interval channel.
11
+ */
12
+ export function intervalY(args) {
13
+ return interval('y', args);
8
14
  }
9
- function interval(dim, plot, { data, ...options }) {
15
+ function interval(dim, { data, ...options }) {
10
16
  if (options.interval &&
11
17
  options[dim] &&
12
18
  options[`${dim}1`] == null &&
@@ -1,4 +1,13 @@
1
1
  import type { TransformArg, MapOptions, MapMethod } from '../types/index.js';
2
+ /**
3
+ * Maps one or more positional channels using specified mapping methods.
4
+ */
2
5
  export declare function map<T>(args: TransformArg<T>, options: MapOptions): any;
6
+ /**
7
+ * Maps the x channel values using the specified mapping method.
8
+ */
3
9
  export declare function mapX<T>(args: TransformArg<T>, mapper: MapMethod): any;
10
+ /**
11
+ * Maps the y channel values using the specified mapping method.
12
+ */
4
13
  export declare function mapY<T>(args: TransformArg<T>, mapper: MapMethod): any;
@@ -3,6 +3,9 @@ import { count, rank } from 'd3-array';
3
3
  import { groupFacetsAndZ } from '../helpers/group.js';
4
4
  import { resolveChannel } from '../helpers/resolve.js';
5
5
  import { sort } from './sort';
6
+ /**
7
+ * Maps one or more positional channels using specified mapping methods.
8
+ */
6
9
  export function map(args, options) {
7
10
  const { data, ...channels } = sort(args);
8
11
  const newChannels = {};
@@ -23,6 +26,9 @@ export function map(args, options) {
23
26
  });
24
27
  return { data: newData, ...channels, ...newChannels };
25
28
  }
29
+ /**
30
+ * Maps the x channel values using the specified mapping method.
31
+ */
26
32
  export function mapX(args, mapper) {
27
33
  let { x, x1, x2 } = args;
28
34
  if (x === undefined && x1 === undefined && x2 === undefined)
@@ -36,6 +42,9 @@ export function mapX(args, mapper) {
36
42
  outputs.x2 = mapper;
37
43
  return map(args, outputs);
38
44
  }
45
+ /**
46
+ * Maps the y channel values using the specified mapping method.
47
+ */
39
48
  export function mapY(args, mapper) {
40
49
  let { y, y1, y2 } = args;
41
50
  if (y === undefined && y1 === undefined && y2 === undefined)
@@ -1,6 +1,12 @@
1
1
  import type { TransformArg, MapIndexObject } from '../types/index.js';
2
2
  type NormalizeBasis = 'deviation' | 'first' | 'last' | 'min' | 'max' | 'mean' | 'median' | 'sum' | 'extent' | MapIndexObject;
3
+ /**
4
+ * Normalizes the x values based on the specified basis. Uses mapX.
5
+ */
3
6
  export declare function normalizeX<T>(args: TransformArg<T>, basis: NormalizeBasis): any;
7
+ /**
8
+ * Normalizes the y values based on the specified basis. Uses mapY.
9
+ */
4
10
  export declare function normalizeY<T>(args: TransformArg<T>, basis: NormalizeBasis): any;
5
11
  /**
6
12
  * Convenience wrapper for normalizeY for parallel coordinates.
@@ -1,9 +1,15 @@
1
1
  import { mapX, mapY } from './map.js';
2
2
  import { min, max, mean, median, sum, deviation, extent } from 'd3-array';
3
3
  import { sort } from './sort.js';
4
+ /**
5
+ * Normalizes the x values based on the specified basis. Uses mapX.
6
+ */
4
7
  export function normalizeX(args, basis) {
5
8
  return mapX(args, normalize(basis));
6
9
  }
10
+ /**
11
+ * Normalizes the y values based on the specified basis. Uses mapY.
12
+ */
7
13
  export function normalizeY(args, basis) {
8
14
  return mapY(args, normalize(basis));
9
15
  }
@@ -48,6 +48,10 @@ export type MapIndexObject = {
48
48
  mapIndex: (I: number[], S: RawValue[], T: RawValue[]) => void;
49
49
  };
50
50
  export type MapMethod = 'cumsum' | 'rank' | 'quantile' | ((I: number[], S: number[]) => number[]) | MapIndexObject;
51
+ /**
52
+ * An object specifying mapping methods for one or more scaled channels
53
+ * e.g. ```{ x: 'rank' }```
54
+ */
51
55
  export type MapOptions = Partial<Record<ScaledChannelName, MapMethod>>;
52
56
  export type UsedScales = Record<ScaledChannelName, boolean>;
53
57
  export * from './channel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.9.1-pr-322.5",
3
+ "version": "0.9.1-pr-322.7",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",
@@ -24,10 +24,10 @@
24
24
  "docs": "npm run build && cd build && rsync --recursive . vis4.net:svelteplot/alpha0/",
25
25
  "screenshots": "node screenshot-examples.js",
26
26
  "check-js-extensions": "node scripts/check-js-extensions.js src",
27
- "docs:api:marks": "node scripts/generate-api.js --marks --mark-links && prettier --write .",
27
+ "docs:api:marks": "node scripts/generate-api.js --marks && prettier --write .",
28
28
  "docs:api:plot": "node scripts/generate-api.js --plot",
29
29
  "docs:api:transforms": "node scripts/generate-api.js --transforms",
30
- "docs:api": "node scripts/generate-api.js --marks --mark-links --plot --transforms && prettier --write ."
30
+ "docs:api": "node scripts/generate-api.js --marks --plot --transforms && prettier --write ."
31
31
  },
32
32
  "exports": {
33
33
  ".": {