@@ -28,7 +28,8 @@ import {
28
28
minInArray ,
29
29
maxInArray ,
30
30
abs ,
31
- last
31
+ last ,
32
+ throttle
32
33
} from '@visactor/vutils' ;
33
34
// eslint-disable-next-line no-duplicate-imports
34
35
import type { IFilterMode } from './interface' ;
@@ -64,6 +65,8 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
64
65
protected _orient : IOrientType = 'left' ;
65
66
protected _isHorizontal : boolean ;
66
67
68
+ protected _throttledHide : ( ) => void ;
69
+
67
70
// 是否为自动模式
68
71
protected _auto ?: boolean ;
69
72
protected _fixedBandSize ?: number ;
@@ -448,25 +451,25 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
448
451
s . coordinate === 'cartesian'
449
452
? ( s as ICartesianSeries ) . getXAxisHelper ( )
450
453
: s . coordinate === 'polar'
451
- ? ( s as IPolarSeries ) . angleAxisHelper
452
- : null ;
454
+ ? ( s as IPolarSeries ) . angleAxisHelper
455
+ : null ;
453
456
const yAxisHelper =
454
457
s . coordinate === 'cartesian'
455
458
? ( s as ICartesianSeries ) . getYAxisHelper ( )
456
459
: s . coordinate === 'polar'
457
- ? ( s as IPolarSeries ) . radiusAxisHelper
458
- : null ;
460
+ ? ( s as IPolarSeries ) . radiusAxisHelper
461
+ : null ;
459
462
if ( ! xAxisHelper || ! yAxisHelper ) {
460
463
return ;
461
464
}
462
465
const stateAxisHelper =
463
466
xAxisHelper . getAxisId ( ) === this . _relatedAxisComponent . id
464
467
? xAxisHelper
465
468
: yAxisHelper . getAxisId ( ) === this . _relatedAxisComponent . id
466
- ? yAxisHelper
467
- : this . _isHorizontal
468
- ? xAxisHelper
469
- : yAxisHelper ;
469
+ ? yAxisHelper
470
+ : this . _isHorizontal
471
+ ? xAxisHelper
472
+ : yAxisHelper ;
470
473
const valueAxisHelper = stateAxisHelper === xAxisHelper ? yAxisHelper : xAxisHelper ;
471
474
472
475
dataCollection . push ( s . getRawData ( ) ) ;
@@ -642,8 +645,8 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
642
645
start = this . _spec . start
643
646
? this . _spec . start
644
647
: this . _spec . startValue
645
- ? this . dataToStatePoint ( this . _spec . startValue )
646
- : 0 ;
648
+ ? this . dataToStatePoint ( this . _spec . startValue )
649
+ : 0 ;
647
650
end = this . _spec . end ? this . _spec . end : this . _spec . endValue ? this . dataToStatePoint ( this . _spec . endValue ) : 1 ;
648
651
}
649
652
this . _startValue = this . statePointToData ( start ) ;
@@ -862,6 +865,9 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
862
865
if ( ! this . _activeRoam || ( this . _dragAttr . filter && ! this . _dragAttr . filter ( delta , e ) ) ) {
863
866
return ;
864
867
}
868
+ if ( ( this . _spec . roamDrag as IRoamDragSpec ) ?. autoVisible ) {
869
+ this . show ( ) ;
870
+ }
865
871
const [ dx , dy ] = delta ;
866
872
let value = this . _isHorizontal ? dx : dy ;
867
873
if ( this . _dragAttr . reverse ) {
@@ -886,7 +892,7 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
886
892
887
893
protected _initCommonEvent ( ) {
888
894
const delayType : IDelayType = this . _spec ?. delayType ?? 'throttle' ;
889
- const delayTime = isValid ( this . _spec ?. delayType ) ? this . _spec ?. delayTime ?? 30 : 0 ;
895
+ const delayTime = isValid ( this . _spec ?. delayType ) ? ( this . _spec ?. delayTime ?? 30 ) : 0 ;
890
896
const realTime = this . _spec ?. realTime ?? true ;
891
897
const option = { delayType, delayTime, realTime, allowComponentZoom : true } ;
892
898
if ( this . _zoomAttr . enable ) {
@@ -898,6 +904,13 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
898
904
if ( this . _dragAttr . enable ) {
899
905
( this as unknown as IZoomable ) . initDragEventOfRegions ( this . _regions , null , this . _handleChartDrag , option ) ;
900
906
}
907
+ if ( ( this . _spec . roamDrag as IRoamDragSpec ) ?. autoVisible ) {
908
+ const dragEnd = 'panend' ;
909
+ this . _throttledHide = throttle ( ( ) => this . hide ( ) , 300 ) ;
910
+ this . event . on ( dragEnd , ( ) => {
911
+ this . _throttledHide ( ) ;
912
+ } ) ;
913
+ }
901
914
}
902
915
903
916
updateLayoutAttribute ( ) : void {
@@ -1038,6 +1051,10 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
1038
1051
protected _getNeedClearVRenderComponents ( ) : IGraphic [ ] {
1039
1052
return [ this . _component ] as unknown as IGroup [ ] ;
1040
1053
}
1054
+
1055
+ clear ( ) : void {
1056
+ this . _throttledHide = null ;
1057
+ }
1041
1058
}
1042
1059
1043
1060
mixin ( DataFilterBaseComponent , Zoomable ) ;
0 commit comments