Skip to content

Commit

Permalink
fix: fix vchart spec when leafSpec is simple type
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Dec 30, 2024
1 parent e441972 commit b30d9f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 18 additions & 0 deletions packages/vmind/__tests__/unit/vchartSpec/bar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,22 @@ describe('mergeAppendSpec of barchart', () => {
}
]);
});

it('should contain all spec when spec has more than one path', () => {
const append = {
leafSpec: {
mark: {
maxLineCount: 20
},
dimension: {
maxLineCount: 20
}
},
parentKeyPath: 'tooltip',
aliasKeyPath: 'tooltip'
};

const { newSpec } = mergeAppendSpec(merge({}, spec), append);
expect(newSpec.tooltip).toEqual(append.leafSpec);
});
});
15 changes: 7 additions & 8 deletions packages/vmind/src/atom/VChartSpec/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { BaseOptions } from '../type';
import { BaseAtom } from '../base';
import type { VChartSpecCtx } from '../../types';
import { mergeAppendSpec } from './utils';
import { isNil } from '@visactor/vutils';

export class VChartSpec extends BaseAtom<VChartSpecCtx, BaseOptions> {
name = AtomName.VCHART_SPEC;
Expand All @@ -29,15 +30,13 @@ export class VChartSpec extends BaseAtom<VChartSpecCtx, BaseOptions> {
return this.context;
}

if (!appendSpec || !appendSpec.leafSpec) {
return this.context;
}
if (appendSpec && 'leafSpec' in appendSpec) {
const { newSpec, code } = mergeAppendSpec(this.context.spec, appendSpec);

const { newSpec, code } = mergeAppendSpec(this.context.spec, appendSpec);

this.context.appendCode = code;
this.context.prevSpec = this.context.spec;
this.context.spec = newSpec;
this.context.appendCode = code;
this.context.prevSpec = this.context.spec;
this.context.spec = newSpec;
}

return this.context;
}
Expand Down

0 comments on commit b30d9f1

Please sign in to comment.