Plotly.js: compare/unified hover should include all points at same coordinate

Created on 17 Mar 2020  路  10Comments  路  Source: plotly/plotly.js

In x-unified and x-compare modes, it should never be possible for there to be two data with the same x-coordinate and only one of them is displayed in a hoverlabel. I know compare mode doesn't currently behave this way but I consider it a bug.

The solution proposed by @alexcjohnson seems good to me:

  • Step 1: find hover points the way we do now
  • Step 2: loop back over traces not in the set of hover points we already found, and see if any of them have a point with position-axis value exactly matching what we found for the other point(s)
bug

Most helpful comment

Indeed :) I was just noticing while testing that as I sweep in an increasing-x direction, I get the hover at 1, then 1.1, then 1 again even though my mouse is now at 1.2 or so. C'est la vie: the bar picks it up and then adds the point from 1. It's more correct than anything else I can think of right now :)

All 10 comments

Demonstration of the issue:
unified

The approach suggested by @alexcjohnson seem to work fine for the simple case shown above: https://codepen.io/antoinerg/pen/gOpKwPg (ie. scatter and bar).

Now, I wonder if there are cases for which this may lead to undesirable behavior. WIP on branch fix-4656.

Now, I wonder if there are cases for which this may lead to undesirable behavior. WIP on branch fix-4656.

For one, categorical axis are not working ATM. Working on a fix.

My branch fix-4656 now has fixes for date and categorical axes: https://codepen.io/antoinerg/pen/gOpKwPg

cc @nicolaskruchten

Looks good! Here's an oddity that I don't think we can easily fix, with two points above a bar, one at a slightly different x-coordinate:

unified

Looks good! Here's an oddity that I don't think we can easily fix, with two points above a bar, one at a slightly different x-coordinate:

unified

I'm curious, what behavior would you rather have in that case?

two points above a bar, one at a slightly different x-coordinate

There's a reason the title of this issue says "should include all points at same coordinate" 馃槒

Indeed :) I was just noticing while testing that as I sweep in an increasing-x direction, I get the hover at 1, then 1.1, then 1 again even though my mouse is now at 1.2 or so. C'est la vie: the bar picks it up and then adds the point from 1. It's more correct than anything else I can think of right now :)

Some tests are failing with the changes made in branch fix-4656: multiple boxes/violins sharing a category with offsets. See second figure in https://codepen.io/antoinerg/pen/gOpKwPg . It used to hover on 1 box, now it hovers 2 boxes. I imagine we'd rather hover on all of them right? Would it be OK to only select 1 box as we did before?

@alexcjohnson when you have a chance, can you take a look at branch fix-4656 and let me know what you think of this approach (and potential pitfalls).

For boxes and violins, the 1.52 behaviour for compare was good IMO.

Was this page helpful?
0 / 5 - 0 ratings