svelteplot 0.10.2 → 0.10.3-pr-370.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.
- package/LICENSE.md +1 -1
- package/dist/Mark.svelte.d.ts +4 -4
- package/dist/constants.d.ts +1 -1
- package/dist/helpers/colors.d.ts +8 -11
- package/dist/helpers/curves.d.ts +2 -2
- package/dist/helpers/facets.d.ts +1 -1
- package/dist/helpers/getBaseStyles.d.ts +2 -4
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/reduce.d.ts +1 -1
- package/dist/helpers/scales.d.ts +7 -7
- package/dist/helpers/symbols.d.ts +1 -1
- package/dist/helpers/time.d.ts +3 -3
- package/dist/helpers/typeChecks.d.ts +4 -4
- package/dist/marks/Area.svelte.d.ts +5 -4
- package/dist/marks/AreaX.svelte.d.ts +4 -4
- package/dist/marks/AreaY.svelte.d.ts +4 -4
- package/dist/marks/Arrow.svelte.d.ts +5 -4
- package/dist/marks/AxisX.svelte +13 -0
- package/dist/marks/AxisX.svelte.d.ts +19 -5
- package/dist/marks/AxisY.svelte +15 -0
- package/dist/marks/AxisY.svelte.d.ts +21 -5
- package/dist/marks/BarX.svelte.d.ts +4 -4
- package/dist/marks/BarY.svelte.d.ts +5 -4
- package/dist/marks/BollingerX.svelte +3 -0
- package/dist/marks/BollingerX.svelte.d.ts +2 -77
- package/dist/marks/BollingerY.svelte +3 -0
- package/dist/marks/BollingerY.svelte.d.ts +2 -77
- package/dist/marks/BoxY.svelte +3 -0
- package/dist/marks/BoxY.svelte.d.ts +4 -64
- package/dist/marks/Brush.svelte +4 -0
- package/dist/marks/Brush.svelte.d.ts +5 -64
- package/dist/marks/Cell.svelte.d.ts +5 -4
- package/dist/marks/CellX.svelte.d.ts +30 -30
- package/dist/marks/CellY.svelte.d.ts +30 -30
- package/dist/marks/ColorLegend.svelte +1 -0
- package/dist/marks/ColorLegend.svelte.d.ts +1 -0
- package/dist/marks/CustomMark.svelte +11 -0
- package/dist/marks/CustomMark.svelte.d.ts +2 -85
- package/dist/marks/CustomMarkHTML.svelte +6 -0
- package/dist/marks/CustomMarkHTML.svelte.d.ts +6 -0
- package/dist/marks/DifferenceY.svelte +5 -1
- package/dist/marks/DifferenceY.svelte.d.ts +8 -64
- package/dist/marks/Dot.svelte.d.ts +5 -4
- package/dist/marks/DotX.svelte.d.ts +5 -5
- package/dist/marks/DotY.svelte.d.ts +5 -5
- package/dist/marks/Frame.svelte +11 -0
- package/dist/marks/Frame.svelte.d.ts +17 -5
- package/dist/marks/Geo.svelte +3 -0
- package/dist/marks/Geo.svelte.d.ts +8 -4
- package/dist/marks/Graticule.svelte +3 -0
- package/dist/marks/Graticule.svelte.d.ts +3 -0
- package/dist/marks/GridX.svelte +4 -0
- package/dist/marks/GridX.svelte.d.ts +9 -4
- package/dist/marks/GridY.svelte +4 -0
- package/dist/marks/GridY.svelte.d.ts +9 -4
- package/dist/marks/HTMLTooltip.svelte +7 -0
- package/dist/marks/HTMLTooltip.svelte.d.ts +7 -0
- package/dist/marks/Image.svelte.d.ts +5 -4
- package/dist/marks/Line.svelte.d.ts +4 -4
- package/dist/marks/LineX.svelte.d.ts +6 -6
- package/dist/marks/LineY.svelte.d.ts +6 -6
- package/dist/marks/Link.svelte +3 -1
- package/dist/marks/Link.svelte.d.ts +8 -4
- package/dist/marks/Pointer.svelte +7 -0
- package/dist/marks/Pointer.svelte.d.ts +7 -0
- package/dist/marks/Rect.svelte.d.ts +5 -4
- package/dist/marks/RuleX.svelte.d.ts +5 -4
- package/dist/marks/RuleY.svelte.d.ts +5 -4
- package/dist/marks/Spike.svelte +6 -0
- package/dist/marks/Spike.svelte.d.ts +11 -5
- package/dist/marks/Text.svelte.d.ts +9 -8
- package/dist/marks/TickX.svelte +2 -0
- package/dist/marks/TickX.svelte.d.ts +7 -4
- package/dist/marks/TickY.svelte +5 -3
- package/dist/marks/TickY.svelte.d.ts +10 -7
- package/dist/marks/Trail.svelte +11 -0
- package/dist/marks/Trail.svelte.d.ts +12 -64
- package/dist/marks/Vector.svelte +9 -0
- package/dist/marks/Vector.svelte.d.ts +14 -4
- package/dist/marks/WaffleX.svelte +6 -4
- package/dist/marks/WaffleX.svelte.d.ts +2 -86
- package/dist/marks/WaffleY.svelte +5 -4
- package/dist/marks/WaffleY.svelte.d.ts +10 -8
- package/dist/marks/helpers/Box.svelte.d.ts +1 -64
- package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -107
- package/dist/marks/helpers/Regression.svelte +6 -3
- package/dist/marks/helpers/Regression.svelte.d.ts +6 -0
- package/dist/transforms/bollinger.d.ts +8 -0
- package/dist/transforms/bollinger.js +8 -0
- package/dist/transforms/centroid.d.ts +5 -4
- package/dist/transforms/centroid.js +4 -0
- package/dist/transforms/dodge.d.ts +11 -0
- package/dist/transforms/dodge.js +6 -0
- package/dist/transforms/interval.d.ts +8 -8
- package/dist/transforms/jitter.d.ts +9 -0
- package/dist/transforms/jitter.js +9 -0
- package/dist/transforms/recordize.d.ts +16 -7
- package/dist/transforms/recordize.js +10 -6
- package/dist/transforms/rename.d.ts +5 -1
- package/dist/transforms/rename.js +4 -0
- package/dist/transforms/select.d.ts +36 -28
- package/dist/transforms/select.js +8 -0
- package/dist/transforms/shift.d.ts +8 -0
- package/dist/transforms/shift.js +6 -0
- package/dist/transforms/sort.d.ts +18 -19
- package/dist/transforms/sort.js +4 -0
- package/dist/transforms/stack.d.ts +32 -12
- package/dist/transforms/stack.js +14 -0
- package/dist/transforms/window.d.ts +13 -136
- package/dist/transforms/window.js +6 -0
- package/dist/types/channel.d.ts +12 -0
- package/dist/types/data.d.ts +13 -0
- package/dist/types/facet.d.ts +5 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/mark.d.ts +62 -0
- package/dist/types/plot.d.ts +31 -0
- package/dist/types/scale.d.ts +98 -0
- package/package.json +13 -5
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { BaseMarkProps, ChannelAccessor } from '../../types/index.js';
|
|
2
2
|
type RegressionType = 'linear' | 'quad' | 'poly' | 'exp' | 'log' | 'pow' | 'loess';
|
|
3
3
|
export type RegressionMarkProps = BaseMarkProps & {
|
|
4
|
+
/** the horizontal position channel; bound to the x scale */
|
|
4
5
|
x: ChannelAccessor;
|
|
6
|
+
/** the vertical position channel; bound to the y scale */
|
|
5
7
|
y: ChannelAccessor;
|
|
8
|
+
/** the regression model type */
|
|
6
9
|
type: RegressionType;
|
|
7
10
|
/**
|
|
8
11
|
* If order is specified, sets the regression's order to the specified number.
|
|
@@ -14,8 +17,11 @@ export type RegressionMarkProps = BaseMarkProps & {
|
|
|
14
17
|
* it may have little predictive power for data outside of your domain.
|
|
15
18
|
*/
|
|
16
19
|
order: number;
|
|
20
|
+
/** the base for logarithmic regression */
|
|
17
21
|
base: number;
|
|
22
|
+
/** the bandwidth for LOESS regression, as a fraction of the data range (0 to 1) */
|
|
18
23
|
span: number;
|
|
24
|
+
/** the confidence level for confidence bands (e.g. 0.95 for 95% confidence) */
|
|
19
25
|
confidence: number;
|
|
20
26
|
};
|
|
21
27
|
declare const Regression: import("svelte").Component<any, {}, "">;
|
|
@@ -9,6 +9,14 @@ export type BollingerOptions = {
|
|
|
9
9
|
*/
|
|
10
10
|
k?: number;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* computes Bollinger bands for the x channel, producing x1 (lower), x (mean),
|
|
14
|
+
* and x2 (upper) channels
|
|
15
|
+
*/
|
|
12
16
|
export declare function bollingerX<T>(args: TransformArg<T>, options?: BollingerOptions): TransformArg<T>;
|
|
17
|
+
/**
|
|
18
|
+
* computes Bollinger bands for the y channel, producing y1 (lower), y (mean),
|
|
19
|
+
* and y2 (upper) channels
|
|
20
|
+
*/
|
|
13
21
|
export declare function bollingerY<T>(args: TransformArg<T>, options?: BollingerOptions): TransformArg<T>;
|
|
14
22
|
export declare function bollingerDim<T>(dim: 'x' | 'y', { data, ...channels }: TransformArg<T>, options?: BollingerOptions): TransformArg<T>;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
2
|
+
/**
|
|
3
|
+
* computes Bollinger bands for the x channel, producing x1 (lower), x (mean),
|
|
4
|
+
* and x2 (upper) channels
|
|
5
|
+
*/
|
|
2
6
|
export function bollingerX(args, options = {}) {
|
|
3
7
|
return bollingerDim('x', args, options);
|
|
4
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* computes Bollinger bands for the y channel, producing y1 (lower), y (mean),
|
|
11
|
+
* and y2 (upper) channels
|
|
12
|
+
*/
|
|
5
13
|
export function bollingerY(args, options = {}) {
|
|
6
14
|
return bollingerDim('y', args, options);
|
|
7
15
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DataRecord, TransformArg } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type WithCentroid<T> = T & {};
|
|
3
|
+
/**
|
|
4
|
+
* computes the geographic centroid of each geometry feature, producing
|
|
5
|
+
* x (longitude) and y (latitude) channels
|
|
6
|
+
*/
|
|
6
7
|
export declare function geoCentroid<Datum extends DataRecord>({ data, ...options }: {
|
|
7
8
|
data: Datum[];
|
|
8
9
|
} & TransformArg<Datum>): TransformArg<WithCentroid<Datum>>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { resolveProp } from '../helpers/resolve.js';
|
|
2
2
|
import { geoCentroid as d3GeoCentroid } from 'd3-geo';
|
|
3
3
|
const CENTROID = Symbol('centroid');
|
|
4
|
+
/**
|
|
5
|
+
* computes the geographic centroid of each geometry feature, producing
|
|
6
|
+
* x (longitude) and y (latitude) channels
|
|
7
|
+
*/
|
|
4
8
|
export function geoCentroid({ data, ...options }) {
|
|
5
9
|
const transformedData = data.map((d) => ({
|
|
6
10
|
...d,
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import type { ScaledDataRecord, TransformArg, PlotState } from '../types';
|
|
2
2
|
type BaseDodgeOptions = {
|
|
3
|
+
/** the anchor side for placing dodged marks */
|
|
3
4
|
anchor?: string;
|
|
5
|
+
/** the padding between dodged marks, in pixels */
|
|
4
6
|
padding?: number;
|
|
7
|
+
/** the radius of dodged marks, in pixels */
|
|
5
8
|
r?: number;
|
|
6
9
|
};
|
|
7
10
|
type AnchorX = 'left' | 'right' | 'middle';
|
|
8
11
|
type AnchorY = 'top' | 'bottom' | 'middle';
|
|
12
|
+
/** options for horizontal dodge positioning; can be an anchor string or a full options object */
|
|
9
13
|
export type DodgeXOptions = AnchorX | (BaseDodgeOptions & {
|
|
10
14
|
anchor?: 'left' | 'right' | 'middle';
|
|
11
15
|
});
|
|
16
|
+
/** options for vertical dodge positioning; can be an anchor string or a full options object */
|
|
12
17
|
export type DodgeYOptions = AnchorY | (BaseDodgeOptions & {
|
|
13
18
|
anchor?: 'top' | 'bottom' | 'middle';
|
|
14
19
|
});
|
|
20
|
+
/**
|
|
21
|
+
* offsets marks horizontally to avoid overlap, using circle-packing
|
|
22
|
+
*/
|
|
15
23
|
export declare function dodgeX(args: TransformArg<ScaledDataRecord>, plotState: PlotState): ScaledDataRecord[];
|
|
24
|
+
/**
|
|
25
|
+
* offsets marks vertically to avoid overlap, using circle-packing
|
|
26
|
+
*/
|
|
16
27
|
export declare function dodgeY(args: TransformArg<ScaledDataRecord>, plotState: PlotState): ScaledDataRecord[];
|
|
17
28
|
export {};
|
package/dist/transforms/dodge.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import IntervalTree from 'interval-tree-1d';
|
|
2
2
|
import { groupFacetsAndZ } from '../helpers/group';
|
|
3
|
+
/**
|
|
4
|
+
* offsets marks horizontally to avoid overlap, using circle-packing
|
|
5
|
+
*/
|
|
3
6
|
export function dodgeX(args, plotState) {
|
|
4
7
|
if (!args.dodgeX)
|
|
5
8
|
return args.data;
|
|
@@ -20,6 +23,9 @@ export function dodgeX(args, plotState) {
|
|
|
20
23
|
}
|
|
21
24
|
return dodge('x', 'y', anchorFunction, Number(padding), r, args, plotState);
|
|
22
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* offsets marks vertically to avoid overlap, using circle-packing
|
|
28
|
+
*/
|
|
23
29
|
export function dodgeY(args, plotState) {
|
|
24
30
|
if (!args.dodgeY)
|
|
25
31
|
return args.data;
|
|
@@ -9,14 +9,14 @@ export declare function intervalX<T>(args: TransformArg<T>): {
|
|
|
9
9
|
fy?: import("../types/channel.js").ChannelAccessor<T>;
|
|
10
10
|
dx?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
11
11
|
dy?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
12
|
-
dodgeX?:
|
|
13
|
-
dodgeY?:
|
|
12
|
+
dodgeX?: DodgeXOptions;
|
|
13
|
+
dodgeY?: DodgeYOptions;
|
|
14
14
|
fill?: import("../types/channel.js").ChannelAccessor<T>;
|
|
15
15
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
16
|
-
sort?:
|
|
16
|
+
sort?: {
|
|
17
17
|
channel: string;
|
|
18
18
|
order?: "ascending" | "descending";
|
|
19
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, T>;
|
|
19
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, T>;
|
|
20
20
|
stroke?: import("../types/channel.js").ChannelAccessor<T>;
|
|
21
21
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
22
22
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
@@ -77,14 +77,14 @@ export declare function intervalY<T>(args: TransformArg<T>): {
|
|
|
77
77
|
fy?: import("../types/channel.js").ChannelAccessor<T>;
|
|
78
78
|
dx?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
79
79
|
dy?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
80
|
-
dodgeX?:
|
|
81
|
-
dodgeY?:
|
|
80
|
+
dodgeX?: DodgeXOptions;
|
|
81
|
+
dodgeY?: DodgeYOptions;
|
|
82
82
|
fill?: import("../types/channel.js").ChannelAccessor<T>;
|
|
83
83
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
84
|
-
sort?:
|
|
84
|
+
sort?: {
|
|
85
85
|
channel: string;
|
|
86
86
|
order?: "ascending" | "descending";
|
|
87
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, T>;
|
|
87
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, T>;
|
|
88
88
|
stroke?: import("../types/channel.js").ChannelAccessor<T>;
|
|
89
89
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
90
90
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, T>;
|
|
@@ -12,8 +12,17 @@ type JitterOptions = {
|
|
|
12
12
|
type: 'normal';
|
|
13
13
|
std?: number | string;
|
|
14
14
|
});
|
|
15
|
+
/**
|
|
16
|
+
* adds random noise to the x channel values
|
|
17
|
+
*/
|
|
15
18
|
export declare function jitterX<T>(args: TransformArg<T>, options: JitterOptions): TransformReturn<T, 'x'>;
|
|
19
|
+
/**
|
|
20
|
+
* adds random noise to the y channel values
|
|
21
|
+
*/
|
|
16
22
|
export declare function jitterY<T>(args: TransformArg<T>, options: JitterOptions): TransformReturn<T, 'y'>;
|
|
17
23
|
type PositionalScale = 'x' | 'x1' | 'x2' | 'y' | 'y1' | 'y2';
|
|
24
|
+
/**
|
|
25
|
+
* adds random noise to one or more positional channels
|
|
26
|
+
*/
|
|
18
27
|
export declare function jitter<T, C extends TransformArg<T>>({ data, ...channels }: C, options: Partial<Record<PositionalScale, JitterOptions>>): TransformReturn<C, T>;
|
|
19
28
|
export {};
|
|
@@ -10,12 +10,21 @@ const JITTER = {
|
|
|
10
10
|
y1: Symbol('jitterY1'),
|
|
11
11
|
y2: Symbol('jitterY2')
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* adds random noise to the x channel values
|
|
15
|
+
*/
|
|
13
16
|
export function jitterX(args, options) {
|
|
14
17
|
return jitter(args, { x: options });
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* adds random noise to the y channel values
|
|
21
|
+
*/
|
|
16
22
|
export function jitterY(args, options) {
|
|
17
23
|
return jitter(args, { y: options });
|
|
18
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* adds random noise to one or more positional channels
|
|
27
|
+
*/
|
|
19
28
|
export function jitter({ data, ...channels }, options) {
|
|
20
29
|
const jitterChannels = Object.keys(options).filter((ch) => channels[ch]);
|
|
21
30
|
// if no jitter channels are defined return early
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { TransformArgsRow, TransformArgsRecord, DataRecord, DataRow } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export declare const X: any;
|
|
3
|
+
export declare const Y: any;
|
|
4
|
+
export declare const RAW_VALUE: any;
|
|
5
|
+
export declare function indexData<T extends object>(data: T[]): (T & {})[];
|
|
6
|
+
/**
|
|
7
|
+
* takes an array of raw values and returns data records in which the values
|
|
8
|
+
* are interpreted as the x channel and their index as the y channel
|
|
9
|
+
*/
|
|
9
10
|
export declare function recordizeX<T>({ data, ...channels }: TransformArgsRow<DataRow>, { withIndex }?: {
|
|
10
11
|
withIndex: boolean;
|
|
11
12
|
}): TransformArgsRecord<DataRecord>;
|
|
13
|
+
/**
|
|
14
|
+
* takes an array of raw values and returns data records in which the values
|
|
15
|
+
* are interpreted as the y channel and their index as the x channel
|
|
16
|
+
*/
|
|
12
17
|
export declare function recordizeY<T>({ data, ...channels }: TransformArgsRow<DataRow>, { withIndex }?: {
|
|
13
18
|
withIndex: boolean;
|
|
14
19
|
}): TransformArgsRecord<DataRecord>;
|
|
@@ -18,4 +23,8 @@ export declare function recordizeY<T>({ data, ...channels }: TransformArgsRow<Da
|
|
|
18
23
|
* the rest of our code doesn't have to deal with this case anymore.
|
|
19
24
|
*/
|
|
20
25
|
export declare function recordizeXY<T>({ data, ...channels }: TransformArgsRow<T>): TransformArgsRecord<T>;
|
|
26
|
+
/**
|
|
27
|
+
* wraps raw values into data records with index tracking, without
|
|
28
|
+
* assigning them to a specific positional channel
|
|
29
|
+
*/
|
|
21
30
|
export declare function recordize<T>({ data, ...channels }: TransformArgsRow<T>): TransformArgsRecord<T>;
|
|
@@ -6,9 +6,9 @@ export const RAW_VALUE = Symbol('originalValue');
|
|
|
6
6
|
export function indexData(data) {
|
|
7
7
|
return data.map((d, i) => ({ ...d, [INDEX]: i }));
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
/**
|
|
10
|
+
* takes an array of raw values and returns data records in which the values
|
|
11
|
+
* are interpreted as the x channel and their index as the y channel
|
|
12
12
|
*/
|
|
13
13
|
export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: true }) {
|
|
14
14
|
const dataIsRawValueArray = !isDataRecord(data[0]) && !Array.isArray(data[0]) && channels.x == null;
|
|
@@ -28,9 +28,9 @@ export function recordizeX({ data, ...channels }, { withIndex } = { withIndex: t
|
|
|
28
28
|
}
|
|
29
29
|
return { data: indexData(data), ...channels };
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
/**
|
|
32
|
+
* takes an array of raw values and returns data records in which the values
|
|
33
|
+
* are interpreted as the y channel and their index as the x channel
|
|
34
34
|
*/
|
|
35
35
|
export function recordizeY({ data, ...channels }, { withIndex } = { withIndex: true }) {
|
|
36
36
|
if (!data)
|
|
@@ -78,6 +78,10 @@ export function recordizeXY({ data, ...channels }) {
|
|
|
78
78
|
}
|
|
79
79
|
return { data: data, ...channels };
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* wraps raw values into data records with index tracking, without
|
|
83
|
+
* assigning them to a specific positional channel
|
|
84
|
+
*/
|
|
81
85
|
export function recordize({ data, ...channels }) {
|
|
82
86
|
if (!data)
|
|
83
87
|
return { data, ...channels };
|
|
@@ -2,7 +2,7 @@ import type { DataRecord } from '../types/index.js';
|
|
|
2
2
|
import type { ScaledChannelName, TransformArg } from '../types/index.js';
|
|
3
3
|
type RenameChannelsOptions = Partial<Record<ScaledChannelName, ScaledChannelName>>;
|
|
4
4
|
type ReplaceChannelsOptions = Partial<Record<ScaledChannelName, ScaledChannelName[]>>;
|
|
5
|
-
export declare const RENAME:
|
|
5
|
+
export declare const RENAME: any;
|
|
6
6
|
/**
|
|
7
7
|
* renames a channel without modifying the data
|
|
8
8
|
*/
|
|
@@ -11,5 +11,9 @@ export declare function renameChannels<T>({ data, ...channels }: TransformArg<T,
|
|
|
11
11
|
* renames a channel and copy the data
|
|
12
12
|
*/
|
|
13
13
|
export declare function renameChannelsAndData<T>({ data, ...channels }: TransformArg<T, DataRecord>, options: RenameChannelsOptions): TransformArg<T, DataRecord>;
|
|
14
|
+
/**
|
|
15
|
+
* copies a channel's accessor to multiple target channels, then removes
|
|
16
|
+
* the source channel
|
|
17
|
+
*/
|
|
14
18
|
export declare function replaceChannels<T>({ data, ...channels }: TransformArg<T, DataRecord>, options: ReplaceChannelsOptions): TransformArg<T, DataRecord>;
|
|
15
19
|
export {};
|
|
@@ -33,6 +33,10 @@ export function renameChannelsAndData({ data, ...channels }, options) {
|
|
|
33
33
|
}
|
|
34
34
|
return renameChannels({ data: newData, ...channels }, options);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* copies a channel's accessor to multiple target channels, then removes
|
|
38
|
+
* the source channel
|
|
39
|
+
*/
|
|
36
40
|
export function replaceChannels({ data, ...channels }, options) {
|
|
37
41
|
const newChannels = { ...channels };
|
|
38
42
|
for (const [from, to] of Object.entries(options)) {
|
|
@@ -5,6 +5,10 @@ type AtLeastOne<T, U = {
|
|
|
5
5
|
type SelectOptions = 'first' | 'last' | AtLeastOne<{
|
|
6
6
|
[k in ChannelName]: 'min' | 'max';
|
|
7
7
|
}>;
|
|
8
|
+
/**
|
|
9
|
+
* selects one datum per group based on the given criteria; use "first"/"last"
|
|
10
|
+
* for positional selection, or {channel: "min"/"max"} for value-based selection
|
|
11
|
+
*/
|
|
8
12
|
export declare function select({ data, ...channels }: TransformArg<DataRecord>, options: SelectOptions): {
|
|
9
13
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
10
14
|
facet?: "auto" | "include" | "exclude" | undefined;
|
|
@@ -12,14 +16,14 @@ export declare function select({ data, ...channels }: TransformArg<DataRecord>,
|
|
|
12
16
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
13
17
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
14
18
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
15
|
-
dodgeX?:
|
|
16
|
-
dodgeY?:
|
|
19
|
+
dodgeX?: DodgeXOptions;
|
|
20
|
+
dodgeY?: DodgeYOptions;
|
|
17
21
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
18
22
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
19
|
-
sort?:
|
|
23
|
+
sort?: {
|
|
20
24
|
channel: string;
|
|
21
25
|
order?: "ascending" | "descending";
|
|
22
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
26
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
23
27
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
24
28
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
25
29
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -80,14 +84,14 @@ export declare function selectFirst(args: TransformArg<DataRecord>): {
|
|
|
80
84
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
81
85
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
82
86
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
83
|
-
dodgeX?:
|
|
84
|
-
dodgeY?:
|
|
87
|
+
dodgeX?: DodgeXOptions;
|
|
88
|
+
dodgeY?: DodgeYOptions;
|
|
85
89
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
86
90
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
87
|
-
sort?:
|
|
91
|
+
sort?: {
|
|
88
92
|
channel: string;
|
|
89
93
|
order?: "ascending" | "descending";
|
|
90
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
94
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
91
95
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
92
96
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
93
97
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -148,14 +152,14 @@ export declare function selectLast(args: TransformArg<DataRecord>): {
|
|
|
148
152
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
149
153
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
150
154
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
151
|
-
dodgeX?:
|
|
152
|
-
dodgeY?:
|
|
155
|
+
dodgeX?: DodgeXOptions;
|
|
156
|
+
dodgeY?: DodgeYOptions;
|
|
153
157
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
154
158
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
155
|
-
sort?:
|
|
159
|
+
sort?: {
|
|
156
160
|
channel: string;
|
|
157
161
|
order?: "ascending" | "descending";
|
|
158
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
162
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
159
163
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
160
164
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
161
165
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -206,6 +210,7 @@ export declare function selectLast(args: TransformArg<DataRecord>): {
|
|
|
206
210
|
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
207
211
|
data: Record<string | symbol, import("../types/data.js").RawValue>[];
|
|
208
212
|
};
|
|
213
|
+
/** keeps only the datum with the smallest x value per group */
|
|
209
214
|
export declare function selectMinX(args: TransformArg<DataRecord>): {
|
|
210
215
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
211
216
|
facet?: "auto" | "include" | "exclude" | undefined;
|
|
@@ -213,14 +218,14 @@ export declare function selectMinX(args: TransformArg<DataRecord>): {
|
|
|
213
218
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
214
219
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
215
220
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
216
|
-
dodgeX?:
|
|
217
|
-
dodgeY?:
|
|
221
|
+
dodgeX?: DodgeXOptions;
|
|
222
|
+
dodgeY?: DodgeYOptions;
|
|
218
223
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
219
224
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
220
|
-
sort?:
|
|
225
|
+
sort?: {
|
|
221
226
|
channel: string;
|
|
222
227
|
order?: "ascending" | "descending";
|
|
223
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
228
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
224
229
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
225
230
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
226
231
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -271,6 +276,7 @@ export declare function selectMinX(args: TransformArg<DataRecord>): {
|
|
|
271
276
|
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
272
277
|
data: Record<string | symbol, import("../types/data.js").RawValue>[];
|
|
273
278
|
};
|
|
279
|
+
/** keeps only the datum with the largest x value per group */
|
|
274
280
|
export declare function selectMaxX(args: TransformArg<DataRecord>): {
|
|
275
281
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
276
282
|
facet?: "auto" | "include" | "exclude" | undefined;
|
|
@@ -278,14 +284,14 @@ export declare function selectMaxX(args: TransformArg<DataRecord>): {
|
|
|
278
284
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
279
285
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
280
286
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
281
|
-
dodgeX?:
|
|
282
|
-
dodgeY?:
|
|
287
|
+
dodgeX?: DodgeXOptions;
|
|
288
|
+
dodgeY?: DodgeYOptions;
|
|
283
289
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
284
290
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
285
|
-
sort?:
|
|
291
|
+
sort?: {
|
|
286
292
|
channel: string;
|
|
287
293
|
order?: "ascending" | "descending";
|
|
288
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
294
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
289
295
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
290
296
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
291
297
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -336,6 +342,7 @@ export declare function selectMaxX(args: TransformArg<DataRecord>): {
|
|
|
336
342
|
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
337
343
|
data: Record<string | symbol, import("../types/data.js").RawValue>[];
|
|
338
344
|
};
|
|
345
|
+
/** keeps only the datum with the smallest y value per group */
|
|
339
346
|
export declare function selectMinY(args: TransformArg<DataRecord>): {
|
|
340
347
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
341
348
|
facet?: "auto" | "include" | "exclude" | undefined;
|
|
@@ -343,14 +350,14 @@ export declare function selectMinY(args: TransformArg<DataRecord>): {
|
|
|
343
350
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
344
351
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
345
352
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
346
|
-
dodgeX?:
|
|
347
|
-
dodgeY?:
|
|
353
|
+
dodgeX?: DodgeXOptions;
|
|
354
|
+
dodgeY?: DodgeYOptions;
|
|
348
355
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
349
356
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
350
|
-
sort?:
|
|
357
|
+
sort?: {
|
|
351
358
|
channel: string;
|
|
352
359
|
order?: "ascending" | "descending";
|
|
353
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
360
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
354
361
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
355
362
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
356
363
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -401,6 +408,7 @@ export declare function selectMinY(args: TransformArg<DataRecord>): {
|
|
|
401
408
|
cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
402
409
|
data: Record<string | symbol, import("../types/data.js").RawValue>[];
|
|
403
410
|
};
|
|
411
|
+
/** keeps only the datum with the largest y value per group */
|
|
404
412
|
export declare function selectMaxY(args: TransformArg<DataRecord>): {
|
|
405
413
|
filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
406
414
|
facet?: "auto" | "include" | "exclude" | undefined;
|
|
@@ -408,14 +416,14 @@ export declare function selectMaxY(args: TransformArg<DataRecord>): {
|
|
|
408
416
|
fy?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
409
417
|
dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
410
418
|
dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
411
|
-
dodgeX?:
|
|
412
|
-
dodgeY?:
|
|
419
|
+
dodgeX?: DodgeXOptions;
|
|
420
|
+
dodgeY?: DodgeYOptions;
|
|
413
421
|
fill?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
414
422
|
fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
415
|
-
sort?:
|
|
423
|
+
sort?: {
|
|
416
424
|
channel: string;
|
|
417
425
|
order?: "ascending" | "descending";
|
|
418
|
-
} | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
426
|
+
} | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
419
427
|
stroke?: import("../types/channel.js").ChannelAccessor<Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
420
428
|
strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
421
429
|
strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data.js").RawValue>>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { groupFacetsAndZ } from '../helpers/group.js';
|
|
2
2
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
3
3
|
// let o: SelectOptions = { x: 'min'};
|
|
4
|
+
/**
|
|
5
|
+
* selects one datum per group based on the given criteria; use "first"/"last"
|
|
6
|
+
* for positional selection, or {channel: "min"/"max"} for value-based selection
|
|
7
|
+
*/
|
|
4
8
|
export function select({ data, ...channels }, options) {
|
|
5
9
|
const newData = [];
|
|
6
10
|
groupFacetsAndZ(data, channels, (items) => {
|
|
@@ -41,15 +45,19 @@ export function selectFirst(args) {
|
|
|
41
45
|
export function selectLast(args) {
|
|
42
46
|
return select(args, 'last');
|
|
43
47
|
}
|
|
48
|
+
/** keeps only the datum with the smallest x value per group */
|
|
44
49
|
export function selectMinX(args) {
|
|
45
50
|
return select(args, { x: 'min' });
|
|
46
51
|
}
|
|
52
|
+
/** keeps only the datum with the largest x value per group */
|
|
47
53
|
export function selectMaxX(args) {
|
|
48
54
|
return select(args, { x: 'max' });
|
|
49
55
|
}
|
|
56
|
+
/** keeps only the datum with the smallest y value per group */
|
|
50
57
|
export function selectMinY(args) {
|
|
51
58
|
return select(args, { y: 'min' });
|
|
52
59
|
}
|
|
60
|
+
/** keeps only the datum with the largest y value per group */
|
|
53
61
|
export function selectMaxY(args) {
|
|
54
62
|
return select(args, { y: 'max' });
|
|
55
63
|
}
|
|
@@ -2,12 +2,20 @@ import type { DataRecord, TransformArg } from '../types/index.js';
|
|
|
2
2
|
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
3
3
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
4
4
|
}[Keys];
|
|
5
|
+
/** per-channel shift amounts for x channels; values can be numbers or time interval strings (e.g. "1 month") */
|
|
5
6
|
type ShiftXOptions = {
|
|
6
7
|
[key in 'x' | 'x1' | 'x2']: string | number;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* shifts the x channel values by a fixed amount or time interval
|
|
11
|
+
*/
|
|
8
12
|
export declare function shiftX({ data, ...channels }: TransformArg<DataRecord>, shiftBy: string | number | RequireAtLeastOne<ShiftXOptions>): TransformArg<DataRecord>;
|
|
13
|
+
/** per-channel shift amounts for y channels; values can be numbers or time interval strings (e.g. "1 month") */
|
|
9
14
|
type ShiftYOptions = {
|
|
10
15
|
[key in 'y' | 'y1' | 'y2']: string | number;
|
|
11
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* shifts the y channel values by a fixed amount or time interval
|
|
19
|
+
*/
|
|
12
20
|
export declare function shiftY({ data, ...channels }: TransformArg<DataRecord>, shiftBy: string | number | RequireAtLeastOne<ShiftYOptions>): TransformArg<DataRecord>;
|
|
13
21
|
export {};
|
package/dist/transforms/shift.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { resolveChannel } from '../helpers/resolve.js';
|
|
2
2
|
import { maybeTimeInterval } from '../helpers/time.js';
|
|
3
|
+
/**
|
|
4
|
+
* shifts the x channel values by a fixed amount or time interval
|
|
5
|
+
*/
|
|
3
6
|
export function shiftX({ data, ...channels }, shiftBy) {
|
|
4
7
|
if (typeof shiftBy === 'number' || typeof shiftBy === 'string') {
|
|
5
8
|
shiftBy = { x: shiftBy };
|
|
@@ -10,6 +13,9 @@ export function shiftX({ data, ...channels }, shiftBy) {
|
|
|
10
13
|
}
|
|
11
14
|
return { data, ...channels };
|
|
12
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* shifts the y channel values by a fixed amount or time interval
|
|
18
|
+
*/
|
|
13
19
|
export function shiftY({ data, ...channels }, shiftBy) {
|
|
14
20
|
if (typeof shiftBy === 'number' || typeof shiftBy === 'string') {
|
|
15
21
|
shiftBy = { y: shiftBy };
|