Plotly.js: Hoverlabel clipping should occur with 0 or tight margins

Created on 26 Sep 2019  路  13Comments  路  Source: plotly/plotly.js

Right now it's possible for various plot elements to clip when margin is set to 0, for example the hoverlabel on the axis in hovermode: closest

image

bug

Most helpful comment

Looks fine there.

All 13 comments

This also happens in the horizontal case:

image

Related #3607

What would be the best solution here?

1) should we fit the hover label into viewport, and then possibly tweak the tip shape?
1) should we truncate the hover label text and add ellipses?


I'd vote for 1), but please let me know if you disagree or have a better solution in mind.

When the axis is perpendicular to the edge (second screenshot) then just moving the hoverlabel such that it fits would work I think. When the axis is parallel to the edge (first screenshot) I think ellipses will be needed? hard to imagine what else we can do in this case.

Might be nice to explore solutions to https://github.com/plotly/plotly.js/issues/3985 at the same time as this ticket.

Here's a first attempt:

https://github.com/plotly/plotly.js/compare/common-label-overlaps


Under hovermode: 'x', the common hover label (i.e. the one on top of the x axis) is constrained into the viewport while the hover label arrow appear on the left or right edge.

https://codepen.io/etpinard/pen/NWWpPmq

Peek 2019-10-22 14-48


Under hovermode: 'y', the common hover label for side:'left' y axes has its text shifted to the right so that its beginning is visible and then clipped so that it doesn't overlap the hover label arrow.

https://codepen.io/etpinard/pen/LYYWEvr

Peek 2019-10-22 14-51

Re https://codepen.io/etpinard/pen/NWWpPmq the hoverlabels look great but the axis label is pretty clipped ;P

Re https://codepen.io/etpinard/pen/LYYWEvr when I set automargin there's still a tiny bit of clipping on the "Way longer" one.

the hoverlabels look great but the axis label is pretty clipped

Yes, it was much easier to show the new behaviour w/o setting automargin: true

Re https://codepen.io/etpinard/pen/LYYWEvr when I set automargin there's still a tiny bit of clipping on the "Way longer" one.

Where?

Peek 2019-10-22 15-21

taken off https://codepen.io/etpinard/pen/GRRWJMg

Here's what it looks like in Chrome/MacOS on your pen:

image

Here's what it looks like in Chrome/MacOS on your pen:

Ok, that's odd. How does it look like w/o automargin: true e.g. using https://codepen.io/etpinard/pen/LYYWEvr ?

Looks fine there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WG- picture WG-  路  3Comments

boleslawmaliszewski picture boleslawmaliszewski  路  3Comments

hashimmoosavi picture hashimmoosavi  路  3Comments

chriddyp picture chriddyp  路  3Comments

nicolaskruchten picture nicolaskruchten  路  3Comments