@@ -33,6 +33,9 @@ def __init__(self, dockArea, dockChart, interface):
33
33
34
34
self .IndVolumesActivated = False
35
35
36
+ self .last_zoom_x = []
37
+ self .last_zoom_date = []
38
+
36
39
pass
37
40
38
41
#########
@@ -383,16 +386,30 @@ def setIndicator(self, indicatorName, activated):
383
386
pass
384
387
385
388
def _date_str2x (self , ax , date_str ):
386
- df = ax .getAxis ('bottom' ).vb .datasrc .df
387
- dftime = np .array (df .iloc [:, 0 ])
388
- lsttime = dftime .tolist ()
389
- # print(dftime)
390
- # print(lsttime)
391
-
392
- xtime = dt .strptime (date_str , '%Y-%m-%d %H:%M:%S' )
393
- xint = int ((xtime .timestamp ()+ 8 * 3600 )* 1e9 )
394
- print (xint ,lsttime [0 ])
395
- x = lsttime .index (xint )
389
+ print (type (ax .getAxis ('bottom' ).vb .datasrc ))
390
+ if ax .getAxis ('bottom' ).vb .datasrc is None :
391
+ x = self .last_zoom_x [self .last_zoom_date .index (date_str )]
392
+ else :
393
+ if self .last_zoom_date is not None and len (self .last_zoom_date ) == 2 :
394
+ self .last_zoom_date = []
395
+ self .last_zoom_x = []
396
+
397
+ df = ax .getAxis ('bottom' ).vb .datasrc .df
398
+ dftime = np .array (df .iloc [:, 0 ])
399
+ lsttime = dftime .tolist ()
400
+ # print(dftime)
401
+ # print(lsttime)
402
+
403
+ xtime = dt .strptime (date_str , '%Y-%m-%d %H:%M:%S' )
404
+ xint = int ((xtime .timestamp ()+ 8 * 3600 )* 1e9 )
405
+ print (xint ,lsttime [0 ])
406
+ x = lsttime .index (xint )
407
+ if self .last_zoom_date is None :
408
+ self .last_zoom_date = [date_str ]
409
+ self .last_zoom_x = [x ]
410
+ else :
411
+ self .last_zoom_date = self .last_zoom_date .append (date_str )
412
+ self .last_zoom_x = self .last_zoom_x .append (x )
396
413
return [x ]
397
414
398
415
def zoomTo (self , dateStr1 , dateStr2 ):
0 commit comments