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

[BUG] StreamLit Box, Trend line

Open AlpatechEducation opened this issue 1 year ago • 2 comments

Expected Behavior

When Using normally, my box appears at the right place. With this:

chart.box(start_time='2024-11-29 08:07:00', end_time='2024-11-29 08:09:00', start_value=20860, end_value=20870, fill_color='rgba(255, 0, 0, 0.3)', round= True)

I expect my box to start at 8:07 and end at 8:09.

This work when using the chart without Streamlit Good

Current Behaviour

The box or trend line are at the far left and appears as a little vertical line Bad

Reproducible Example

chart.box(start_time='2024-11-29 08:07:00', end_time='2024-11-29 08:09:00', start_value=20860, end_value=20870, fill_color='rgba(255, 0, 0, 0.3)', round= True)

The same list is use with:

This works
chart = Chart()
chart.set(df_nq)
chart.show(block=True)

This do not work:

chart = StreamlitChart(width=900, height=600)
chart.set(df_nq)
chart.load()

Environment

- OS:Mac os
- Library: 2.1

AlpatechEducation avatar Dec 11 '24 20:12 AlpatechEducation

Image Changing it like this seems to solve the problem.Hope it helps you.

datukai avatar Feb 07 '25 12:02 datukai

Image Changing it like this seems to solve the problem.Hope it helps you.

The calculated _interval and offset are wrong for drawing single elements because of the flawed and overly clever _set_interval method, that is a very terrible implementation!

def _set_interval(self, df: pd.DataFrame):
    ...

Overriding the _set_interval method in the inheritance might be a good idea.

HEUDavid avatar Mar 21 '25 15:03 HEUDavid