Skip to content

Fill doesnt work when curves are of type scattergl #7383

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

Open
53r1k opened this issue Feb 28, 2025 · 4 comments
Open

Fill doesnt work when curves are of type scattergl #7383

53r1k opened this issue Feb 28, 2025 · 4 comments
Labels
bug something broken P3 backlog

Comments

@53r1k
Copy link

53r1k commented Feb 28, 2025

When the type of 2 curves is "scattergl" and there is a fill betweem them, it doesnt work.

Here is a reproducible, minimized codepen: https://codepen.io/GoldBlacky/pen/yyLgOdd

I would also be very happy about a workaround or general direction to try to implement a workaround myself. The reason I need scattergl is because my application is too laggy when using scatter with multiple thousand data points.

Thanks!

@53r1k
Copy link
Author

53r1k commented Feb 28, 2025

Found a workaround by enclosing the space between the two curves I want to fill in a polygon:

const xPolygon = xValues.concat(xValues.reverse());
const yPolygon = yMax.concat(yMin.reverse());

then for the plotly data, providing this polygon data and filling toself:
x: xPolygon,
y: yPolygon,
type: "scattergl",
mode: "lines",
fill: "toself",
fillcolor: "rgba(0, 0, 0, 0.14)",

@gvwilson gvwilson added bug something broken P3 backlog labels Feb 28, 2025
@gvwilson
Copy link
Contributor

Thanks @53r1k - glad you found a workaround. Realistically, I don't think we're going to be able to get to this one any time soon, but we'd be happy to prioritize review if you are interested in preparing a PR. Thanks - @gvwilson

@53r1k
Copy link
Author

53r1k commented Apr 7, 2025

I'm currently looking into the issue, and I managed to identify the problem. Thankfully it isn't webgl itself, just the logic about linking curves to each other isn't quite correct in the scattergl implementation. I was able to fix the issue I was experiencing by adjusting how the curves are linked, but it's a bit too hacky to PR right now. Any way, In the process of doing that, I also realized that the scattergl implementation of the fill also doesn't quite work with "toself", when the resulting shape is twisted (lines intersect), this can be tested with this PlotData for example:

{
"x": [1, 2, 3, 4, 4, 3, 2, 1],
"y": [3, 5, 1, 7, 5, 3, 2, 0],
"fill": "toself",
"type": "scattergl"
}

Since regular scatter has a fundamentally different implementation, it works there without a problem. So if you change the type to "scatter", it works fine.

Im not exactly sure, are interesecting lines supposed to be supported with fills like tonexty or toself?

@53r1k
Copy link
Author

53r1k commented Apr 7, 2025

For reference, this is what I mean with twisted shapes being drawn incorrectly by scattegl, the result of:
{
"x": [1, 2, 3, 4, 4, 3, 2, 1],
"y": [3, 5, 1, 7, 5, 3, 2, 0],
"fill": "toself",
"type": "scattergl"
}
gives us:
Image

Changing the type to scatter results in this image:

Image

@53r1k 53r1k changed the title Fill doesnt work when curves are of type scattegl Fill doesnt work when curves are of type scattergl Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants