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

Change chart's percentage legend colour with each candle #210

Closed
litoco opened this issue Nov 23, 2023 · 1 comment
Closed

Change chart's percentage legend colour with each candle #210

litoco opened this issue Nov 23, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@litoco
Copy link

litoco commented Nov 23, 2023

Description

I was thinking to change colour of % move for a particular candle in chart legend but I wasn't able to find out any help regarding that. Currently we can only change colour of all legends open, high, close, low and percentage. And this change can be done before starting the chart. I wanted it to change colour with the candle that the crosshair is on. But I can't do that.

Is this feature already available? If not is there any workaround?

Code example

import pandas as pd
from lightweight_charts import Chart


if __name__ == '__main__':
    
    chart = Chart()

    df = pd.read_csv('ohlcv.csv')

    chart.layout(background_color='#090008', text_color='#FFFFFF', font_size=16,
                 font_family='Helvetica')

    chart.candle_style(up_color='#00ff55', down_color='#ed4807',
                       border_up_color='#FFFFFF', border_down_color='#FFFFFF',
                       wick_up_color='#FFFFFF', wick_down_color='#FFFFFF')

    chart.crosshair(mode='normal', vert_color='#FFFFFF', vert_style='dotted',
                    horz_color='#FFFFFF', horz_style='dotted')

    chart.legend(visible=True, font_size=14)

    chart.set(df)

    chart.show(block=True)

Now I wanted to change the colour of percentage move legend according to the candle that the crosshair is pointing to, but I am not able to do it currently.

@litoco litoco added the enhancement New feature or request label Nov 23, 2023
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

The latest version contains the color_based_on_candle parameter, which implements this feature.

Louis

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

No branches or pull requests

2 participants