Skip to content

Fixup bar spike distance - #5542

Merged
archmoj merged 4 commits into
masterfrom
fixup-bar-spike-dist
Mar 16, 2021
Merged

archmoj merged 4 commits into
masterfrom
fixup-bar-spike-dist

Conversation

@archmoj

@archmoj archmoj commented Mar 10, 2021 •

Copy link
Copy Markdown
Contributor

Fix for #4716.

@plotly/plotly_js

Comment thread src/traces/bar/hover.js Outdated
// 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
Copy Markdown
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)

@alexcjohnson alexcjohnson left a comment

Copy link
Copy Markdown
Collaborator

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