@@ -177,25 +177,12 @@ export function stack(m: Mark | MarkDef, encoding: Encoding<string>): StackPrope
177177 const dimensionDef = encoding [ dimensionChannel ] ;
178178 const dimensionField = isFieldDef ( dimensionDef ) ? vgField ( dimensionDef , { } ) : undefined ;
179179 const hasSameDimensionAndStackedField = dimensionField && dimensionField === stackedField ;
180- const isUnbinnedQuant = isUnbinnedQuantitative ( dimensionDef ) ;
180+ const isDimensionUnbinnedQuant = isUnbinnedQuantitative ( dimensionDef ) ;
181181
182- // Check if both the field channel and dimension channel have unbinned quantitative fields
183- const isFieldUnbinnedQuant = isUnbinnedQuantitative ( stackedFieldDef ) ;
184-
185- const bothChannelsAreUnbinnedQuantitative = isUnbinnedQuant && isFieldUnbinnedQuant ;
186-
187- // For area charts, we need to ensure we still group by the dimension field
188- // even if both fields are quantitative (e.g., for cumulative frequency plots)
189- const isAreaMark = mark === 'area' ;
190-
191- // The core logic: we only add to groupBy when:
192- // 1. The dimension field is different from the stacked field (to avoid redundant grouping)
193- // 2. AND either:
194- // a. The dimension field is not an unbinned quantitative field, OR
195- // b. The field channel is not an unbinned quantitative field, OR
196- // c. It's an area mark (which needs grouping even with quantitative fields)
197- const shouldAddToGroupBy =
198- ! hasSameDimensionAndStackedField && ( ! isUnbinnedQuant || ! bothChannelsAreUnbinnedQuantitative || isAreaMark ) ;
182+ // The core logic for when to add a dimension to groupBy:
183+ // 1. Never add if dimension field is the same as stacked field (avoid redundancy)
184+ // 2. Add if dimension is not an unbinned quantitative field
185+ const shouldAddToGroupBy = ! hasSameDimensionAndStackedField && ! isDimensionUnbinnedQuant ;
199186
200187 if ( shouldAddToGroupBy ) {
201188 // avoid grouping by the stacked field
0 commit comments