Skip to content
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

Add shapes.layer "between" for drawing between gridlines and traces #6927

Merged
merged 13 commits into from
Mar 28, 2024

Conversation

my-tien
Copy link
Contributor

@my-tien my-tien commented Mar 15, 2024

This PR adds the value "belowtraces" to the shapes.layer property. "below" draws the shape below the gridlines, "above" draws it above traces and "belowtraces" draws it between gridlines and traces.

I am required to add that…

the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

@my-tien my-tien force-pushed the below_traces branch 2 times, most recently from 16b6139 to 7338ad8 Compare March 15, 2024 16:09
@archmoj archmoj added feature something new community community contribution status: reviewable labels Mar 15, 2024
@archmoj archmoj changed the title Add shapes.layer "belowtraces" for drawing between gridlines and traces Add shapes.layer "between" for drawing between gridlines and traces Mar 18, 2024
@archmoj
Copy link
Contributor

archmoj commented Mar 18, 2024

This option should be added to newshape too here:


That way one could use this feature when drawing new shapes.

@my-tien
Copy link
Contributor Author

my-tien commented Mar 18, 2024

Hi @archmoj, thx for your feedback so far!
Please let me know if there are more locations I need to update for newshape. I didn't find any.

@my-tien
Copy link
Contributor Author

my-tien commented Mar 20, 2024

Hi, any pointers for this error that suddenly appeared? Can it be ignored?

  1. @gl should fetch GeoJSON using URLs found in the traces
    Test mapbox GeoJSON fetching:
    Error: Expected Error: GeoJSON at URL "invalidUrl-two" does not exist. to equal Error: GeoJSON at URL "invalidUrl" does not exist..
    at
    at eval (webpack://plotly.js/./test/jasmine/tests/mapbox_test.js?:1800:22)
    Error: Expected 'pending' to be undefined.
    at
    at eval (webpack://plotly.js/./test/jasmine/tests/mapbox_test.js?:1801:49)

@archmoj
Copy link
Contributor

archmoj commented Mar 20, 2024

We fixed a problem on CircleCI (#6935).
Please pull upstream/master and merge it into this branch.

@archmoj
Copy link
Contributor

archmoj commented Mar 21, 2024

@my-tien Thanks very much for the PR.

Just a little note:
Force pushing to PRs is discouraged as described here: https://github.com/plotly/plotly.js/blob/master/.github/PULL_REQUEST_TEMPLATE.md

It's just fine for now. But for future work it would be better to pull upstream/master and merge it instead of rebasing and force push.

Thanks again for all your great contributions.

I would request a second review from @emilykl on this PR.

@archmoj archmoj requested a review from emilykl March 21, 2024 14:42
@my-tien
Copy link
Contributor Author

my-tien commented Mar 21, 2024

@my-tien Thanks very much for the PR.

Just a little note: Force pushing to PRs is discouraged as described here: https://github.com/plotly/plotly.js/blob/master/.github/PULL_REQUEST_TEMPLATE.md

It's just fine for now. But for future work it would be better to pull upstream/master and merge it instead of rebasing and force push.

Thanks again for all your great contributions.

I would request a second review from @emilykl on this PR.

Right, I might have tested your tolerance there… will pay attention to that next time! :)

@emilykl
Copy link
Contributor

emilykl commented Mar 22, 2024

How does this behave with multiple overlaid sets of axes and gridlines?

- added axis y2 to test interaction between axes
- added shape label
- moved dashdot line to see more of its interaction with the gridlines
- removed transparency for easier visual checking
@my-tien
Copy link
Contributor Author

my-tien commented Mar 25, 2024

How does this behave with multiple overlaid sets of axes and gridlines?

I have added a y2 axis to the test to verify that it looks correct

draftlogs/6927_add.md Outdated Show resolved Hide resolved
@archmoj
Copy link
Contributor

archmoj commented Mar 26, 2024

@my-tien Please test the following mock:
It looks there is a problem placing some of the shapes in the relevant layer.

{
    "data":[{
        "x":[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1],
        "y":[1,2,3,4,5,6,7,8,9,10],
        "mode":"markers"
    },
    {
        "x":["2000-01-01", "2000-01-02"],
        "y":["a", "b"],
        "mode":"markers",
        "xaxis":"x2",
        "yaxis":"y2"
    }],
    "layout": {
        "xaxis":{"title":{"text":"linear"},"range":[0,1],"domain":[0.35,0.65],"type":"linear","zeroline":false,"showticklabels":false},
        "yaxis":{"title":{"text":"log"},"range":[0,1],"domain":[0.6,1],"type":"log","zeroline":false,"showticklabels":false},
        "xaxis2":{"title":{"text":"date"},"range":["2000-01-01","2000-01-02"],"domain":[0.7,1],"anchor":"y2","type":"date","zeroline":false,"showticklabels":false},
        "yaxis2":{"title":{"text":"category"},"range":[0,1],"domain":[0.6,1],"anchor":"x2","type":"category","zeroline":false,"showticklabels":false},
        "height":400,
        "width":800,
        "margin": {"l":20,"r":20,"pad":0},
        "showlegend":false,
        "shapes":[
            {"layer":"between","x0":0.1,"x1":0.4,"y0":1.5,"y1":20,"opacity":0.5,"fillcolor":"#f00","line":{"width":8,"color":"#008","dash":"dashdot"}},
            {"layer":"between","path":"M0.5,3C0.5,9 0.9,9 0.9,3C0.9,1 0.5,1 0.5,3ZM0.6,4C0.6,5 0.66,5 0.66,4ZM0.74,4C0.74,5 0.8,5 0.8,4ZM0.6,3C0.63,2 0.77,2 0.8,3Z","fillcolor":"#fd2","line":{"width":1,"color":"black"}},
            {"layer":"between","xref":"x2","yref":"y2","type":"circle","x0":"2000-01-01 02","x1":"2000-01-01 08:30:33.456","y0":0.1,"y1":0.9,"fillcolor":"rgba(0,0,0,0.5)","line":{"color":"rgba(0,255,0,0.5)", "width":5}},
            {"layer":"between","xref":"x2","yref":"y2","path":"M2000-01-01_11:20:45.6,0.2Q2000-01-01_10:00,0.85 2000-01-01_21,0.8Q2000-01-01_22:20,0.15 2000-01-01_11:20:45.6,0.2Z","fillcolor":"rgb(151,73,58)"},
            {"layer":"between","xref":"x2","yref":"y2","type":"line","x0":"2000-01-01 11:00","x1":"2000-01-01 09:00","y0":"b","y1":"a","line":{"color":"#006","width":3}}
        ]
    }
}

@my-tien
Copy link
Contributor Author

my-tien commented Mar 27, 2024

@my-tien Please test the following mock: It looks there is a problem placing some of the shapes in the relevant layer.

{
    "data":[{
        "x":[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1],
        "y":[1,2,3,4,5,6,7,8,9,10],
        "mode":"markers"
    },
    {
        "x":["2000-01-01", "2000-01-02"],
        "y":["a", "b"],
        "mode":"markers",
        "xaxis":"x2",
        "yaxis":"y2"
    }],
    "layout": {
        "xaxis":{"title":{"text":"linear"},"range":[0,1],"domain":[0.35,0.65],"type":"linear","zeroline":false,"showticklabels":false},
        "yaxis":{"title":{"text":"log"},"range":[0,1],"domain":[0.6,1],"type":"log","zeroline":false,"showticklabels":false},
        "xaxis2":{"title":{"text":"date"},"range":["2000-01-01","2000-01-02"],"domain":[0.7,1],"anchor":"y2","type":"date","zeroline":false,"showticklabels":false},
        "yaxis2":{"title":{"text":"category"},"range":[0,1],"domain":[0.6,1],"anchor":"x2","type":"category","zeroline":false,"showticklabels":false},
        "height":400,
        "width":800,
        "margin": {"l":20,"r":20,"pad":0},
        "showlegend":false,
        "shapes":[
            {"layer":"between","x0":0.1,"x1":0.4,"y0":1.5,"y1":20,"opacity":0.5,"fillcolor":"#f00","line":{"width":8,"color":"#008","dash":"dashdot"}},
            {"layer":"between","path":"M0.5,3C0.5,9 0.9,9 0.9,3C0.9,1 0.5,1 0.5,3ZM0.6,4C0.6,5 0.66,5 0.66,4ZM0.74,4C0.74,5 0.8,5 0.8,4ZM0.6,3C0.63,2 0.77,2 0.8,3Z","fillcolor":"#fd2","line":{"width":1,"color":"black"}},
            {"layer":"between","xref":"x2","yref":"y2","type":"circle","x0":"2000-01-01 02","x1":"2000-01-01 08:30:33.456","y0":0.1,"y1":0.9,"fillcolor":"rgba(0,0,0,0.5)","line":{"color":"rgba(0,255,0,0.5)", "width":5}},
            {"layer":"between","xref":"x2","yref":"y2","path":"M2000-01-01_11:20:45.6,0.2Q2000-01-01_10:00,0.85 2000-01-01_21,0.8Q2000-01-01_22:20,0.15 2000-01-01_11:20:45.6,0.2Z","fillcolor":"rgb(151,73,58)"},
            {"layer":"between","xref":"x2","yref":"y2","type":"line","x0":"2000-01-01 11:00","x1":"2000-01-01 09:00","y0":"b","y1":"a","line":{"color":"#006","width":3}}
        ]
    }
}

Can you specify which layer is placed incorrectly? I couldn't find an issue with this example (I removed transparency and made the traces overlap all shapes to see that it correctly draws on top of the shapes):

{
  "data":[{
      "x":[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1],
      "y":[1,2,3,4,5,6,6,6,6,6],
      "mode":"markers"
  },
  {
      "x":["2000-01-01", "2000-01-02"],
      "y":["a", "b"],
      "mode":"lines+markers",
      "xaxis":"x2",
      "yaxis":"y2"
  }],
  "layout": {
      "xaxis":{"title":{"text":"linear"},"range":[0,1],"domain":[0.35,0.65],"type":"linear","zeroline":false,"showticklabels":false},
      "yaxis":{"title":{"text":"log"},"range":[0,1],"domain":[0.6,1],"type":"log","zeroline":false,"showticklabels":false},
      "xaxis2":{"title":{"text":"date"},"range":["2000-01-01","2000-01-02"],"domain":[0.7,1],"anchor":"y2","type":"date","zeroline":false,"showticklabels":false},
      "yaxis2":{"title":{"text":"category"},"range":[0,1],"domain":[0.6,1],"anchor":"x2","type":"category","zeroline":false,"showticklabels":false},
      "height":400,
      "width":800,
      "margin": {"l":20,"r":20,"pad":0},
      "showlegend":false,
      "shapes":[
          {"layer":"between","x0":0.1,"x1":0.4,"y0":1.5,"y1":20,"opacity":1,"fillcolor":"#f00","line":{"width":8,"color":"#008","dash":"dashdot"}},
          {"layer":"between","path":"M0.5,3C0.5,9 0.9,9 0.9,3C0.9,1 0.5,1 0.5,3ZM0.6,4C0.6,5 0.66,5 0.66,4ZM0.74,4C0.74,5 0.8,5 0.8,4ZM0.6,3C0.63,2 0.77,2 0.8,3Z","fillcolor":"#fd2","line":{"width":1,"color":"black"}},
          {"layer":"between","xref":"x2","yref":"y2","type":"circle","x0":"2000-01-01 02","x1":"2000-01-01 08:30:33.456","y0":0.1,"y1":0.9,"fillcolor":"rgba(0,0,0,1)","line":{"color":"rgba(0,255,0,1)", "width":5}},
          {"layer":"between","xref":"x2","yref":"y2","path":"M2000-01-01_11:20:45.6,0.2Q2000-01-01_10:00,0.85 2000-01-01_21,0.8Q2000-01-01_22:20,0.15 2000-01-01_11:20:45.6,0.2Z","fillcolor":"rgb(151,73,58)"},
          {"layer":"between","xref":"x2","yref":"y2","type":"line","x0":"2000-01-01 11:00","x1":"2000-01-01 09:00","y0":"b","y1":"a","line":{"color":"#006","width":3}}
      ]
  }
}

image

@archmoj
Copy link
Contributor

archmoj commented Mar 27, 2024

Thanks for testing it out. So It was because of the transparency that I thought there is an issue.
Resolved.

@my-tien Please test the following mock: It looks there is a problem placing some of the shapes in the relevant layer.

Can you specify which layer is placed incorrectly? I couldn't find an issue with this example (I removed transparency and made the traces overlap all shapes to see that it correctly draws on top of the shapes):

image

@archmoj
Copy link
Contributor

archmoj commented Mar 28, 2024

Nicely completed.
💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants