Skip to content

Commit 7f05001

Browse files
committed
column, not channel
1 parent 0c81b16 commit 7f05001

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,11 +2024,11 @@ Plot provides a few helpers for implementing transforms.
20242024
20252025
Given an *options* object that may specify some basic transforms (*filter*, *sort*, or *reverse*) or a custom *transform* function, composes those transforms if any with the given *transform* function, returning a new *options* object. If a custom *transform* function is present on the given *options*, any basic transforms are ignored. Any additional input *options* are passed through in the returned *options* object. This method facilitates applying the basic transforms prior to applying the given custom *transform* and is used internally by Plot’s built-in transforms.
20262026
2027-
#### Plot.channel([*source*])
2027+
#### Plot.column([*source*])
20282028
2029-
This helper for constructing derived channels returns a [*channel*, *setChannel*] array. The *channel* object implements *channel*.transform, returning whatever value was most recently passed to *setChannel*. If *setChannel* is not called, then *channel*.transform returns undefined. If a *source* is specified, then *channel*.label exposes the given *source*’s label, if any: if *source* is a string as when representing a named field of data, then *channel*.label is *source*; otherwise *channel*.label propagates *source*.label. This allows derived channels to propagate a human-readable axis or legend label.
2029+
This helper for constructing derived channels returns a [*channel*, *setColumn*] array. The *channel* object implements *channel*.transform, returning whatever value was most recently passed to *setColumn*. If *setColumn* is not called, then *channel*.transform returns undefined. If a *source* is specified, then *channel*.label exposes the given *source*’s label, if any: if *source* is a string as when representing a named field of data, then *channel*.label is *source*; otherwise *channel*.label propagates *source*.label. This allows derived channels to propagate a human-readable axis or legend label.
20302030
2031-
Plot.channel is typically used by options transforms to define new channels; these channels are populated (derived) when the custom *transform* function is invoked.
2031+
Plot.column is typically used by options transforms to define new channels; these columns are populated (derived) when the custom *transform* function is invoked.
20322032
20332033
## Curves
20342034

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export {RuleX, RuleY, ruleX, ruleY} from "./marks/rule.js";
1414
export {Text, text, textX, textY} from "./marks/text.js";
1515
export {TickX, TickY, tickX, tickY} from "./marks/tick.js";
1616
export {Vector, vector, vectorX, vectorY} from "./marks/vector.js";
17-
export {valueof, channel} from "./options.js";
17+
export {valueof, column} from "./options.js";
1818
export {filter, reverse, sort, shuffle, basic as transform} from "./transforms/basic.js";
1919
export {bin, binX, binY} from "./transforms/bin.js";
2020
export {group, groupX, groupY, groupZ} from "./transforms/group.js";

src/options.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ export function maybeInput(key, options) {
153153
return options[key];
154154
}
155155

156-
// Defines a channel whose values are lazily populated by calling the returned
156+
// Defines a column whose values are lazily populated by calling the returned
157157
// setter. If the given source is labeled, the label is propagated to the
158-
// returned channel definition.
159-
export function channel(source) {
158+
// returned column definition.
159+
export function column(source) {
160160
let value;
161161
return [
162162
{
@@ -167,9 +167,9 @@ export function channel(source) {
167167
];
168168
}
169169

170-
// Like channel, but allows the source to be null.
171-
export function maybeChannel(source) {
172-
return source == null ? [source] : channel(source);
170+
// Like column, but allows the source to be null.
171+
export function maybeColumn(source) {
172+
return source == null ? [source] : column(source);
173173
}
174174

175175
export function labelof(value, defaultValue) {
@@ -178,10 +178,10 @@ export function labelof(value, defaultValue) {
178178
: defaultValue;
179179
}
180180

181-
// Assuming that both x1 and x2 and lazy channels (per above), this derives a
182-
// new a channel that’s the average of the two, and which inherits the channel
183-
// label (if any). Both input channels are assumed to be quantitative. If either
184-
// channel is temporal, the returned channel is also temporal.
181+
// Assuming that both x1 and x2 and lazy columns (per above), this derives a new
182+
// a column that’s the average of the two, and which inherits the column label
183+
// (if any). Both input columns are assumed to be quantitative. If either column
184+
// is temporal, the returned column is also temporal.
185185
export function mid(x1, x2) {
186186
return {
187187
transform(data) {

src/transforms/bin.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {bin as binner, extent, thresholdFreedmanDiaconis, thresholdScott, thresholdSturges, utcTickInterval} from "d3";
2-
import {valueof, range, identity, maybeChannel, maybeTuple, maybeColorChannel, maybeValue, mid, labelof, isTemporal} from "../options.js";
2+
import {valueof, range, identity, maybeColumn, maybeTuple, maybeColorChannel, maybeValue, mid, labelof, isTemporal} from "../options.js";
33
import {coerceDate, coerceNumber} from "../scales.js";
44
import {basic} from "./basic.js";
55
import {hasOutput, maybeEvaluator, maybeGroup, maybeOutput, maybeOutputs, maybeReduce, maybeSort, maybeSubgroup, reduceCount, reduceFirst, reduceIdentity} from "./group.js";
@@ -67,14 +67,14 @@ function binn(
6767
if (gy != null && hasOutput(outputs, "y", "y1", "y2")) gy = null;
6868

6969
// Produce x1, x2, y1, and y2 output channels as appropriate (when binning).
70-
const [BX1, setBX1] = maybeChannel(bx);
71-
const [BX2, setBX2] = maybeChannel(bx);
72-
const [BY1, setBY1] = maybeChannel(by);
73-
const [BY2, setBY2] = maybeChannel(by);
70+
const [BX1, setBX1] = maybeColumn(bx);
71+
const [BX2, setBX2] = maybeColumn(bx);
72+
const [BY1, setBY1] = maybeColumn(by);
73+
const [BY2, setBY2] = maybeColumn(by);
7474

7575
// Produce x or y output channels as appropriate (when grouping).
7676
const [k, gk] = gx != null ? [gx, "x"] : gy != null ? [gy, "y"] : [];
77-
const [GK, setGK] = maybeChannel(k);
77+
const [GK, setGK] = maybeColumn(k);
7878

7979
// Greedily materialize the z, fill, and stroke channels (if channels and not
8080
// constants) so that we can reference them for subdividing groups without
@@ -94,11 +94,11 @@ function binn(
9494
interval, // eslint-disable-line no-unused-vars
9595
...options
9696
} = inputs;
97-
const [GZ, setGZ] = maybeChannel(z);
97+
const [GZ, setGZ] = maybeColumn(z);
9898
const [vfill] = maybeColorChannel(fill);
9999
const [vstroke] = maybeColorChannel(stroke);
100-
const [GF = fill, setGF] = maybeChannel(vfill);
101-
const [GS = stroke, setGS] = maybeChannel(vstroke);
100+
const [GF = fill, setGF] = maybeColumn(vfill);
101+
const [GS = stroke, setGS] = maybeColumn(vstroke);
102102

103103
return {
104104
..."z" in inputs && {z: GZ || z},

src/transforms/group.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {group as grouper, sort, sum, deviation, min, max, mean, median, mode, variance, InternSet, minIndex, maxIndex, rollup} from "d3";
22
import {ascendingDefined, firstof} from "../defined.js";
3-
import {valueof, maybeColorChannel, maybeInput, maybeTuple, maybeChannel, channel, first, identity, take, labelof, range, second, percentile} from "../options.js";
3+
import {valueof, maybeColorChannel, maybeInput, maybeTuple, maybeColumn, column, first, identity, take, labelof, range, second, percentile} from "../options.js";
44
import {basic} from "./basic.js";
55

66
// Group on {z, fill, stroke}.
@@ -51,8 +51,8 @@ function groupn(
5151
filter = filter == null ? undefined : maybeEvaluator("filter", filter, inputs);
5252

5353
// Produce x and y output channels as appropriate.
54-
const [GX, setGX] = maybeChannel(x);
55-
const [GY, setGY] = maybeChannel(y);
54+
const [GX, setGX] = maybeColumn(x);
55+
const [GY, setGY] = maybeColumn(y);
5656

5757
// Greedily materialize the z, fill, and stroke channels (if channels and not
5858
// constants) so that we can reference them for subdividing groups without
@@ -65,11 +65,11 @@ function groupn(
6565
y1, y2, // consumed if y is an output
6666
...options
6767
} = inputs;
68-
const [GZ, setGZ] = maybeChannel(z);
68+
const [GZ, setGZ] = maybeColumn(z);
6969
const [vfill] = maybeColorChannel(fill);
7070
const [vstroke] = maybeColorChannel(stroke);
71-
const [GF = fill, setGF] = maybeChannel(vfill);
72-
const [GS = stroke, setGS] = maybeChannel(vstroke);
71+
const [GF = fill, setGF] = maybeColumn(vfill);
72+
const [GS = stroke, setGS] = maybeColumn(vstroke);
7373

7474
return {
7575
..."z" in inputs && {z: GZ || z},
@@ -148,7 +148,7 @@ export function maybeOutputs(outputs, inputs) {
148148

149149
export function maybeOutput(name, reduce, inputs) {
150150
const evaluator = maybeEvaluator(name, reduce, inputs);
151-
const [output, setOutput] = channel(evaluator.label);
151+
const [output, setOutput] = column(evaluator.label);
152152
let O;
153153
return {
154154
name,

src/transforms/map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {count, group, rank} from "d3";
2-
import {maybeZ, take, valueof, maybeInput, channel} from "../options.js";
2+
import {maybeZ, take, valueof, maybeInput, column} from "../options.js";
33
import {basic} from "./basic.js";
44

55
export function mapX(m, options = {}) {
@@ -19,7 +19,7 @@ export function map(outputs = {}, options = {}) {
1919
const channels = Object.entries(outputs).map(([key, map]) => {
2020
const input = maybeInput(key, options);
2121
if (input == null) throw new Error(`missing channel: ${key}`);
22-
const [output, setOutput] = channel(input);
22+
const [output, setOutput] = column(input);
2323
return {key, input, output, setOutput, map: maybeMap(map)};
2424
});
2525
return {

src/transforms/stack.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {InternMap, cumsum, group, groupSort, greatest, max, min, rollup, sum} from "d3";
22
import {ascendingDefined} from "../defined.js";
3-
import {field, channel, maybeChannel, maybeZ, mid, range, valueof, maybeZero} from "../options.js";
3+
import {field, column, maybeColumn, maybeZ, mid, range, valueof, maybeZero} from "../options.js";
44
import {basic} from "./basic.js";
55

66
export function stackX(stackOptions = {}, options = {}) {
@@ -67,9 +67,9 @@ function mergeOptions(options) {
6767

6868
function stack(x, y = () => 1, ky, {offset, order, reverse}, options) {
6969
const z = maybeZ(options);
70-
const [X, setX] = maybeChannel(x);
71-
const [Y1, setY1] = channel(y);
72-
const [Y2, setY2] = channel(y);
70+
const [X, setX] = maybeColumn(x);
71+
const [Y1, setY1] = column(y);
72+
const [Y2, setY2] = column(y);
7373
offset = maybeOffset(offset);
7474
order = maybeOrder(order, offset, ky);
7575
return [

0 commit comments

Comments
 (0)