Skip to content

Commit bacc920

Browse files
committed
revert type changes; remove reducer type tests for now
1 parent 08c80c0 commit bacc920

22 files changed

+26
-1919
lines changed

src/channel.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export type ChannelDomainValueSpec = ChannelDomainValue | ({value: ChannelDomain
210210
export type ChannelDomainSort = {[key in ScaleName]?: ChannelDomainValueSpec} & ChannelDomainOptions;
211211

212212
/** How to reduce channel values, e.g. when binning or grouping. */
213-
export type ChannelReducers<T = Reducer> = {[key in ChannelName]?: T | null};
213+
export type ChannelReducers<T = Reducer> = {[key in ChannelName]?: T | {reduce: T; scale?: Channel["scale"]} | null};
214214

215215
/** Abstract (unscaled) values, and associated scale, per channel. */
216216
export type ChannelStates = {[key in ChannelName]?: {value: any[]; scale: ScaleName | null}};

src/marks/area.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
22
import type {CurveOptions} from "../curve.js";
33
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
4-
import type {BinOptions} from "../transforms/bin.js";
5-
import type {BinReducer} from "../reducer.js";
4+
import type {BinOptions, BinReducer} from "../transforms/bin.js";
65
import type {StackOptions} from "../transforms/stack.js";
76

87
export interface AreaOptions extends MarkOptions, StackOptions, CurveOptions {

src/marks/line.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type {ChannelValue, 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";
5-
import type {BinOptions} from "../transforms/bin.js";
6-
import type {BinReducer} from "../reducer.js";
5+
import type {BinOptions, BinReducer} from "../transforms/bin.js";
76

87
export interface LineOptions extends MarkOptions, MarkerOptions, CurveAutoOptions {
98
x?: ChannelValueSpec;

src/marks/linearRegression.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
22
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
3-
import type {BinOptions} from "../transforms/bin.js";
4-
import type {BinReducer} from "../reducer.js";
3+
import type {BinOptions, BinReducer} from "../transforms/bin.js";
54

65
interface LinearRegressionOptions extends MarkOptions, BinOptions {
76
x?: ChannelValueSpec;

src/reducer.d.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type {Channel} from "./channel.js";
2-
31
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
42

53
export type ReducerPercentile =
@@ -29,36 +27,9 @@ export type ReducerName =
2927

3028
export type ReducerFunction = (values: any[]) => any;
3129

32-
export type ReducerImplementation =
33-
| {
34-
reduce: ReducerName;
35-
scale?: Channel["scale"];
36-
}
37-
| {
38-
reduce(index: number[], values: any[]): any;
39-
}
40-
| {
41-
reduce(index: number[], values: any[], summary?: any): any;
42-
scope: "data" | "facet";
43-
};
44-
45-
export type BinReducerImplementation =
46-
| {
47-
reduce: BinReducerName;
48-
scale?: Channel["scale"];
49-
}
50-
| {
51-
reduce(index: number[], values: any[], extent: {x1: any; y1: any; x2: any; y2: any}): any;
52-
}
53-
| {
54-
reduce(index: number[], values: any[], summary?: any, extent?: {x1: any; y1: any; x2: any; y2: any}): any;
55-
scope: "data" | "facet";
56-
};
30+
// TODO scope, label
31+
export interface ReducerImplementation {
32+
reduce(index: number[], values: any[]): any;
33+
}
5734

5835
export type Reducer = ReducerName | ReducerFunction | ReducerImplementation;
59-
60-
type BinReducerFunction = (values: any[], extent: {x1: any; y1: any; x2: any; y2: any}) => any;
61-
62-
type BinReducerName = ReducerName | "x" | "x1" | "x2" | "y" | "y1" | "y2";
63-
64-
export type BinReducer = BinReducerName | BinReducerFunction | BinReducerImplementation;

src/transforms/bin.d.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {ChannelReducers} from "../channel.js";
22
import type {RangeInterval} from "../interval.js";
3-
import type {BinReducer} from "../reducer.js";
3+
import type {Reducer} from "../reducer.js";
44
import type {Transformed} from "./basic.js";
55

66
export type ThresholdsName = "freedman-diaconis" | "scott" | "sturges" | "auto";
@@ -47,6 +47,23 @@ export interface BinOptions {
4747
interval?: RangeInterval;
4848
}
4949

50+
export type BinReducer =
51+
| Reducer
52+
| BinReducerFunction
53+
| BinReducerImplementation
54+
| "x"
55+
| "x1"
56+
| "x2"
57+
| "y"
58+
| "y1"
59+
| "y2";
60+
61+
export type BinReducerFunction = (values: any[], extent: {x1: any; y1: any; x2: any; y2: any}) => any;
62+
63+
// TODO scope, label
64+
export interface BinReducerImplementation {
65+
reduce(index: number[], values: any[], extent: {x1: any; y1: any; x2: any; y2: any}): any;
66+
}
5067
export interface BinOutputOptions extends BinOptions {
5168
/**
5269
* The data reducer; defaults to the array of values that belong to the bin in

test/output/reducerBinFunction.svg

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)