Skip to content

Commit 230d0db

Browse files
author
mole
committed
part fix zoom issue
1 parent 6bcb9b7 commit 230d0db

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

finplotWindow.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import finplot as fplt
1414

1515
import pandas as pd
16+
import numpy as np
17+
from datetime import datetime as dt
1618
import backtrader as bt
1719
from pyqtgraph import mkColor, mkBrush
1820

@@ -379,13 +381,26 @@ def setIndicator(self, indicatorName, activated):
379381
self.updateChart()
380382

381383
pass
382-
384+
385+
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)
396+
return [x]
397+
383398
def zoomTo(self, dateStr1, dateStr2):
384399

385400
for win in fplt.windows:
386401
for ax in win.axs:
387-
x1 = fplt._dateStr2x(ax,dateStr1)
388-
x2 = fplt._dateStr2x(ax,dateStr2)
402+
x1 = self._date_str2x(ax, dateStr1)
403+
x2 = self._date_str2x(ax, dateStr2)
389404

390405
# Do not zoom exactly on the trade, so take a little bit before & after
391406
date1 = x1[0]

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