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

fix for spikedistance=-1 #4637

Merged
merged 3 commits into from
Mar 13, 2020
Merged

fix for spikedistance=-1 #4637

merged 3 commits into from
Mar 13, 2020

Conversation

antoinerg
Copy link
Contributor

@antoinerg antoinerg commented Mar 13, 2020

@archmoj
Copy link
Contributor

archmoj commented Mar 13, 2020

@antoinerg thanks for the follow ups!
Would you mind updating before codepen to use v1.52.3 instead of latest?
That way one could easily compare the two after a new release.

@@ -161,7 +160,7 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal']);

// spikelines always want "closest" distance regardless of hovermode
pointData.spikeDistance = (sizeFn(di) + thisBarPositionFn(di)) / 2 + maxSpikeDistance - maxHoverDistance;
pointData.spikeDistance = (sizeFn(di) + thisBarPositionFn(di)) / 2 - maxHoverDistance;
Copy link
Contributor Author

@antoinerg antoinerg Mar 13, 2020

Choose a reason for hiding this comment

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

maxHoverDistance is necessary here because it is added in the function sizeFn. Now, why would a function computing the size of a bar would contain maxHoverDistance is beyond my comprehension.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, super confusing. It's not computing the size of a bar, it's computing a distance measure along the size axis. Is it necessary to remove maxSpikeDistance here? Or it just doesn't have an understood purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it necessary to remove maxSpikeDistance here?

Keeping maxSpikeDistance in leads to:
Screenshot_2020-03-13_15-47-32

Or it just doesn't have an understood purpose?

I'll be honest: I also don't understand its purpose. What is spikedistance supposed to represent? Why would we add maxSpikeDistance and substract maxHoverDistance to it at the trace-level? It seems to me that this logic should live in fx/hover.js no?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah this logic should certainly be cleaned up at some point... super hacky. Perhaps as part of #4638 🙏

mockCopy.layout.yaxis.showspikes = true;
mockCopy.layout.spikedistance = -1;

Plotly.newPlot(gd, mockCopy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:
We could us newPlot > plot here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is that desirable? plot is not part of the API we want anyone using, so I'd kind of rather not use it in tests either, even if it's a little faster.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the note. Resolving...
And please feel free to open an issue if you prefer to chage similar cases in all the tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't bother converting the rest unless there are problems. Sometimes there's a good reason to go for the faster one, in particular I seem to recall a lot of overhead to newPlot in WebGL tests? But that overhead comes with more assurance that there's no cross-test interaction, which has lead to hard-to-debug errors in the past. @etpinard any words of wisdom to add here?

@@ -593,4 +616,139 @@ describe('spikeline hover', function() {
.catch(failTest)
.then(done);
});

it('correctly draws lines up to the last point', function(done) {
Plotly.newPlot(gd, [
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:
We could us newPlot > plot here.

}
};

Plotly.newPlot(gd, mock)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:
We could us newPlot > plot here.

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.

💃 Very nice!

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.

spike lines do not appear when spikedistance
3 participants