From 5b8ee24e60211305a80cf8a9c57c01f0fcaf5dee Mon Sep 17 00:00:00 2001 From: Younghoon Kim Date: Wed, 19 Jul 2023 12:54:31 -0700 Subject: [PATCH] Set stack for area with plain Qs on the both axes --- examples/specs/area_cumulative_freq.vl.json | 3 ++- src/stack.ts | 2 +- test/stack.test.ts | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/specs/area_cumulative_freq.vl.json b/examples/specs/area_cumulative_freq.vl.json index d74bc5dd933..82a51396bbe 100644 --- a/examples/specs/area_cumulative_freq.vl.json +++ b/examples/specs/area_cumulative_freq.vl.json @@ -14,7 +14,8 @@ }, "y": { "field": "Cumulative Count", - "type": "quantitative" + "type": "quantitative", + "aggregate": "max" } } } diff --git a/src/stack.ts b/src/stack.ts index 22fa87ce121..db05480795a 100644 --- a/src/stack.ts +++ b/src/stack.ts @@ -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') { diff --git a/test/stack.test.ts b/test/stack.test.ts index f8d29dc23d4..455748d07d9 100644 --- a/test/stack.test.ts +++ b/test/stack.test.ts @@ -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 = { + 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 = {