Skip to content

Commit

Permalink
fix: use expression to generalize zeroOrMinOrMax when there is a scale
Browse files Browse the repository at this point in the history
  • Loading branch information
kanitw committed May 9, 2024
1 parent cd7d913 commit bbeeff9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/compile/mark/encode/zeroOrMinOrMax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ export function zeroOrMinOrMax({
};
}

if (scaleName) {
const domain = `domain('${scaleName}')`;
const min = `${domain}[0]`;
const max = `${domain}[1]`;

switch (mode) {
case 'min':
return {signal: `scale('${scaleName}', ${min})`}; // encode the scale domain min
case 'zeroOrMin':
return {signal: `scale('${scaleName}', inrange(0, ${domain}) ? 0 : ${min})`}; // encode the scale domain min
default: //zeroOrMax
return {signal: `scale('${scaleName}', inrange(0, ${domain}) ? 0 : ${max})`}; // encode the scale domain min
}
}

if (mode === 'zeroOrMin' || mode === 'min') {
switch (mainChannel) {
case 'radius':
Expand Down

0 comments on commit bbeeff9

Please sign in to comment.