Skip to content

Commit 9dfeb79

Browse files
committed
revert "reduce/label"
see #1364
1 parent c9711f8 commit 9dfeb79

5 files changed

Lines changed: 9 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ The following aggregation methods are supported:
21262126
* *y1* - the lower bound of the bin’s *y* extent (when binning on *y*)
21272127
* *y2* - the upper bound of the bin’s *y* extent (when binning on *y*)
21282128
* a function to be passed the array of values for each bin and the extent of the bin
2129-
* an object with a *reduce* method, and optionally a *scope* and a *label*
2129+
* an object with a *reduce* method, and optionally a *scope*
21302130
21312131
In the last case, the *reduce* method is repeatedly passed three arguments: the index for each bin (an array of integers), the input channel’s array of values, and the extent of the bin (an object {x1, x2, y1, y2}); it must then return the corresponding aggregate value for the bin. If the reducer object’s *scope* is “data”, then the *reduce* method is first invoked for the full data; the return value of the *reduce* method is then made available as a third argument (making the extent the fourth argument). Similarly if the *scope* is “facet”, then the *reduce* method is invoked for each facet, and the resulting reduce value is made available while reducing the facet’s bins. (This optional *scope* is used by the *proportion* and *proportion-facet* reducers.)
21322132
@@ -2277,7 +2277,7 @@ The following aggregation methods are supported:
22772277
* *deviation* - the standard deviation
22782278
* *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
22792279
* a function - passed the array of values for each group
2280-
* an object with a *reduce* method, an optionally a *scope* and a *label*
2280+
* an object with a *reduce* method, an optionally a *scope*
22812281
22822282
In the last case, the *reduce* method is repeatedly passed two arguments: the index for each group (an array of integers), and the input channel’s array of values; it must then return the corresponding aggregate value for the group. If the reducer object’s *scope* is “data”, then the *reduce* method is first invoked for the full data; the return value of the *reduce* method is then made available as a third argument. Similarly if the *scope* is “facet”, then the *reduce* method is invoked for each facet, and the resulting reduce value is made available while reducing the facet’s groups. (This optional *scope* is used by the *proportion* and *proportion-facet* reducers.)
22832283

src/reducer.d.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type ReducerName =
2929

3030
export type ReducerFunction = (values: any[]) => any;
3131

32-
export type ReducerImplementation = (
32+
export type ReducerImplementation =
3333
| {
3434
reduce: ReducerName;
3535
scale?: Channel["scale"];
@@ -40,10 +40,9 @@ export type ReducerImplementation = (
4040
| {
4141
reduce(index: number[], values: any[], summary?: any): any;
4242
scope: "data" | "facet";
43-
}
44-
) & {label?: string | null};
43+
};
4544

46-
export type BinReducerImplementation = (
45+
export type BinReducerImplementation =
4746
| {
4847
reduce: BinReducerName;
4948
scale?: Channel["scale"];
@@ -54,8 +53,7 @@ export type BinReducerImplementation = (
5453
| {
5554
reduce(index: number[], values: any[], summary?: any, extent?: {x1: any; y1: any; x2: any; y2: any}): any;
5655
scope: "data" | "facet";
57-
}
58-
) & {label?: string | null};
56+
};
5957

6058
export type Reducer = ReducerName | ReducerFunction | ReducerImplementation;
6159

src/transforms/group.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ export function maybeOutputs(outputs, inputs, asOutput = maybeOutput) {
178178

179179
export function maybeOutput(name, reduce, inputs, asEvaluator = maybeEvaluator) {
180180
let scale; // optional per-channel scale override
181-
let {label} = reduce;
182181
if (isObject(reduce) && typeof reduce.reduce !== "function") (scale = reduce.scale), (reduce = reduce.reduce);
183182
const evaluator = asEvaluator(name, reduce, inputs);
184-
const [output, setOutput] = column(label !== undefined ? label : evaluator.label);
183+
const [output, setOutput] = column(evaluator.label);
185184
let O;
186185
return {
187186
name,

test/output/reducerGroupFunction.svg

Lines changed: 1 addition & 1 deletion
Loading

test/plots/reducers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export async function reducerGroupFunction() {
220220
penguins,
221221
Plot.groupX(
222222
{
223-
y: {reduce: "count", label: "# of specimens"},
223+
y: "count",
224224
fill: (values) => d3.mode(values)
225225
},
226226
{x: "species", fill: "island", fy: "sex"}

0 commit comments

Comments
 (0)