Skip to content

Implement arrayOk behavior for trace 'hoverinfo' #1749

Closed
@alexcjohnson

Description

@alexcjohnson

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?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions