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

[BUG] Cannot turn off legend for lines #216

Closed
krazatchu opened this issue Nov 27, 2023 · 2 comments
Closed

[BUG] Cannot turn off legend for lines #216

krazatchu opened this issue Nov 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@krazatchu
Copy link

Expected Behavior

Turning off lines in the legend call should maintain after a window resize.

Current Behaviour

I'm using both pyside6 and the native chart.
And I'm trying to figure out what's causing some chart flicker on pyside6 while using update_from_tick.

I turned off the legend lines - then resized the window and it comes back.
Then I set visible to False and the lines legend returns after a window resize.

Both pyside6 and native have this behavior.

Reproducible Example

import pandas as pd
from lightweight_charts import Chart

def calculate_sma(df, period: int = 50):
    return pd.DataFrame({
        'time': df['date'],
        f'SMA {period}': df['close'].rolling(window=period).mean()
    }).dropna()


if __name__ == '__main__':
    chart = Chart()
    chart.legend(visible=True)

    # df = pd.read_csv('ohlcv.csv')
    df = pd.read_csv('lw_charts_data/ohlc.csv')
    chart.set(df)

    line = chart.create_line('SMA 50')
    # line = chart.create_line('SMA 50', price_line=False, price_label=False) # same behavior

    sma_data = calculate_sma(df, period=50)
    line.set(sma_data)

    chart.legend(visible=False)   # turns off everything - comes back on resize
    # chart.legend(visible=True, lines=False)     # doesn't turn off legend for lines

    chart.show(block=True)


-- resize window with mouse --

Environment

- OS: win 11
- Library: 1.0.18.5
@krazatchu krazatchu added the bug Something isn't working label Nov 27, 2023
@louisnw01
Copy link
Owner

Hey @krazatchu,

This is a bug and it will be fixed in the next version.

Louis

louisnw01 added a commit that referenced this issue Dec 10, 2023
- Added the `color_based_on_candle` parameter to the legend, which will color the percentage change based on the candle color underneath the crosshair.
(#210)
- Fixed a bug which prevented the legend from turning off. (#216)
@louisnw01
Copy link
Owner

Fixed in the latest version.

Louis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants