Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scale): zero domain min and max #5014

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
return inferDomainO(values);
case 'sequential': {
const [d0, d1] = inferDomainS(values);
return [domainMin || d0, domainMax || d1];
return [domainMin ?? d0, domainMax ?? d1];
}
default:
return [];
Expand Down Expand Up @@ -316,8 +316,8 @@
const fullName = upperFirst(palette);

// If scheme have enough colors, then return pre-defined colors.
const scheme = d3ScaleChromatic[`scheme${fullName}`];

Check warning on line 319 in src/runtime/scale.ts

View workflow job for this annotation

GitHub Actions / build

Unable to validate computed reference to imported namespace 'd3ScaleChromatic'
const interpolator = d3ScaleChromatic[`interpolate${fullName}`];

Check warning on line 320 in src/runtime/scale.ts

View workflow job for this annotation

GitHub Actions / build

Unable to validate computed reference to imported namespace 'd3ScaleChromatic'
if (!scheme && !interpolator) return null;

if (scheme) {
Expand Down
Loading