diff --git a/examples/compiled/bar_negative_horizontal_label.vg.json b/examples/compiled/bar_negative_horizontal_label.vg.json index 08f2c46abe..021382b43c 100644 --- a/examples/compiled/bar_negative_horizontal_label.vg.json +++ b/examples/compiled/bar_negative_horizontal_label.vg.json @@ -173,7 +173,6 @@ "labelPadding": 4, "ticks": false, "labelAlign": "right", - "labelBaseline": null, "zindex": 0 } ] diff --git a/src/compile/axis/assemble.ts b/src/compile/axis/assemble.ts index a102511bee..9e0ed0919f 100644 --- a/src/compile/axis/assemble.ts +++ b/src/compile/axis/assemble.ts @@ -5,7 +5,7 @@ import {POSITION_SCALE_CHANNELS} from '../../channel'; import {defaultTitle, FieldDefBase} from '../../channeldef'; import {Config} from '../../config'; import {isText} from '../../title'; -import {getFirstDefined, isEmpty, replaceAll} from '../../util'; +import {contains, getFirstDefined, isEmpty, replaceAll} from '../../util'; import {isSignalRef, VgEncodeChannel, VgValueRef} from '../../vega.schema'; import {exprFromValueOrSignalRef} from '../common'; import {Model} from '../model'; @@ -101,6 +101,12 @@ export function assembleAxis( delete axis[prop]; } // else do nothing since the property already supports signal } + + // Do not pass labelAlign/Baseline = null to Vega since it won't pass the schema + // Note that we need to use null so the default labelAlign is preserved. + if (contains(['labelAlign', 'labelBaseline'], prop) && axis[prop] === null) { + delete axis[prop]; + } } if (kind === 'grid') {