File tree 2 files changed +25
-8
lines changed
__tests__/unit/vchartSpec
2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -295,4 +295,22 @@ describe('mergeAppendSpec of barchart', () => {
295
295
}
296
296
] ) ;
297
297
} ) ;
298
+
299
+ it ( 'should contain all spec when spec has more than one path' , ( ) => {
300
+ const append = {
301
+ leafSpec : {
302
+ mark : {
303
+ maxLineCount : 20
304
+ } ,
305
+ dimension : {
306
+ maxLineCount : 20
307
+ }
308
+ } ,
309
+ parentKeyPath : 'tooltip' ,
310
+ aliasKeyPath : 'tooltip'
311
+ } ;
312
+
313
+ const { newSpec } = mergeAppendSpec ( merge ( { } , spec ) , append ) ;
314
+ expect ( newSpec . tooltip ) . toEqual ( append . leafSpec ) ;
315
+ } ) ;
298
316
} ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { BaseOptions } from '../type';
3
3
import { BaseAtom } from '../base' ;
4
4
import type { VChartSpecCtx } from '../../types' ;
5
5
import { mergeAppendSpec } from './utils' ;
6
+ import { isNil } from '@visactor/vutils' ;
6
7
7
8
export class VChartSpec extends BaseAtom < VChartSpecCtx , BaseOptions > {
8
9
name = AtomName . VCHART_SPEC ;
@@ -29,15 +30,13 @@ export class VChartSpec extends BaseAtom<VChartSpecCtx, BaseOptions> {
29
30
return this . context ;
30
31
}
31
32
32
- if ( ! appendSpec || ! appendSpec . leafSpec ) {
33
- return this . context ;
34
- }
33
+ if ( appendSpec && 'leafSpec' in appendSpec ) {
34
+ const { newSpec, code } = mergeAppendSpec ( this . context . spec , appendSpec ) ;
35
35
36
- const { newSpec, code } = mergeAppendSpec ( this . context . spec , appendSpec ) ;
37
-
38
- this . context . appendCode = code ;
39
- this . context . prevSpec = this . context . spec ;
40
- this . context . spec = newSpec ;
36
+ this . context . appendCode = code ;
37
+ this . context . prevSpec = this . context . spec ;
38
+ this . context . spec = newSpec ;
39
+ }
41
40
42
41
return this . context ;
43
42
}
You can’t perform that action at this time.
0 commit comments