Skip to content

[BUG]cross hair is missing in QT GUI #411

@bobokingbao

Description

@bobokingbao

Requirements (place an x in each of the [ ])**

  • I realize finplot is not a web lib. (Hint: it's native!)
  • I've read the snippets and not found what I'm looking for.
  • I've searched for any related issues and avoided creating a duplicate issue.
  • I've updated finplot (pip install -U finplot).
  • I've supplied the required data to run my code below.

Code to reproduce

import finplot as fplt
#here is main code in my QT GUI which call the finplot code
self.tableWidget_self_select.doubleClicked.connect(self.DoubleClicked)

#here is the finplot implementation code which i copy from the example
    def DoubleClicked(self):
        print("DoubleClicked")
        # Draw charts based on input data
        ret_stock_list = QUANT_STOCK_API.quant_stock_day_query(code='000001', start='2017-10-01')
        stock_day_fields = ['code', 'open', 'high', 'low', 'close', 'volume', 'amount', 'date']

        df = pd.DataFrame(ret_stock_list, columns=stock_day_fields)
        df.rename(
            columns={
                'date': 'Date', 'open': 'Open',
                'high': 'High', 'low': 'Low',
                'close': 'Close','volume': 'Volume'},
            inplace=True)
        df['Date'] = df['Date'].apply(lambda x: datetime.strptime((x), '%Y-%m-%d %H:%M:%S'))
        #df = df.set_index('Date')
        self.data = df
        # create two axes
        ax, ax2 = fplt.create_plot('600000', rows=2)

        # plot candle sticks
        candles = df[['Date', 'Open', 'Close', 'High', 'Low']]
        fplt.candlestick_ochl(candles, ax=ax)

        # overlay volume on the top plot
        volumes = df[['Date', 'Open', 'Close', 'High', 'Volume']]
        fplt.volume_ocv(volumes, ax=ax.overlay())

        # put an MA on the close price
        fplt.plot(df['Date'], df['Close'].rolling(25).mean(), ax=ax, legend='ma-25')

        # place some dumb markers on low wicks
        lo_wicks = df[['Open', 'Close']].T.min() - df['Low']
        df.loc[(lo_wicks > lo_wicks.quantile(0.99)), 'marker'] = df['Low']
        fplt.plot(df['Date'], df['marker'], ax=ax, color='#4a5', style='^', legend='dumb mark')

        # draw some random crap on our second plot
        fplt.plot(df['Date'], np.random.normal(size=len(df)), ax=ax2, color='#927', legend='stuff')
        fplt.set_y_range(-1.4, +3.7, ax=ax2)  # hard-code y-axis range limitation
        #fplt.add_crosshair_info(self.update_crosshair_text, ax=ax)
        # restore view (X-position and zoom) if we ever run this example again
        fplt.autoviewrestore()
        fplt.foreground = '#777'
        fplt.background = '#19232D'
        fplt.candle_bull_color = fplt.candle_bull_body_color = '#0b0'
        fplt.candle_bear_color = '#a23'
        volume_transparency = '6'
        # we're done
        fplt.show()

Describe the bug

in the chart the crosshair is missing and some error message in the console when i am trying to use mouse wheel

Expected behavior

crosshair work properly and not error message related to the mouse wheel event

Screenshots

following is the error message

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\pyqt\lib\site-packages\finplot\__init__.py", line 790, in wheelEvent
    _mouse_moved(self.win, None)
  File "C:\ProgramData\Anaconda3\envs\pyqt\lib\site-packages\finplot\__init__.py", line 2477, in _mouse_moved
    evs = master_data[master]['last_mouse_evs']
KeyError: <finplot.FinWindow object at 0x000001AC1E9FA0D0>

and the screenshot
54b5f1263e4229d0fe736c35f1b5ad8

and the odd thing is that if i run the example code independently ,for example, create a py file such as demo.py and copy the example code into it and run this py file ,it works



#### Reproducible in:

*OS*:
*finplot 1.9:
*pyqtgraph 0.13.1:
*pyqt 6.4.2:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions