8000 Fixup hover on period positioned points by archmoj · Pull Request #5618 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fixup hover on period positioned points #5618

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

Merged
merged 14 commits into from
May 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
optimize customVal function
  • Loading branch information
archmoj committed May 1, 2021
commit e15da902d043400c476f0f3fd22aafa876728eb3
23 changes: 14 additions & 9 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,10 @@ function _hover(gd, evt, subplot, noHoverEvent) {
hoverData[0].trace.type !== 'splom' // TODO: add support for splom
) {
var winningPoint = hoverData[0];
var isGrouped = (fullLayout.boxmode === 'group' || fullLayout.violinmode === 'group');

findHoverPoints(
customVal('x', winningPoint, isGrouped),
customVal('y', winningPoint, isGrouped)
customVal('x', winningPoint, fullLayout),
customVal('y', winningPoint, fullLayout)
);

// Remove duplicated hoverData points
Expand Down Expand Up @@ -1898,15 +1897,21 @@ function orderPeriod(hoverData, hovermode) {
hoverData = first.concat(last);
}

function customVal(axLetter, winningPoint, isGrouped) {
var cd0 = winningPoint.cd[winningPoint.index];
function customVal(axLetter, winningPoint, fullLayout) {
var ax = winningPoint[axLetter + 'a'];
var val = winningPoint[axLetter + 'Val'];

if(ax.type === 'category') val = ax._categoriesMap[val];
if(ax.type === 'date') val = ax.d2c(val);
if(cd0 && cd0.t && cd0.t.posLetter === ax._id && isGrouped) {
val += cd0.t.dPos;
if(ax.type === 'category') return ax._categoriesMap[val];
if(ax.type === 'date') return ax.d2c(val);

var cd0 = winningPoint.cd[winningPoint.index];
if(cd0 && cd0.t && cd0.t.posLetter === ax._id) {
if(
fullLayout.boxmode === 'group' ||
fullLayout.violinmode === 'group'
) {
val += cd0.t.dPos;
}
}

return val;
Expand Down
0