Skip to content

Commit

Permalink
Merge pull request #82 from VisActor/fix/identity-scale
Browse files Browse the repository at this point in the history
Fix/identity scale
  • Loading branch information
xile611 authored Aug 29, 2023
2 parents 7a6c509 + 9762932 commit ba6a3dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix(vscale): identity scale may have no domain\n\n",
"type": "none",
"packageName": "@visactor/vscale"
}
],
"packageName": "@visactor/vscale",
"email": "dingling112@gmail.com"
}
2 changes: 2 additions & 0 deletions packages/vscale/__tests__/identity-scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { IdentityScale } from '../src/identity-scale';
test('IdentityScale of any values', () => {
const scale = new IdentityScale();

expect(scale.domain()).toBeUndefined();
expect(scale.range()).toBeUndefined();
expect(scale.scale('x')).toBe('x');
expect(scale.scale(12)).toBe(12);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/vscale/src/identity-scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class IdentityScale implements IBaseScale {
domain(_: any[]): this;
domain(_?: any[]): this | any {
if (!_) {
return this._domain.slice();
return this._domain ? this._domain.slice() : undefined;
}
this._domain = _;

Expand All @@ -65,7 +65,7 @@ export class IdentityScale implements IBaseScale {
range(_: any[]): this;
range(_?: any[]): this | any {
if (!_) {
return this._domain.slice();
return this._domain ? this._domain.slice() : undefined;
}

return this;
Expand Down

0 comments on commit ba6a3dd

Please sign in to comment.