Skip to content

Legend drag gets misaligned in the bottom 2/3 of the plot #1438

Closed
@alexcjohnson

Description

@alexcjohnson

Another one discovered while fiddling re: #1432 - If you make a plot with a legend (perhaps http://localhost:3000/devtools/test_dashboard/#legend_style) and make it editable so you can drag the legend (Plotly.newPlot(gd, gd.data, gd.layout, {editable: true})) you can drag the legend around anywhere in the top 1/3 of the plot area and it positions itself correctly. But if you drag it to the middle or bottom of the plot area, it jumps back up a bit when you drop it.

This comes from a miscalculation with yanchor: auto, which is the default yanchor value, and means that when you're in the middle third of the plot, the position (legend.y) is anchored to the middle of the legend, and when you're in the bottom third it's anchored to the bottom of the legend. This setting is designed to make it easy to keep the legend aligned near a corner of the plot even when the plot size might change.

It seems like x also has this problem, but it has an additional problem that xanchor defaults to left rather than auto as it should. That may be a tougher one to solve, as we can't just change the default without breaking backward compatibility for some plots...

Annotations (when paper-referenced with no arrow) have the same auto anchor behavior, but they do not have either of these bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions