Skip to content

Commit

Permalink
fix: allow axis settings when ("bin":"binned"). (#7192)
Browse files Browse the repository at this point in the history
Before, any axis blocks would be dropped from the resulting Vega, including any
axis settings. After, mirror the behavior of ("bin":true) - axis settings cause
the axis block to be included.

This because I wanted grid lines to accompany my pre-binned data.

Co-authored-by: Yclept Nemo <pscjtwjdjtAhnbjm/dpn>
  • Loading branch information
orbisvicis committed Jan 31, 2021
1 parent 95f8d5d commit 09a407a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/compile/axis/properties.ts
Expand Up @@ -56,13 +56,8 @@ export const axisRules: {
return guideFormatType(formatType, fieldOrDatumDef, scaleType);
},

grid: ({fieldOrDatumDef, axis, scaleType}) => {
if (isFieldDef(fieldOrDatumDef) && isBinned(fieldOrDatumDef.bin)) {
return false;
} else {
return axis.grid ?? defaultGrid(scaleType, fieldOrDatumDef);
}
},
grid: ({fieldOrDatumDef, axis, scaleType}) =>
axis.grid ?? defaultGrid(scaleType, fieldOrDatumDef),

gridScale: ({model, channel}) => gridScale(model, channel),

Expand Down Expand Up @@ -125,7 +120,7 @@ export const axisRules: {
*/

export function defaultGrid(scaleType: ScaleType, fieldDef: TypedFieldDef<string> | DatumDef) {
return !hasDiscreteDomain(scaleType) && isFieldDef(fieldDef) && !isBinning(fieldDef?.bin);
return !hasDiscreteDomain(scaleType) && isFieldDef(fieldDef) && !isBinning(fieldDef?.bin) && !isBinned(fieldDef?.bin);
}

export function gridScale(model: UnitModel, channel: PositionScaleChannel) {
Expand Down

0 comments on commit 09a407a

Please sign in to comment.