Skip to content
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

Data onover / onout not reliably called when moving between different series with same x-value #2901

Closed
grantcox opened this issue Oct 11, 2022 · 3 comments
Assignees
Labels

Comments

@grantcox
Copy link

grantcox commented Oct 11, 2022

Description

I want to show some information based on which datapoint is currently highlighted - much like a tooltip. This additional data involves template rendering so is a little expensive to generate, so I'd like to update it only when the highlighted data point actually changes.

Using data.onover, data.onout and tooltip.grouped = false almost achieves what I want, the only problem is that the onout for a series is only called when highlighting a completely separate x-axis value, not when highlighting another series value at the same x-axis value. This means that trying to compare two series at the same point in time works "one way" (as each onover is called in turn), but then stops updating.
data-onover

I can get the desired behavior to work by using the tooltip.onshow and tooltip.onhide, but both of these callbacks are executed for every mouse movement even when there has been no significant change - there's no definitive "tooltip is no longer being shown" callback (afaict). To avoid expensive template re-rendering I'd need to debounce these calls and see if there was a net change over time.
tooltip-onshow

Is this the intended behavior? The setOverOut implementation (and cache usage), looks like it was intended to call data.onout for each datapoint as soon as the cursor moves outside the shape bounds - potentially multiple points could be "over" concurrently, but once moving outside the shape bounds the respective onout should run immediately, rather than "once all shapes are out".

Steps to check or reproduce

Here is a JSFiddle demonstrating these two cases: https://jsfiddle.net/6m9ay5Lh/4/

@netil
Copy link
Member

netil commented Oct 14, 2022

Hi @grantcox, thanks for the post. I'll re-check the scenario if there're points to improve on this.

@netil netil self-assigned this Oct 14, 2022
netil added a commit to netil/billboard.js that referenced this issue Oct 21, 2022
Fix onover/onout event call on same x axis bar shape.

Ref naver#2901
@netil netil closed this as completed in 345b016 Oct 21, 2022
netil added a commit to netil/billboard.js that referenced this issue Oct 21, 2022
Make the call only when there's no selected shape.

Ref naver#2901
netil added a commit that referenced this issue Oct 21, 2022
Make the call only when there's no selected shape.

Ref #2901
netil added a commit that referenced this issue Oct 21, 2022
Fix onover/onout event call on same x axis bar shape.

Fix #2901
netil added a commit that referenced this issue Oct 21, 2022
Make the call only when there's no selected shape.

Ref #2901
github-actions bot pushed a commit that referenced this issue Oct 21, 2022
## [3.6.1](3.6.0...3.6.1) (2022-10-21)

### Bug Fixes

* **interaction:** Fix incorrect data.onover/out event call ([1389d85](1389d85)), closes [#2901](#2901)
* **tooltip:** fix redundant onxxx callback calls ([85cdf36](85cdf36)), closes [#2901](#2901)
* **type:** add missing svg.classname type definition ([72e5c84](72e5c84)), closes [#2893](#2893)
@netil
Copy link
Member

netil commented Oct 21, 2022

@grantcox, released the 3.6.2 with the fix.

And one reminder, when tooltip.grouped=false is set, data.onxxx event fires with the "sensitivity".
The default is bar.sensitivity=2, which means the approximation distance of the shape to fire the event.

If don't want redundant event firing at the point of crossing the boundary of shapes, set the sensitivity value to 0 as follows.

bar: {
    sensitivity: 0
},

netil pushed a commit that referenced this issue Oct 21, 2022
## [3.6.1](3.6.0...3.6.1) (2022-10-21)

### Bug Fixes

* **interaction:** Fix incorrect data.onover/out event call ([1389d85](1389d85)), closes [#2901](#2901)
* **tooltip:** fix redundant onxxx callback calls ([85cdf36](85cdf36)), closes [#2901](#2901)
* **type:** add missing svg.classname type definition ([72e5c84](72e5c84)), closes [#2893](#2893)
@grantcox
Copy link
Author

grantcox commented Nov 2, 2022

Thank you @netil , both for the changes to data.onover/out and for the suggestion about the bar sensitivity. I was out of the office last week and I won't have a chance to test / integrate these changes in the coming week, but I really appreciate your efforts and responsiveness. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants