|
1 | 1 | import {array, hasOwnProperty, isBoolean} from 'vega-util'; |
2 | 2 | import {Aggregate, SUM_OPS} from './aggregate.js'; |
3 | | -import {getSecondaryRangeChannel, NonPositionChannel, NONPOSITION_CHANNELS, isPolarPositionChannel} from './channel.js'; |
| 3 | +import {getSecondaryRangeChannel, NonPositionChannel, NONPOSITION_CHANNELS} from './channel.js'; |
4 | 4 | import { |
5 | 5 | channelDefType, |
6 | 6 | FieldName, |
@@ -173,20 +173,19 @@ export function stack(m: Mark | MarkDef, encoding: Encoding<string>): StackPrope |
173 | 173 | const groupbyChannels: StackProperties['groupbyChannels'] = []; |
174 | 174 | const groupbyFields: Set<FieldName> = new Set(); |
175 | 175 |
|
176 | | - if (encoding[dimensionChannel]) { |
177 | | - const dimensionDef = encoding[dimensionChannel]; |
178 | | - const dimensionField = isFieldDef(dimensionDef) ? vgField(dimensionDef, {}) : undefined; |
179 | | - const hasSameDimensionAndStackedField = dimensionField && dimensionField === stackedField; |
| 176 | + const dimensionDef = encoding[dimensionChannel]; |
| 177 | + const dimensionField = isFieldDef(dimensionDef) ? vgField(dimensionDef, {}) : undefined; |
| 178 | + const hasSameDimensionAndStackedField = dimensionField && dimensionField === stackedField; |
180 | 179 |
|
181 | | - // For polar coordinates, do not set a groupBy when working with quantitative fields. |
182 | | - const isPolar = isPolarPositionChannel(fieldChannel) || isPolarPositionChannel(dimensionChannel); |
183 | | - const shouldAddPolarGroupBy = !isUnbinnedQuantitative(dimensionDef); |
| 180 | + // Do not set a groupBy when working with unbinned quantitative fields |
| 181 | + // This applies to both polar and cartesian coordinates |
| 182 | + const shouldAddGroupBy = !isUnbinnedQuantitative(dimensionDef); |
184 | 183 |
|
185 | | - if (isPolar ? shouldAddPolarGroupBy : !hasSameDimensionAndStackedField) { |
186 | | - // avoid grouping by the stacked field |
187 | | - groupbyChannels.push(dimensionChannel); |
188 | | - groupbyFields.add(dimensionField); |
189 | | - } |
| 184 | + // If it's binned, we don't need to group by the dimension field, because we will filter out the offset in the end anyway |
| 185 | + if (shouldAddGroupBy && !hasSameDimensionAndStackedField) { |
| 186 | + // avoid grouping by the stacked field |
| 187 | + groupbyChannels.push(dimensionChannel); |
| 188 | + groupbyFields.add(dimensionField); |
190 | 189 | } |
191 | 190 |
|
192 | 191 | const dimensionOffsetChannel = dimensionChannel === 'x' ? 'xOffset' : 'yOffset'; |
|
0 commit comments