Skip to content

Commit 714b07f

Browse files
author
michael xu
committed
try fix zoom bug
1 parent 230d0db commit 714b07f

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

finplotWindow.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self, dockArea, dockChart, interface):
3333

3434
self.IndVolumesActivated = False
3535

36+
self.last_zoom_x = []
37+
self.last_zoom_date = []
38+
3639
pass
3740

3841
#########
@@ -383,16 +386,30 @@ def setIndicator(self, indicatorName, activated):
383386
pass
384387

385388
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)
396413
return [x]
397414

398415
def zoomTo(self, dateStr1, dateStr2):

strategyTesterUI.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ def initialize(self):
3232
# Remove straty .py file name
3333
self.strategyBaseName = []
3434
for stratName in self.strategyNames:
35+
# here remove file extension
3536
self.strategyBaseName.append(QtCore.QFileInfo(stratName).baseName())
3637

3738
self.strategyNameCB.addItems(self.strategyBaseName)
38-
39+
self.strategyNameCB.setCurrentIndex(self.strategyNameCB.count()-1)
3940
pass
4041

4142
def run(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy