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

Plot discontinuous lines

Open TodeDragos opened this issue 1 year ago • 4 comments

Question

Hello,

I'm currently using the Chart class to plot a line chart for a time series data. However, I've encountered an issue when trying to plot a line that has gaps (i.e., discontinuous line).

Here's a simplified version of my code:

chart = Chart()
bid1_line = chart.create_line('bid1_line', width=1, color='#FF0000')
data = df[['time', 'bid1_line']].dropna()
bid1_line.set(data)

In my data, there are periods where 'bid1_line' is NaN, and I would like these periods to appear as gaps in the line chart. However, the current implementation seems to connect the points before and after the gap, creating the impression of a continuous line.

I was wondering if there's a way to create a broken line chart using the Chart class? If not, could this feature be considered for a future update?

Thank you for your help.

Code example

No response

TodeDragos avatar Apr 11 '24 14:04 TodeDragos

Hi, I also encountered the same situation. I checked and found that when I zoom in, I can occupy non continuous lines, but when I zoom out, it shows continuous lines. By the way, have you solved this problem? If there is a good solution, can you share it?

Baili-BL avatar May 13 '24 05:05 Baili-BL

I changed the line style, still doesn't solve the problem.

LukeZhuohuiLi avatar May 14 '24 00:05 LukeZhuohuiLi

nope, unfortunately, I couldn't find any solution for this behavior.

TodeDragos avatar May 14 '24 18:05 TodeDragos

I just solved this by spliting the series, put them into two lists, and drawing them one by one using two for loops. Stupid but works.

LukeZhuohuiLi avatar May 15 '24 02:05 LukeZhuohuiLi

Fixed in latest version. Just use NaN or None values in your DataFrame for whitespace.

Louis

louisnw01 avatar Jun 01 '24 12:06 louisnw01