Skip to content

Commit

Permalink
fix(scale): zero domain min and max (#5014)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored and hustcc committed May 12, 2023
1 parent b94ef47 commit 2e92914
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions __tests__/plots/static/basic-interval-zero-domain-min.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { G2Spec } from '../../../src';

export async function basicIntervalZeroDomainMin(): Promise<G2Spec> {
return {
type: 'interval',
data: [
{ name: 'MODIFY', value: 138, washaway: 0.21014492753623193 },
{ name: 'PRERELEASE', value: 109, washaway: 0.5596330275229358 },
{ name: 'RELEASING', value: 48, washaway: 0 },
{ name: 'XXX', value: -48, washaway: 0 },
],
encode: {
x: 'name',
y: 'value',
color: 'name',
},
scale: {
y: { domainMin: 0 },
},
};
}
1 change: 1 addition & 0 deletions __tests__/plots/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,4 @@ export { mockPointLogTicks } from './mock-point-log-ticks';
export { alphabetIntervalLabelRotate } from './alphabet-interval-label-rotate';
export { aaplLineBasicTranspose } from './aapl-line-basic-transpose';
export { alphabetIntervalSortXDomain } from './alphabet-interval-sort-x-domain';
export { basicIntervalZeroDomainMin } from './basic-interval-zero-domain-min';
4 changes: 2 additions & 2 deletions src/runtime/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function inferScaleDomain(
case 'quantize':
case 'threshold': {
const [d0, d1] = inferDomainQ(values, options);
return [domainMin || d0, domainMax || d1];
return [domainMin ?? d0, domainMax ?? d1];
}
case 'band':
case 'ordinal':
Expand All @@ -210,7 +210,7 @@ function inferScaleDomain(
return inferDomainO(values);
case 'sequential': {
const [d0, d1] = inferDomainS(values);
return [domainMin || d0, domainMax || d1];
return [domainMin ?? d0, domainMax ?? d1];
}
default:
return [];
Expand Down

0 comments on commit 2e92914

Please sign in to comment.