Skip to content

x-unified hover tooltips overflow #5721

Closed

Description

@xenatisch

Synopsis

The hover tooltips in x-unified mode exceed max-width and therefore overflow. This happens when:

  • the chart is small and close to the sides
  • the chart is large (near width size) on a small screen - e.g. mobile
  • the tooltip is displayed for a point on the chart that falls near the mid-point of the x-axis

The issue persists in Plotly v2.0.0.

Example

You can see an example of the issue on our live service, provided that your browser width is smaller than ~580px.

Screenshot 2021-06-08 at 14 52 22

Expected behaviour

The hover tooltip x-extrema must always fall between x-extrema of the browser. An even better outcome would be for the tooltip to not spill out of the cartesian axes.

I don't think there's an easy / immediate solution to this, primarily because the tooltip position moves based on cursor position. I suppose one way to address it is to do what folks at Google Charts have done - i.e. move the tooltip until it hits one side, then stop moving horizontally.

Here's an example, which you've probably seen before:

google-sample
[Credit: Google]

Thanks again for all your efforts.

Activity

  1. nicolaskruchten commented on Jun 8, 2021

    @nicolaskruchten
    Contributor

    I actually think this is "just a bug" where the hoverlabel should be on the left-hand side if there is room there. If there not enough room on either side then yes, we will need some new behaviour.

  2. alexcjohnson commented on Jun 8, 2021

    @alexcjohnson
    Collaborator

    Seems like in this plot we've set the figure width to a half-integer, and perhaps due to rounding that's allowing us to draw the hover label 1px beyond the true displayed edge of its container. If we keep all our hover labels 1px away from the edges no matter what (just change by 1px the condition for flipping the label to the left side), that should fix this.

  3. added
    bug
    on Jun 8, 2021
  4. nicolaskruchten commented on Jun 8, 2021

    @nicolaskruchten
    Contributor

    The hoverlabel looks like it's much more than 1px beyond the edge, though, no?

  5. nicolaskruchten commented on Jun 8, 2021

    @nicolaskruchten
    Contributor

    Ah I see, this is just a really wide hoverlabel and there is a zone where there is no room on either the left or the right :(

    In this case @xenatisch I would recommend using newlines i.e. <br> in the hovertemplate if you can on narrow screens? Like before "daily" or something?

  6. alexcjohnson commented on Jun 8, 2021

    @alexcjohnson
    Collaborator

    Ah right, x unified doesn't seem to have the centered fallback for when there isn't room on either side like closest and x modes have. We should add that. But I was definitely able to get a situation where there was plenty of room on the left for the whole label, yet it was shown on the right side with just 1px border cut off. So I think we should pad it 1px as well.

  7. xenatisch commented on Jun 8, 2021

    @xenatisch
    Author

    So, there are two issues here - one is ours, the other is yours:

    • Some of our labels are just too long, and that needs to be fixed. This is something for our content team to think about as the labels are set dynamically.
    • Where the labels aren't toooo long, some of the tooltips still overflow, and that's the topic of this issue.

    In the latter case, as you highlighted eloquently, there is indeed enough space on one side, but the tooltip still overflows without using the space that's available. This, however, tends to happen when we're near the mid-point. How close to the mid-point? That would depend on the width of the tooltip itself.

    This clip shows the problem more clearly (I think / hope):

    Here's the link to the graph in the clip in case you want to experiment with it yourself.

    tooltip-thing.mov
  8. added this to the v2.3.0 milestone on Jul 22, 2021
  9. xenatisch commented on Jul 23, 2021

    @xenatisch
    Author

    Hallelujah. Thanks @nicolaskruchten, @archmoj, and @alexcjohnson. Looking forward to 2.3.0.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions