Skip to content

Commit

Permalink
fix(#9401): conditional opacity should respect default value
Browse files Browse the repository at this point in the history
  • Loading branch information
kanitw committed Jul 31, 2024
1 parent 4ef3cde commit 5cc9898
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/compile/mark/encode/nonposition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {SignalRef} from 'vega';
import {NonPositionScaleChannel} from '../../../channel';
import {Value} from '../../../channeldef';
import {Value, isConditionalDef} from '../../../channeldef';
import {VgEncodeChannel, VgEncodeEntry, VgValueRef} from '../../../vega.schema';
import {getMarkPropOrConfig, signalOrValueRef} from '../../common';
import {UnitModel} from '../../unit';
Expand All @@ -24,16 +24,22 @@ export function nonPosition(
const {vgChannel} = opt;
let {defaultRef, defaultValue} = opt;

const channelDef = encoding[channel];

if (defaultRef === undefined) {
// prettier-ignore
defaultValue ??= getMarkPropOrConfig(channel, markDef, config, {vgChannel, ignoreVgConfig: true});
defaultValue ??= getMarkPropOrConfig(channel, markDef, config, {
vgChannel,
// If there is no conditonal def, we ignore vgConfig so the output spec is concise.
// However, if there is a conditional def, we must include vgConfig so the default is respected.
ignoreVgConfig: !isConditionalDef(channelDef)
});

if (defaultValue !== undefined) {
defaultRef = signalOrValueRef(defaultValue);
}
}

const channelDef = encoding[channel];
const commonProps = {
markDef,
config,
Expand Down

0 comments on commit 5cc9898

Please sign in to comment.