Skip to content

Commit 4e81cd5

Browse files
committed
ChannelValueDenseBinSpec
1 parent b1b6713 commit 4e81cd5

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

src/channel.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {Interval} from "./interval.js";
22
import type {Reducer} from "./reducer.js";
33
import type {ScaleName, ScaleType} from "./scales.js";
4+
import type {BinOptions} from "./transforms/bin.js";
45

56
/** Lazily-constructed channel values derived from data. */
67
export interface ChannelTransform {
@@ -148,6 +149,18 @@ export type ChannelValueSpec = ChannelValue | {value: ChannelValue; scale?: Chan
148149
*/
149150
export type ChannelValueIntervalSpec = ChannelValueSpec | {value: ChannelValue; interval?: Interval}; // TODO scale override?
150151

152+
/**
153+
* When binning on **x** or **y**, you can specify the channel values as a
154+
* {value} object to provide separate bin options for each.
155+
*/
156+
export type ChannelValueBinSpec = ChannelValue | ({value: ChannelValue} & BinOptions);
157+
158+
/**
159+
* For marks that use a one-dimensional dense interval transform, such as lineX
160+
* and areaY; here interval must be a mark-level option.
161+
*/
162+
export type ChannelValueDenseBinSpec = ChannelValue | ({value: ChannelValue; scale?: Channel["scale"]} & Omit<BinOptions, "interval">); // prettier-ignore
163+
151164
/**
152165
* The available inputs for imputing scale domains. In addition to a named
153166
* channel, an input may be specified as:

src/marks/area.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
1+
import type {ChannelValue, ChannelValueDenseBinSpec, ChannelValueSpec} from "../channel.js";
22
import type {CurveOptions} from "../curve.js";
33
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
44
import type {BinOptions, BinReducer} from "../transforms/bin.js";
@@ -14,12 +14,12 @@ export interface AreaOptions extends MarkOptions, StackOptions, CurveOptions {
1414

1515
export interface AreaXOptions extends Omit<AreaOptions, "y1" | "y2">, BinOptions {
1616
x?: ChannelValueSpec;
17-
y?: ChannelValueSpec & Omit<BinOptions, "interval">; // interval must be a mark-level option
17+
y?: ChannelValueDenseBinSpec;
1818
reduce?: BinReducer;
1919
}
2020

2121
export interface AreaYOptions extends Omit<AreaOptions, "x1" | "x2">, BinOptions {
22-
x?: ChannelValueSpec & Omit<BinOptions, "interval">; // interval must be a mark-level option
22+
x?: ChannelValueDenseBinSpec;
2323
y?: ChannelValueSpec;
2424
reduce?: BinReducer;
2525
}

src/marks/line.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
1+
import type {ChannelValue, ChannelValueDenseBinSpec, ChannelValueSpec} from "../channel.js";
22
import type {CurveAutoOptions} from "../curve.js";
33
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
44
import type {MarkerOptions} from "../marker.js";
@@ -11,12 +11,12 @@ export interface LineOptions extends MarkOptions, MarkerOptions, CurveAutoOption
1111
}
1212

1313
export interface LineXOptions extends LineOptions, BinOptions {
14-
y?: ChannelValueSpec & Omit<BinOptions, "interval">; // interval must be mark-level option
14+
y?: ChannelValueDenseBinSpec;
1515
reduce?: BinReducer;
1616
}
1717

1818
export interface LineYOptions extends LineOptions, BinOptions {
19-
x?: ChannelValueSpec & Omit<BinOptions, "interval">; // interval must be mark-level option
19+
x?: ChannelValueDenseBinSpec;
2020
reduce?: BinReducer;
2121
}
2222

src/marks/linearRegression.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
1+
import type {ChannelValue, ChannelValueDenseBinSpec, ChannelValueSpec} from "../channel.js";
22
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
33
import type {BinOptions, BinReducer} from "../transforms/bin.js";
44

@@ -12,11 +12,11 @@ interface LinearRegressionOptions extends MarkOptions, BinOptions {
1212
}
1313

1414
export interface LinearRegressionXOptions extends LinearRegressionOptions {
15-
y?: ChannelValueSpec & Omit<BinOptions, "interval">; // interval must be mark-level option
15+
y?: ChannelValueDenseBinSpec;
1616
}
1717

1818
export interface LinearRegressionYOptions extends LinearRegressionOptions {
19-
x?: ChannelValueSpec & Omit<BinOptions, "interval">; // interval must be mark-level option
19+
x?: ChannelValueDenseBinSpec;
2020
}
2121

2222
export function linearRegressionX(data?: Data, options?: LinearRegressionXOptions): RenderableMark;

src/transforms/bin.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ChannelReducers, ChannelValue} from "../channel.js";
1+
import type {ChannelReducers, ChannelValueBinSpec} from "../channel.js";
22
import type {RangeInterval} from "../interval.js";
33
import type {Reducer} from "../reducer.js";
44
import type {Transformed} from "./basic.js";
@@ -149,12 +149,6 @@ export interface BinReducerImplementation<S = any, T = S> {
149149
// TODO label
150150
}
151151

152-
/**
153-
* When binning on **x** or **y**, you can specify the channel values as a
154-
* {value} object to provide separate bin options for each.
155-
*/
156-
export type ChannelValueBinSpec = ChannelValue | ({value: ChannelValue} & BinOptions);
157-
158152
/** Inputs to the binX transform. */
159153
export type BinXInputs<T> = Omit<T, "x"> & {x?: ChannelValueBinSpec} & BinOptions;
160154

0 commit comments

Comments
 (0)