Skip to content

Commit

Permalink
Set stack for area with plain Qs on the both axes
Browse files Browse the repository at this point in the history
  • Loading branch information
yhoonkim committed Jul 19, 2023
1 parent 277e556 commit 5b8ee24
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/specs/area_cumulative_freq.vl.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"y": {
"field": "Cumulative Count",
"type": "quantitative"
"type": "quantitative",
"aggregate": "max"
}
}
}
2 changes: 1 addition & 1 deletion src/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function potentialStackedChannel(
return xAggregate ? x : y;
}

if (isCartesian && mark === 'bar') {
if (isCartesian && ['bar', 'area'].includes(mark)) {
if (orient === 'vertical') {
return y;
} else if (orient === 'horizontal') {
Expand Down
15 changes: 15 additions & 0 deletions test/stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,21 @@ describe('stack', () => {
}
});

it('should stack even for two plain quantitatives with the orient on the axes', () => {
for (const mark of [BAR, AREA]) {
const spec: TopLevel<NormalizedUnitSpec> = {
data: {url: 'data/movies.json'},
mark: {type: mark, orient: 'vertical'}, // orient also can be inferred by init.ts
encoding: {
x: {field: 'IMDB Rating', type: 'quantitative'},
y: {field: 'Rotten Tomatoes Rating', type: 'quantitative'}
}
};
const stackProps = stack(spec.mark, spec.encoding);
expect(stackProps.fieldChannel).toBe(Y);
}
});

it('should be correct for horizontal (single)', () => {
for (const stackableMark of [BAR, AREA]) {
const spec: TopLevel<NormalizedUnitSpec> = {
Expand Down

0 comments on commit 5b8ee24

Please sign in to comment.