Skip to content

Commit 2afac8c

Browse files
committed
(d) => …
1 parent ded02e1 commit 2afac8c

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

docs/features/marks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ Plot.dot(sales, {x: "units", y: "fruit"}).plot()
465465
While a column name such as `"units"` is the most concise way of specifying channel values, values can also be specified as functions for greater flexibility, say to transform data or derive a new column on the fly. Channel functions are invoked for each datum (*d*) in the data and return the corresponding channel value. (This is similar to how D3’s [*selection*.attr](https://github.com/d3/d3-selection/blob/main/README.md#selection_attr) accepts functions, though note that Plot channel functions should return abstract values, not visual values.)
466466

467467
```js
468-
Plot.dot(sales, {x: d => d.units * 1000, y: d => d.fruit}).plot()
468+
Plot.dot(sales, {x: (d) => d.units * 1000, y: (d) => d.fruit}).plot()
469469
```
470470

471471
Plot also supports columnar data for greater efficiency with bigger datasets; for example, data can be specified as any array of the appropriate length (or any iterable or value compatible with [Array.from](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)), and then separate arrays of values can be passed as *options*.
@@ -550,7 +550,7 @@ The color channels (**fill** and **stroke**) are bound to the *color* scale by d
550550
In addition to functions of data, arrays, and column names, channel values can be specified as an object with a *transform* method; this transform method is passed the mark’s array of data and must return the corresponding array of channel values. (Whereas a channel value specified as a function is invoked repeatedly for each element in the mark’s data, similar to *array*.map, the transform method is invoked only once being passed the entire array of data.) For example, to pass the mark’s data directly to the **x** channel, equivalent to [Plot.identity](./transforms.md#plotidentity):
551551

552552
```js
553-
Plot.dot(numbers, {x: {transform: data => data}})
553+
Plot.dot(numbers, {x: {transform: (data) => data}})
554554
```
555555

556556
The **title**, **href**, and **ariaLabel** options can *only* be specified as channels. When these options are specified as a string, the string refers to the name of a column in the mark’s associated data. If you’d like every instance of a particular mark to have the same value, specify the option as a function that returns the desired value, *e.g.* `() => "Hello, world!"`.

docs/features/scales.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Plot.plot({
298298

299299
And like position scales, you can apply a *sqrt*, *pow*, *log*, or *symlog* transform; these are often useful when working with non-uniformly distributed data.
300300

301-
<!-- html`${["log", "symlog", "sqrt", "linear"].map(type => html`<div style="position: relative;">
301+
<!-- html`${["log", "symlog", "sqrt", "linear"].map((type) => html`<div style="position: relative;">
302302
<div style="position: absolute; color: white; font: bold 13px/33px var(--sans-serif); padding: 0 38px;">${type}</div>${Plot.plot({
303303
height: 33,
304304
color: {
@@ -567,7 +567,7 @@ Plot.plot({
567567
y: {
568568
grid: true,
569569
label: `↑ Daily temperature range (°${celsius ? "C" : "F"})`,
570-
transform: celsius ? f => (f - 32) * (5 / 9) : undefined // Fahrenheit to Celsius
570+
transform: celsius ? (f) => (f - 32) * (5 / 9) : undefined // Fahrenheit to Celsius
571571
},
572572
marks: [
573573
Plot.areaY(sftemp, {x: "date", y1: "low", y2: "high"})
@@ -689,7 +689,7 @@ The *scale*.**transform** option allows you to apply a function to all values be
689689
Plot.plot({
690690
y: {
691691
label: "↑ Temperature (°F)",
692-
transform: f => f * 9 / 5 + 32 // convert Celsius to Fahrenheit
692+
transform: (f) => f * 9 / 5 + 32 // convert Celsius to Fahrenheit
693693
},
694694
marks:
695695
})

docs/marks/box.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ The given *options* are passed through to these underlying marks, with the excep
125125
## boxX(*data*, *options*)
126126

127127
```js
128-
Plot.boxX(simpsons.map(d => d.imdb_rating))
128+
Plot.boxX(simpsons.map((d) => d.imdb_rating))
129129
```
130130

131131
Returns a horizontal box mark. If the **x** option is not specified, it defaults to the identity function, as when *data* is an array of numbers. If the **y** option is not specified, it defaults to null; if the **y** option is specified, it should represent an ordinal (discrete) value.
132132

133133
## boxY(*data*, *options*)
134134

135135
```js
136-
Plot.boxY(simpsons.map(d => d.imdb_rating))
136+
Plot.boxY(simpsons.map((d) => d.imdb_rating))
137137
```
138138

139139
Returns a vertical box mark. If the **y** option is not specified, it defaults to the identity function, as when *data* is an array of numbers. If the **x** option is not specified, it defaults to null; if the **x** option is specified, it should represent an ordinal (discrete) value.

docs/marks/density.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,18 @@ Plot.plot({
186186
inset: 10,
187187
color: {legend: true},
188188
marks: [
189-
Plot.density(penguins.filter(d => d.sex), {
190-
weight: d => d.sex === "FEMALE" ? 1 - skew : 1 + skew,
189+
Plot.density(penguins.filter((d) => d.sex), {
190+
weight: (d) => d.sex === "FEMALE" ? 1 - skew : 1 + skew,
191191
x: "flipper_length_mm",
192192
y: "culmen_length_mm",
193193
strokeOpacity: 0.5,
194194
clip: true
195195
}),
196-
Plot.dot(penguins.filter(d => d.sex), {
196+
Plot.dot(penguins.filter((d) => d.sex), {
197197
x: "flipper_length_mm",
198198
y: "culmen_length_mm",
199199
stroke: "sex",
200-
strokeOpacity: d => d.sex === "FEMALE" ? 1 - skew : 1 + skew
200+
strokeOpacity: (d) => d.sex === "FEMALE" ? 1 - skew : 1 + skew
201201
}),
202202
Plot.frame()
203203
]

docs/marks/dot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ onMounted(() => {
3535
});
3636
d3.csv("../data/us-population-state-age.csv", d3.autoType).then((data) => {
3737
const ages = data.columns.slice(1); // convert wide data to tidy data
38-
stateage.value = Object.assign(ages.flatMap(age => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
38+
stateage.value = Object.assign(ages.flatMap((age) => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
3939
});
4040
});
4141

docs/marks/line.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ onMounted(() => {
2222
d3.json("../data/countries-110m.json").then((data) => (world.value = data));
2323
d3.csv("../data/us-population-state-age.csv", d3.autoType).then((data) => {
2424
const ages = data.columns.slice(1); // convert wide data to tidy data
25-
stateage.value = Object.assign(ages.flatMap(age => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
25+
stateage.value = Object.assign(ages.flatMap((age) => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
2626
});
2727
Promise.all([
2828
d3.csv("../data/amzn.csv", d3.autoType),
2929
d3.csv("../data/goog.csv", d3.autoType),
3030
d3.csv("../data/ibm.csv", d3.autoType)
3131
]).then((datas) => {
32-
stocks.value = d3.zip(["AAPL", "AMZN", "GOOG", "IBM"], [aapl].concat(datas)).flatMap(([Symbol, data]) => data.map(d => ({Symbol, ...d})));
32+
stocks.value = d3.zip(["AAPL", "AMZN", "GOOG", "IBM"], [aapl].concat(datas)).flatMap(([Symbol, data]) => data.map((d) => ({Symbol, ...d})));
3333
});
3434
});
3535

@@ -372,7 +372,7 @@ Returns a new line with the given *data* and *options*. If neither the **x** nor
372372
## lineX(*data*, *options*)
373373

374374
```js
375-
Plot.lineX(aapl.map(d => d.Close))
375+
Plot.lineX(aapl.map((d) => d.Close))
376376
```
377377

378378
Similar to [line](#line-data-options) except that if the **x** option is not specified, it defaults to the identity function and assumes that *data* = [*x₀*, *x₁*, *x₂*, …]. If the **y** option is not specified, it defaults to [0, 1, 2, …].
@@ -388,7 +388,7 @@ The **interval** option is recommended to “regularize” sampled data; for exa
388388
## lineY(*data*, *options*)
389389

390390
```js
391-
Plot.lineY(aapl.map(d => d.Close))
391+
Plot.lineY(aapl.map((d) => d.Close))
392392
```
393393

394394
Similar to [line](#line-data-options) except that if the **y** option is not specified, it defaults to the identity function and assumes that *data* = [*y₀*, *y₁*, *y₂*, …]. If the **x** option is not specified, it defaults to [0, 1, 2, …].

docs/marks/tick.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const stateage = shallowRef([]);
1111
onMounted(() => {
1212
d3.csv("../data/us-population-state-age.csv", d3.autoType).then((data) => {
1313
const ages = data.columns.slice(1); // convert wide data to tidy data
14-
stateage.value = Object.assign(ages.flatMap(age => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
14+
stateage.value = Object.assign(ages.flatMap((age) => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
1515
});
1616
});
1717

docs/transforms/group.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,19 @@ Plot.groupX({y: "sum"}, {x: "species", y: "body_mass_g"})
388388
You can control whether a channel is computed before or after grouping. If a channel is declared only in *options* (and it is not a special group-eligible channel such as **x**, **y**, **z**, **fill**, or **stroke**), it will be computed after grouping and be passed the grouped data: each datum is the array of input data corresponding to the current group.
389389

390390
```js
391-
Plot.groupX({y: "count"}, {x: "species", title: group => group.map(d => d.body_mass_g).join("\n")})
391+
Plot.groupX({y: "count"}, {x: "species", title: (group) => group.map((d) => d.body_mass_g).join("\n")})
392392
```
393393

394394
This is equivalent to declaring the channel only in *outputs*.
395395

396396
```js
397-
Plot.groupX({y: "count", title: group => group.map(d => d.body_mass_g).join("\n")}, {x: "species"})
397+
Plot.groupX({y: "count", title: (group) => group.map((d) => d.body_mass_g).join("\n")}, {x: "species"})
398398
```
399399

400400
However, if a channel is declared in both *outputs* and *options*, then the channel in *options* is computed before grouping and can be aggregated using any built-in reducer (or a custom reducer function) during the group transform.
401401

402402
```js
403-
Plot.groupX({y: "count", title: masses => masses.join("\n")}, {x: "species", title: "body_mass_g"})
403+
Plot.groupX({y: "count", title: (masses) => masses.join("\n")}, {x: "species", title: "body_mass_g"})
404404
```
405405

406406
If any of **z**, **fill**, or **stroke** is a channel, the first of these channels is considered the *z* dimension and will be used to subdivide groups.

docs/transforms/normalize.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ onMounted(() => {
1515
d3.csv("../data/goog.csv", d3.autoType),
1616
d3.csv("../data/ibm.csv", d3.autoType)
1717
]).then((datas) => {
18-
stocks.value = d3.zip(["AAPL", "AMZN", "GOOG", "IBM"], datas).flatMap(([Symbol, data]) => data.map(d => ({Symbol, ...d})));
18+
stocks.value = d3.zip(["AAPL", "AMZN", "GOOG", "IBM"], datas).flatMap(([Symbol, data]) => data.map((d) => ({Symbol, ...d})));
1919
});
2020
d3.csv("../data/us-population-state-age.csv", d3.autoType).then((data) => {
2121
const ages = data.columns.slice(1); // convert wide data to tidy data
22-
stateage.value = Object.assign(ages.flatMap(age => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
22+
stateage.value = Object.assign(ages.flatMap((age) => data.map((d) => ({state: d.name, age, population: d[age]}))), {ages});
2323
});
2424
});
2525

docs/transforms/select.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ onMounted(() => {
1313
d3.csv("../data/goog.csv", d3.autoType),
1414
d3.csv("../data/ibm.csv", d3.autoType)
1515
]).then((datas) => {
16-
stocks.value = d3.zip(["AAPL", "AMZN", "GOOG", "IBM"], [aapl].concat(datas)).flatMap(([Symbol, data]) => data.map(d => ({Symbol, ...d})));
16+
stocks.value = d3.zip(["AAPL", "AMZN", "GOOG", "IBM"], [aapl].concat(datas)).flatMap(([Symbol, data]) => data.map((d) => ({Symbol, ...d})));
1717
});
1818
});
1919

0 commit comments

Comments
 (0)