diff --git a/src/compositemark/boxplot.ts b/src/compositemark/boxplot.ts index c281c9890eb..ef6bed38768 100644 --- a/src/compositemark/boxplot.ts +++ b/src/compositemark/boxplot.ts @@ -104,6 +104,8 @@ export function normalizeBoxPlot( const boxPlotType = getBoxPlotType(extent); const { + bins, + timeUnits, transform, continuousAxisChannelDef, continuousAxis, @@ -300,17 +302,14 @@ export function normalizeBoxPlot( } })[0]; + const filteredLayersMixinsTransforms = [...bins, ...timeUnits, joinaggregateTransform]; if (outlierLayersMixins && filteredWhiskerSpec) { filteredLayersMixins = { - transform: [joinaggregateTransform], + transform: filteredLayersMixinsTransforms, layer: [outlierLayersMixins, filteredWhiskerSpec] }; - } else if (outlierLayersMixins) { - filteredLayersMixins = outlierLayersMixins; - filteredLayersMixins.transform.unshift(joinaggregateTransform); - } else if (filteredWhiskerSpec) { - filteredLayersMixins = filteredWhiskerSpec; - filteredLayersMixins.transform.unshift(joinaggregateTransform); + } else if ((filteredLayersMixins = outlierLayersMixins || filteredWhiskerSpec)) { + filteredLayersMixins.transform.unshift(...filteredLayersMixinsTransforms); } } @@ -423,6 +422,8 @@ function boxParams( ]; return { + bins, + timeUnits, transform, groupby, aggregate, diff --git a/test/compositemark/boxplot.test.ts b/test/compositemark/boxplot.test.ts index d105e210682..6b19c5e1871 100644 --- a/test/compositemark/boxplot.test.ts +++ b/test/compositemark/boxplot.test.ts @@ -1070,4 +1070,31 @@ describe('normalizeBoxIQR', () => { const {tooltip} = normalizedSpecWithTooltip['layer'][0]['layer'][0]['encoding']; expect(tooltip).toEqual({field: 'year', type: 'quantitative'}); }); + + it("should include timeUnit transform in filteredLayerMixins' transform", () => { + const field = 'Date'; + const timeUnit = 'year'; + const normalizedSpec = normalize( + { + data: {url: 'data/population.json'}, + mark: 'boxplot', + encoding: { + x: { + field, + type: 'temporal', + timeUnit + }, + y: {field: 'Anomaly', type: 'quantitative'} + } + }, + defaultConfig + ); + + const filteredLayerMixins = normalizedSpec['layer'][1]; + expect(filteredLayerMixins.transform[0]).toEqual({ + timeUnit: {unit: 'year'}, + field, + as: `${timeUnit}_${field}` + }); + }); });