@@ -2246,3 +2246,172 @@ describe('vchart updateSpec of different title', () => {
2246
2246
} ) ;
2247
2247
} ) ;
2248
2248
} ) ;
2249
+
2250
+ describe ( 'vchart updateSpec of different indicator' , ( ) => {
2251
+ let container : HTMLElement ;
2252
+ let dom : HTMLElement ;
2253
+ let vchart : VChart ;
2254
+ beforeAll ( ( ) => {
2255
+ container = createDiv ( ) ;
2256
+ dom = createDiv ( container ) ;
2257
+ dom . id = 'container' ;
2258
+ container . style . position = 'fixed' ;
2259
+ container . style . width = '500px' ;
2260
+ container . style . height = '500px' ;
2261
+ container . style . top = '0px' ;
2262
+ container . style . left = '0px' ;
2263
+ } ) ;
2264
+
2265
+ afterAll ( ( ) => {
2266
+ removeDom ( container ) ;
2267
+ vchart . release ( ) ;
2268
+ } ) ;
2269
+
2270
+ it ( 'should reMake when `visible` of indicator change to `false`' , ( ) => {
2271
+ const spec = {
2272
+ type : 'area' ,
2273
+ data : [
2274
+ {
2275
+ id : 'area' ,
2276
+ values : [
2277
+ { x : '1990' , y : 110 , from : 'video ad' } ,
2278
+ { x : '1995' , y : 160 , from : 'video ad' } ,
2279
+ { x : '2000' , y : 230 , from : 'video ad' } ,
2280
+ { x : '2005' , y : 300 , from : 'video ad' } ,
2281
+ { x : '2010' , y : 448 , from : 'video ad' } ,
2282
+ { x : '2015' , y : 500 , from : 'video ad' } ,
2283
+ { x : '1990' , y : 120 , from : 'email marketing' } ,
2284
+ { x : '1995' , y : 150 , from : 'email marketing' } ,
2285
+ { x : '2000' , y : 200 , from : 'email marketing' } ,
2286
+ { x : '2005' , y : 210 , from : 'email marketing' } ,
2287
+ { x : '2010' , y : 300 , from : 'email marketing' } ,
2288
+ { x : '2015' , y : 320 , from : 'email marketing' }
2289
+ ]
2290
+ }
2291
+ ] ,
2292
+ title : {
2293
+ visible : true ,
2294
+ text : 'test'
2295
+ } ,
2296
+ xField : 'x' ,
2297
+ yField : 'y' ,
2298
+ seriesField : 'from' ,
2299
+ indicator : {
2300
+ title : {
2301
+ visible : true ,
2302
+ style : {
2303
+ text : 'bbb'
2304
+ }
2305
+ } ,
2306
+ content : [
2307
+ {
2308
+ visible : true ,
2309
+ style : {
2310
+ fontSize : 20 ,
2311
+ text : '2222'
2312
+ }
2313
+ }
2314
+ ]
2315
+ }
2316
+ } ;
2317
+ vchart = new VChart ( spec , {
2318
+ dom
2319
+ } ) ;
2320
+ vchart . renderSync ( ) ;
2321
+ const updateRes = ( vchart as any ) . _updateSpec (
2322
+ {
2323
+ ...spec ,
2324
+ indicator : {
2325
+ ...spec . indicator ,
2326
+ visible : false
2327
+ }
2328
+ } ,
2329
+ false
2330
+ ) ;
2331
+
2332
+ expect ( updateRes ) . toEqual ( {
2333
+ changeBackground : false ,
2334
+ change : true ,
2335
+ changeTheme : false ,
2336
+ reCompile : true ,
2337
+ reMake : false ,
2338
+ reRender : true ,
2339
+ reSize : false ,
2340
+ reTransformSpec : false
2341
+ } ) ;
2342
+ } ) ;
2343
+
2344
+ it ( 'should reMake when `visible` of indicator change from `false` to `true`' , ( ) => {
2345
+ const spec = {
2346
+ type : 'area' ,
2347
+ data : [
2348
+ {
2349
+ id : 'area' ,
2350
+ values : [
2351
+ { x : '1990' , y : 110 , from : 'video ad' } ,
2352
+ { x : '1995' , y : 160 , from : 'video ad' } ,
2353
+ { x : '2000' , y : 230 , from : 'video ad' } ,
2354
+ { x : '2005' , y : 300 , from : 'video ad' } ,
2355
+ { x : '2010' , y : 448 , from : 'video ad' } ,
2356
+ { x : '2015' , y : 500 , from : 'video ad' } ,
2357
+ { x : '1990' , y : 120 , from : 'email marketing' } ,
2358
+ { x : '1995' , y : 150 , from : 'email marketing' } ,
2359
+ { x : '2000' , y : 200 , from : 'email marketing' } ,
2360
+ { x : '2005' , y : 210 , from : 'email marketing' } ,
2361
+ { x : '2010' , y : 300 , from : 'email marketing' } ,
2362
+ { x : '2015' , y : 320 , from : 'email marketing' }
2363
+ ]
2364
+ }
2365
+ ] ,
2366
+ title : {
2367
+ visible : true ,
2368
+ text : 'test'
2369
+ } ,
2370
+ xField : 'x' ,
2371
+ yField : 'y' ,
2372
+ seriesField : 'from' ,
2373
+ indicator : {
2374
+ title : {
2375
+ visible : false ,
2376
+ style : {
2377
+ text : 'bbb'
2378
+ }
2379
+ } ,
2380
+ content : [
2381
+ {
2382
+ visible : true ,
2383
+ style : {
2384
+ fontSize : 20 ,
2385
+ text : '2222'
2386
+ }
2387
+ }
2388
+ ]
2389
+ }
2390
+ } ;
2391
+ vchart = new VChart ( spec , {
2392
+ dom
2393
+ } ) ;
2394
+ vchart . renderSync ( ) ;
2395
+ const updateRes = ( vchart as any ) . _updateSpec (
2396
+ {
2397
+ ...spec ,
2398
+ indicator : {
2399
+ ...spec . indicator ,
2400
+ visible : true
2401
+ }
2402
+ } ,
2403
+ false
2404
+ ) ;
2405
+
2406
+ expect ( updateRes ) . toEqual ( {
2407
+ changeBackground : false ,
2408
+ change : true ,
2409
+ changeTheme : false ,
2410
+ reCompile : true ,
2411
+ reMake : false ,
2412
+ reRender : true ,
2413
+ reSize : false ,
2414
+ reTransformSpec : false
2415
+ } ) ;
2416
+ } ) ;
2417
+ } ) ;
0 commit comments