Skip to content

Commit 51df12f

Browse files
committed
shorten
1 parent f8e5c5f commit 51df12f

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/transforms/group.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@ import {defined, firstof} from "../defined.js";
33
import {valueof, maybeColor, maybeTransform, maybeValue, maybeLazyChannel, lazyChannel, first, identity, take, maybeTuple} from "../mark.js";
44

55
export function groupX({x, ...options} = {}) {
6-
const [transform, X, y, z, fill, stroke] = group1(x, options);
7-
return {x: X, y, ...transform, z, fill, stroke};
6+
const [transform, X, y] = group1(x, options);
7+
return {x: X, y, ...transform};
88
}
99

1010
export function groupY({y, ...options} = {}) {
11-
const [transform, Y, x, z, fill, stroke] = group1(y, options);
12-
return {y: Y, x, ...transform, z, fill, stroke};
11+
const [transform, Y, x] = group1(y, options);
12+
return {y: Y, x, ...transform};
1313
}
1414

1515
export function groupR(options) {
1616
return group({...options, out: "r"});
1717
}
1818

1919
export function group({x, y, out = "fill", ...options} = {}) {
20-
const [transform, X, Y, L, z, fill, stroke] = group2(x, y, options);
21-
return {x: X, y: Y, ...transform, z, fill, stroke, [out]: L};
20+
const [transform, X, Y, L] = group2(x, y, options);
21+
return {x: X, y: Y, ...transform, [out]: L};
2222
}
2323

24-
function group1(x = identity, {domain, normalize, ...options} = {}) {
25-
const {z, fill, stroke} = options;
24+
function group1(x = identity, {domain, normalize, z, fill, stroke, ...options} = {}) {
2625
const k = normalize === true ? 100 : +normalize;
2726
const [X, setX] = lazyChannel(x);
2827
const [Y, setY] = lazyChannel(`Frequency${k === 100 ? " (%)" : ""}`);
@@ -34,6 +33,9 @@ function group1(x = identity, {domain, normalize, ...options} = {}) {
3433
const defined = maybeDomain(domain);
3534
return [
3635
{
36+
z: Z,
37+
fill: F,
38+
stroke: S,
3739
...options,
3840
transform: maybeTransform(options, (data, facets) => {
3941
const X = valueof(data, x);
@@ -71,15 +73,11 @@ function group1(x = identity, {domain, normalize, ...options} = {}) {
7173
})
7274
},
7375
X,
74-
Y,
75-
Z,
76-
F,
77-
S
76+
Y
7877
];
7978
}
8079

81-
function group2(xv, yv, {domain, normalize, ...options} = {}) {
82-
const {z, fill, stroke} = options;
80+
function group2(xv, yv, {z, fill, stroke, domain, normalize, ...options} = {}) {
8381
let {value: x, domain: xdomain} = {domain, ...maybeValue(xv)};
8482
let {value: y, domain: ydomain} = {domain, ...maybeValue(yv)};
8583
([x, y] = maybeTuple(x, y));
@@ -96,6 +94,9 @@ function group2(xv, yv, {domain, normalize, ...options} = {}) {
9694
const ydefined = maybeDomain(ydomain);
9795
return [
9896
{
97+
z: Z,
98+
fill: F,
99+
stroke: S,
99100
...options,
100101
transform: maybeTransform(options, (data, facets) => {
101102
const X = valueof(data, x);
@@ -140,10 +141,7 @@ function group2(xv, yv, {domain, normalize, ...options} = {}) {
140141
},
141142
X,
142143
Y,
143-
L,
144-
Z,
145-
F,
146-
S
144+
L
147145
];
148146
}
149147

0 commit comments

Comments
 (0)