Skip to content

Implement arrayOk behavior for trace 'hoverinfo' #1749

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

Closed
alexcjohnson opened this issue May 31, 2017 · 1 comment · Fixed by #1761
Closed

Implement arrayOk behavior for trace 'hoverinfo' #1749

alexcjohnson opened this issue May 31, 2017 · 1 comment · Fixed by #1761
Assignees
Labels
feature something new

Comments

@alexcjohnson
Copy link
Collaborator

The plotly_beforehover event can be used to prevent hover effects dynamically, by attaching a handler that returns false if you don't want the hover label. But it has two shortcomings:

  • It doesn't include info about which point(s) were going to get a label, only the mouse event. If we move this event to after the hover data has been calculated but before the labels have been displayed, we should be able to fix this.
    • The ideal fix would be to make the event data match most of our other events, and include the plotly data and the mouse event inside one object. But if we did this now, it would be a breaking change. Do we think this is acceptable? I don't see what useful thing people would do with the mouse event by itself, so I wouldn't be too worried about this, but it is a breaking change.
    • @n-riesco suggests an alternative: we could fire this event after gd._hoverdata has been set, so the handler can inspect it, and then if the handler returns false we reset gd._hoverdata to what it was before (or just clear it?) Perhaps this would be a safer way to do it, then switch to ^^ in v2?
  • If you attach multiple handlers, only the return value of the last one will be used. This is both limiting and potentially dangerous (if your app can possibly attach handlers in unknown order) Can we change to pass on the && of any of these handlers returning false? (ie undefined and other falsey values should not count as false if we do this, only false itself).

@etpinard thoughts?

@etpinard
Copy link
Contributor

etpinard commented Jun 2, 2017

After some internal discussions, we'll implement the desired by making hoverinfo an arrayOk attribute.

e.g.

trace = {
  x: [1, 2, 3],
  y: [1, 2, 1],
  hoverinfo: ['x+y','skip', 'skip']
}

would only show x+y info on the (1,1) point, the other points would get no labels.


This should be part of the next minor release 1.28.0.

@etpinard etpinard changed the title make plotly_beforehover event more useful Implement arrayOk behavior for trace 'hoverinfo' Jun 2, 2017
@etpinard etpinard added the feature something new label Jun 2, 2017
@etpinard etpinard self-assigned this Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants