lightweight-charts-python icon indicating copy to clipboard operation
lightweight-charts-python copied to clipboard

subchart with streamlit

Open yakir4123 opened this issue 1 year ago • 3 comments

Question

Im following this https://lightweight-charts-python.readthedocs.io/en/latest/examples/subchart.html#synced-line-chart the only difference is that im using StreamlitChart. And i cant make it work. I did the exact example Is subchart not working for streamlit charts? I want to add rsi too.

When i plot the line on the base streamlit chart it works correctly .

Code example

import pandas as pd
from lightweight_charts.widgets import StreamlitChart

def create_chart(candles, rsi):
    chart = StreamlitChart(inner_width=1, inner_height=0.8)
    chart.time_scale(visible=False)

    chart2 = chart.create_subchart(width=1, height=0.2, sync=True)
    line = chart2.create_line()
 
    chart.set(candles)
    line.set(rsi)

    return chart

...

chart = create_chart(candles, rsi)
chart.load()

yakir4123 avatar Mar 08 '24 15:03 yakir4123

same question in jupyter notebook

pentcn avatar Mar 11 '24 07:03 pentcn

import pandas as pd
from lightweight_charts.widgets import StreamlitChart

def create_chart(candles, rsi):
    chart = StreamlitChart(width=600, height=900, inner_width=1, inner_height=0.8)
    chart.time_scale(visible=False)

    chart2 = chart.create_subchart(width=1, height=0.2, sync=True)
    line = chart2.create_line()
 
    chart.set(candles)
    line.set(rsi)

    return chart

...

chart = create_chart(candles, rsi)
chart.load()

need to add chart width and height to display properly

babygodzilla avatar May 06 '24 02:05 babygodzilla

Thank you ill test it as soon as possible.

yakir4123 avatar May 06 '24 08:05 yakir4123

that works, but it seems like hotkeys won't work in streamlit ? is there any solutions?

tsauliu avatar Nov 15 '24 08:11 tsauliu

Does not work in jupyter

ironhak avatar Mar 24 '25 13:03 ironhak