Skip to content

scattergl fillcolor incorrect with multiple polygons in same trace when with fill: toself #2291

Closed

Description

@cpsievert

https://codepen.io/cpsievert/pen/ZvNqjQ

Note that fillcolor renders correctly when type: scatter.

Activity

  1. jackparmer commented on Jan 24, 2018

    @jackparmer
    Contributor

    cc @Kully - this is going to be an issue with the Python county choropleth as well. Probably watch this issue and hold off on the WebGL approach until this is fixed:

    image

  2. Kully commented on Jan 24, 2018

    @Kully
    Contributor

    I actually found that toself fill didn't work with just one polygon (ie list of coordinates defining a contained polygon)

    But I only checked in the Python API

  3. jackparmer commented on Jan 26, 2018

    @jackparmer
    Contributor

    Here is what I get for a full US county map for SVG vs WebGL using toself:

    image

  4. alexcjohnson commented on Mar 8, 2018

    @alexcjohnson
    Collaborator

    related: #2450

  5. Kully commented on May 28, 2018

    @Kully
    Contributor

    Another example of the USA choropleth from here: https://plot.ly/python/county-choropleth/#the-entire-usa This is switching scatter -> scattergl in the figurefactory.

    screen shot 2018-05-28 at 12 07 32 pm

  6. jackparmer commented on May 28, 2018

    @jackparmer
    Contributor

    ⬆️ Doesn't look like the recent scattergl fill changes fixed things for this particular use case

  7. etpinard commented on May 28, 2018

    @etpinard
    Contributor

    Doesn't look like the recent scattergl fill changes fixed things for this particular use case

    There haven't been any scattergl fill changes since the regl push back January.

  8. jackparmer commented on May 28, 2018

    @jackparmer
    Contributor

    Oh, I thought @dy had done some work on regl-line2d fills after January. I guess I'm misremembering.

  9. etpinard commented on May 28, 2018

    @etpinard
    Contributor

    He's done some work. But none of which is ready to get merged at this stage.

  10. dy commented on May 28, 2018

    @dy
    Contributor

    It is coming, after regl-text. Pls stay tuned)

  11. alexcjohnson commented on Jul 26, 2018

    @alexcjohnson
    Collaborator

    A nice pared-down reproduction from @llnns in #2845:


    Using scattergl with toself fill option results in a "ghost"/wrong/extra fill among the first points of each object. A minimal example creating three rectangles:

    https://codepen.io/anon/pen/NBvbbv

    Results in:

    newplot

    Also, using the same data with scatter type has the expected output:

    newplot 1

  12. llnns commented on Jul 26, 2018

    @llnns

    Hey, maybe another hint here:
    Using https://codepen.io/anon/pen/NBvbbv as an example.

    It seems that the extra triangle comes from the triangulation function earcut. The block at

    else if(trace.fill === 'toself' || trace.fill === 'tonext') {
    pos = [];
    last = 0;
    for(j = 0; j < srcPos.length; j += 2) {
    if(isNaN(srcPos[j]) || isNaN(srcPos[j + 1])) {
    pos = pos.concat(srcPos.slice(last, j));
    pos.push(srcPos[last], srcPos[last + 1]);
    last = j + 2;
    }
    }
    pos = pos.concat(srcPos.slice(last));
    if(last) {
    pos.push(srcPos[last], srcPos[last + 1]);
    }
    }
    is generating the follow pos array:

    pos = [
      0,
      9,
      0,
      10,
      1,
      10,
      1,
      9,
      0,
      9,
      0,
      9,
      1,
      6,
      1,
      8,
      2,
      8,
      2,
      6,
      1,
      6,
      1,
      6,
      2,
      1,
      2,
      2,
      3,
      2,
      3,
      1,
      2,
      1,
      2,
      1
    ]
    

    That it is been pass to earcut function as earcut(pos, []) (I think at: https://github.com/a-vis/regl-line2d/blob/d4e34d3d38b20fce5bc0398e3cf30181d1f506a0/index.js#L519 ) resulting in the follow triangles indices array:

    triangles = [
      15,
      14,
      13,
      9,
      8,
      7,
      3,
      2,
      1,
      4,
      3,
      1,
      15,
      13,
      12,
      6,
      0,
      12,
      7,
      10,
      9
    ]
    

    Notice that the result has 21 indices, 7 triangles, one more than the 6 needed for the 3 rectangles example. Also, I am not sure if it is intended, but in the pos array the last position of each rectangle is duplicated.

  13. etpinard commented on Sep 19, 2018

    @etpinard
    Contributor

    A very nice example from @ErwanMAS in #3025


    Please look .

    https://codepen.io/erwanmas/pen/dqQrbR

    The issue is generated by https://github.com/mapbox/earcut in https://github.com/a-vis/regl-line2d . AND earcut doesn't guarantee correctness

    https://github.com/mapbox/earcut/blob/master/README.md

    a simple console.log here https://github.com/a-vis/regl-line2d/blob/b9d56d51e1598c4ee7a9a5e0a733e920daf63c2d/index.js#L520 will output only 1 triangle , instead of 2 triangles

  14. 4 remaining items

  15. rlele5 commented on Jun 11, 2020

    @rlele5

    Hi all, still having this issue. Are there any plans to merge any of the proposed solutions into main plotly? This single bug fix could potentially fix so many of my plotting performance issues, so I'm eagerly looking forward to it! Hopefully it can be prioritized.

    Another example posted here if needed: https://community.plotly.com/t/feature-request-for-gantt-gl-like-scatter-gl/37925/4

    Tag: @archmoj, @etpinard

  16. jackparmer commented on Sep 10, 2020

    @jackparmer
    Contributor

    This issue has been tagged with NEEDS SPON$OR

    A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.

    Sponsorship range: $15k-$20k

    What Sponsorship includes:

    • Completion of this feature to the Sponsor's satisfaction, in a manner coherent with the rest of the Plotly.js library and API
    • Tests for this feature
    • Long-term support (continued support of this feature in the latest version of Plotly.js)
    • Documentation at plotly.com/javascript
    • Possibility of integrating this feature with Plotly Graphing Libraries (Python, R, F#, Julia, MATLAB, etc)
    • Possibility of integrating this feature with Dash
    • Feature announcement on community.plotly.com with shout out to Sponsor (or can remain anonymous)
    • Gratification of advancing the world's most downloaded, interactive scientific graphing libraries (>50M downloads across supported languages)

    Please include the link to this issue when contacting us to discuss.

  17. rlele5 commented on Sep 12, 2020

    @rlele5

    Thanks for the update :). Now another feature request for @github, if you're listening - we should have Gofundmes attached to issues! I'd gladly commit a few hundred to this issue if it could be done in a safe and organized way

  18. avsdev-cw commented on Nov 9, 2020

    @avsdev-cw

    I would also like to see this fixed, so +1 for that.

    However that I feel that sponsership range is pretty excessive considering a bunch of people have already dug out what the root cause appears to be...

  19. ruijin commented on Dec 18, 2020

    @ruijin
    Contributor

    Created two PR to plotlyjs and regl

    #5355
    gl-vis/regl-line2d#49

    I am happy to help with any further testing, as long as this got fixed.

  20. rlele5 commented on Dec 31, 2020

    @rlele5

    @ruijin , thanks for making the pull requests! I'm excited to try them out!

  21. rlele5 commented on Jan 14, 2021

    @rlele5

    Hi @ruijin , I tried manually updating the /Library/Frameworks/Python.framework/Versions/3.7/share/jupyter/lab/staging/node_modules/plotly.js/src/traces/scattergl and /Library/Frameworks/Python.framework/Versions/3.7/share/jupyter/lab/staging/node_modules/regl-line2d/index.js code and then I restarted my jupyter notebook to see if it worked. However, I still saw the same issue. I'm pretty sure the issue is on my end, but do you know how I can get my plotly.py library to "uptake" the changes that I manually made to plotly.js? I've tried deleting plotly.py's __pycache__ and restarting/rerunning to no avail.

  22. added this to the NEXT milestone on Jan 14, 2021
  23. archmoj commented on Jan 14, 2021

    @archmoj
    Contributor

    Fixed via #5355.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions