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

Fixup bar spike distance #5542

Merged
merged 4 commits into from
Mar 16, 2021
Merged

Fixup bar spike distance #5542

merged 4 commits into from
Mar 16, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Mar 10, 2021

Fix for #4716.

@plotly/plotly_js

// add a little to the pseudo-distance for wider bars, so that like scatter,
// if you are over two overlapping bars, the narrower one wins.
return Fx.inbox(_minPos - posVal, _maxPos - posVal,
maxSpikeDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the only difference between spikePositionFn and hoverPositionFn is which max*Distance is used, just make that a 3rd arg to the _positionFn calls below.

Same with sizeFn vs thisBarSizeFn, looks like that could be a higher-order function like sizeFn(whichMaxDist)(di)

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a comment about making it more DRY 🌴

💃 after considering that.

@archmoj archmoj merged commit 623fcd1 into master Mar 16, 2021
@archmoj archmoj deleted the fixup-bar-spike-dist branch March 16, 2021 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants