@@ -287,43 +287,46 @@ class NetJSONGraphRender {
287
287
*
288
288
*/
289
289
graphRender ( JSONData , self ) {
290
- self . utils . echartsSetOption (
291
- self . utils . generateGraphOption ( JSONData , self ) ,
292
- self ,
293
- ) ;
290
+ const echartOptions = self . utils . generateGraphOption ( JSONData , self ) ;
291
+ if ( echartOptions . series [ 0 ] . label === undefined ) {
292
+ echartOptions . series [ 0 ] . label = { }
293
+ }
294
+ if (
295
+ ! echartOptions . series [ 0 ] . zoom ||
296
+ echartOptions . series [ 0 ] . zoom < self . config . showLabelsAtZoomLevel
297
+ ) {
298
+ echartOptions . series [ 0 ] . label . show = false ;
299
+ } else {
300
+ echartOptions . series [ 0 ] . label . show = true ;
301
+ }
302
+ self . utils . echartsSetOption ( echartOptions , self ) ;
294
303
295
304
window . onresize = ( ) => {
296
305
self . echarts . resize ( ) ;
297
306
} ;
298
307
299
- if (
300
- self . echarts . getOption ( ) . series [ 0 ] . zoom <
301
- self . config . showLabelsAtZoomLevel
302
- ) {
303
- self . echarts . setOption ( {
304
- series : [
305
- {
306
- label : {
307
- show : false ,
308
- } ,
309
- } ,
310
- ] ,
311
- } ) ;
312
- }
313
-
314
- self . echarts . on ( "graphRoam" , ( e ) => {
308
+ self . echarts . on ( "graphRoam" , ( ) => {
309
+ const customOptions = self . echarts . getOption ( ) ;
315
310
if (
316
- self . echarts . getOption ( ) . series [ 0 ] . zoom >=
317
- self . config . showLabelsAtZoomLevel
311
+ customOptions . series [ 0 ] . zoom >= self . config . showLabelsAtZoomLevel &&
312
+ ! customOptions . series [ 0 ] . label . show
318
313
) {
319
- self . echarts . setOption ( {
320
- series : [
321
- {
322
- label : {
323
- show : true ,
324
- } ,
325
- } ,
326
- ] ,
314
+ customOptions . series [ 0 ] . label . show = true ;
315
+ self . echarts . setOption ( customOptions , {
316
+ notMerge : {
317
+ silent : true ,
318
+ } ,
319
+ lazyUpdate : true ,
320
+ } ) ;
321
+ } else if (
322
+ customOptions . series [ 0 ] . zoom < self . config . showLabelsAtZoomLevel &&
323
+ customOptions . series [ 0 ] . label . show
324
+ ) {
325
+ customOptions . series [ 0 ] . label . show = false ;
326
+ self . echarts . setOption ( customOptions , {
327
+ notMerge : {
328
+ silent : true ,
329
+ } ,
327
330
} ) ;
328
331
}
329
332
} ) ;
0 commit comments