Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom stuck when using DockArea to display multiples chart with different timeframe #551

Open
laixuanthoi opened this issue Feb 6, 2025 · 1 comment

Comments

@laixuanthoi
Copy link

laixuanthoi commented Feb 6, 2025

Hi.
I created 4 Dock to display 4 different timeframes: 1minute, 5minute, 1hour, 1day by following 'dockable.py' example.
Error occured when i couldn't zoom-in 1minute chart maybe 1d chart is reaching max zoom point.
Any idea to fix this.

Image

Here is my code

asyncio.run(load_historical_ticks())
for timeframe in TimeFrames:
    bars = build_bars_from_ticks(TickDf, timeframe, price_column='bid')
    Bars[timeframe] = bars

def update():
    ax0.reset() # remove previous plots
    ax1.reset() # remove previous plots
    ax2.reset() # remove previous plots
    ax3.reset() # remove previous p

    ohlc0 = fplt.candlestick_ochl(Bars[TimeFrames[0]]["open close high low".split()], ax = ax0)
    ohlc1 = fplt.candlestick_ochl(Bars[TimeFrames[1]]["open close high low".split()], ax = ax1)
    ohlc2 = fplt.candlestick_ochl(Bars[TimeFrames[2]]["open close high low".split()], ax = ax2)
    ohlc3 = fplt.candlestick_ochl(Bars[TimeFrames[3]]["open close high low".split()], ax = ax3)

    ohlc0.resamp = None
    ohlc1.resamp = None
    ohlc2.resamp = None
    ohlc3.resamp = None

    fplt.refresh() # refresh autoscaling when all plots complete

# create app
app = QApplication([])
# app.setStyle('Windows')

win = QMainWindow()
area = DockArea()
win.setCentralWidget(area)
win.resize(1600,800)
win.setWindowTitle(f"{Symbol} Replay Chart")
win.setStyleSheet("QSplitter { width : 10px; height : 10px; }")

# Create docks
dock_0 = Dock(f"{TimeFrames[0]}", size = (1000, 100), closable = False)
dock_1 = Dock(f"{TimeFrames[1]}", size = (1000, 100), closable = False)
dock_2 = Dock(f"{TimeFrames[2]}", size = (1000, 100), closable = False)
dock_3 = Dock(f"{TimeFrames[3]}", size = (1000, 100), closable = False)

area.addDock(dock_0)
area.addDock(dock_1, 'right', dock_0)
area.addDock(dock_2)
area.addDock(dock_3, 'right', dock_2)

#creat axis
ax0,ax1,ax2,ax3 = fplt.create_plot_widget(master=area, rows=4, init_zoom_periods=100)
# ax0,ax1,ax2,ax3 = fplt.create_plot('', rows=4, init_zoom_periods=100)

area.axs = [ax0, ax1, ax2, ax3]
dock_0.addWidget(ax0.ax_widget, 1, 0, 1, 1)
dock_1.addWidget(ax1.ax_widget, 1, 0, 1, 1)
dock_2.addWidget(ax2.ax_widget, 1, 0, 1, 1)
dock_3.addWidget(ax3.ax_widget, 1, 0, 1, 1)

# Link x-axis
ax1.setXLink(ax0)
ax2.setXLink(ax0)
ax3.setXLink(ax0)
win.axs = [ax0,ax1,ax2,ax3]

update()

fplt.show(qt_exec = False)
win.show()
app.exec()
@laixuanthoi laixuanthoi changed the title Zoom stuck when using Docker to display multiples chart with different timeframe Zoom stuck when using Dock to display multiples chart with different timeframe Feb 6, 2025
@laixuanthoi laixuanthoi changed the title Zoom stuck when using Dock to display multiples chart with different timeframe Zoom stuck when using DockArea to display multiples chart with different timeframe Feb 6, 2025
@highfestiva
Copy link
Owner

I guess you could try fplt.max_zoom_points = 1 (or possibly even 0, if that doesn't crash). That setting regulates how far you can zoom, default is 20 (so 20 days in your case). GL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants