plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
17.02k stars 1.86k forks source link

provide line connect threshold to avoid need to add NaNs to data #6551

Open VelizarVESSELINOV opened 1 year ago

VelizarVESSELINOV commented 1 year ago

We must add nan rows to the datasets if we want to plot a line plot with significant gaps in the middle.

https://stackoverflow.com/questions/71382497/removing-gaps-between-data-on-a-plotly-graph This workaround could be better as we add fake data to make the plot do what we want.

Let's define line_connect_threshold = x if the distance is more significant, not connected.

nicolaskruchten commented 1 year ago

OOh, that's a really nice idea, and would work really well for a-priori periodic data like daily data: missing days could result in gaps if the threshold is one day. Thoughts @alexcjohnson and @archmoj ?

alexcjohnson commented 1 year ago

I like it, thanks @VelizarVESSELINOV! Moved to plotly.js where it'll need to be implemented. Also I'll note that in principle we need two separate thresholds, an x and a y, or a threshold and an axis (though maybe you could come up with a scenario where you want both simultaneously?), in case your smoothly-incrementing variable is in the y direction. I'm not sure about the name... line.autogapx and line.autogapy perhaps?

Would also be nice for wrapped periodic data, that scans across and then jumps back to the start and scans again, where currently you also need to insert a null to avoid drawing a line connecting one scan to the next.

nicolaskruchten commented 1 year ago

Ah yes the wrapped case where the delta is negative essentially. Hearty vote for this feature!!

nicolaskruchten commented 1 year ago

How about (x|y)gapthreshold?