Skip to content

Commit 7db9dfd

Browse files
authored
known keys for empty groups (#499)
* known keys for empty groups * known keys for empty groups * test empty groups
1 parent fe06c22 commit 7db9dfd

File tree

6 files changed

+1835
-8
lines changed

6 files changed

+1835
-8
lines changed

src/transforms/bin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function binn(
106106
for (const o of outputs) o.scope("facet", facet);
107107
if (sort) sort.scope("facet", facet);
108108
if (filter) filter.scope("facet", facet);
109-
for (const [, I] of maybeGroup(facet, G)) {
109+
for (const [f, I] of maybeGroup(facet, G)) {
110110
for (const [k, g] of maybeGroup(I, K)) {
111111
for (const [x1, x2, fx] of BX) {
112112
const bb = fx(g);
@@ -116,9 +116,9 @@ function binn(
116116
groupFacet.push(i++);
117117
groupData.push(reduceData.reduce(b, data));
118118
if (K) GK.push(k);
119-
if (Z) GZ.push(Z[b[0]]);
120-
if (F) GF.push(F[b[0]]);
121-
if (S) GS.push(S[b[0]]);
119+
if (Z) GZ.push(G === Z ? f : Z[b[0]]);
120+
if (F) GF.push(G === F ? f : F[b[0]]);
121+
if (S) GS.push(G === S ? f : S[b[0]]);
122122
if (BX1) BX1.push(x1), BX2.push(x2);
123123
if (BY1) BY1.push(y1), BY2.push(y2);
124124
for (const o of outputs) o.reduce(b);

src/transforms/group.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ function groupn(
9191
for (const o of outputs) o.scope("facet", facet);
9292
if (sort) sort.scope("facet", facet);
9393
if (filter) filter.scope("facet", facet);
94-
for (const [, I] of maybeGroup(facet, G)) {
94+
for (const [f, I] of maybeGroup(facet, G)) {
9595
for (const [y, gg] of maybeGroup(I, Y)) {
9696
for (const [x, g] of maybeGroup(gg, X)) {
9797
if (filter && !filter.reduce(g)) continue;
9898
groupFacet.push(i++);
9999
groupData.push(reduceData.reduce(g, data));
100100
if (X) GX.push(x);
101101
if (Y) GY.push(y);
102-
if (Z) GZ.push(Z[g[0]]);
103-
if (F) GF.push(F[g[0]]);
104-
if (S) GS.push(S[g[0]]);
102+
if (Z) GZ.push(G === Z ? f : Z[g[0]]);
103+
if (F) GF.push(G === F ? f : F[g[0]]);
104+
if (S) GS.push(G === S ? f : S[g[0]]);
105105
for (const o of outputs) o.reduce(g);
106106
if (sort) sort.reduce(g);
107107
}

0 commit comments

Comments
 (0)