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 logic for hiding zero lines when they conflict with axis lines #2936

Merged
merged 4 commits into from
Aug 22, 2018

Conversation

alexcjohnson
Copy link
Collaborator

Fixes #2874

The logic was quite a bit more complicated than just switching ax -> counterAxis... but seems to work in all cases now.

cc @etpinard

Copy link
Contributor

@etpinard etpinard left a comment

Choose a reason for hiding this comment

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

The logic was quite a bit more complicated than just switching ax -> counterAxis..

I had the same feeling when looking at #2874 - it's nice to finally look the behavior down in those tests you wrote.

})
.then(function() {
// x axis still has a zero line on xy2, and y on x2y
// all the others have disappeared now
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 📚

extraSubplot = (!ya._anchorAxis || subplot !== xa._mainSubplot);
if(extraSubplot && ya.ticks && ya.mirror === 'allticks') {
extraSubplot = (!ya._anchorAxis || subplot !== ya._mainSubplot);
if(extraSubplot && (ya.mirror === 'allticks' || ya.mirror === 'all')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice find! Is there a test 🔒 ing this down?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ha, there was a test (the subplot case) locking down the changes but not the parts that remained -> added these in 545ad47

}
}

function anyCounterAxLineAtZero(counterAxis, rng) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice function name.

0 : ax._length
);

var counterLetterAxes = axes.list(gd, counterLetter);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would nice to avoid looping over all axes here.

Can we skip this loop when fullLayout._plots[counterAxis._mainSubplot].overlays is empty, and only check lineNearZero(counterAxis, zeroPosition)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call - it was almost that simple. one more relevant test in bcd7c06 and 🐎 in 0f59ca2

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to hear it was that easy. 💯

var rng = Lib.simpleMap(ax.range, ax.r2l),
showZl = (rng[0] * rng[1] <= 0) && ax.zeroline &&
var rng = Lib.simpleMap(ax.range, ax.r2l);
var zlData = {x: 0, id: axid};
Copy link
Contributor

Choose a reason for hiding this comment

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

No need this do in this PR (opening a new issue would be fine), but we'll need to propagate these changes to large-sploms' regl-based grid line logic:

// just like in Axes.doTicks but without the loop over traces
function showZeroLine(ax) {
var rng = Lib.simpleMap(ax.range, ax.r2l);
var p0 = ax.l2p(0);
return (
ax.zeroline &&
ax._vals && ax._vals.length &&
(rng[0] * rng[1] <= 0) &&
(ax.type === 'linear' || ax.type === '-') &&
((p0 > 1 && p0 < ax._length - 1) || !ax.showline)
);
}

where I didn't just reuse the axes.js logic because I wanted to avoid looping over the traces (to compute that hasBarsOrFill boolean). Thinking about this again, looping over traces isn't really a performance hit for sploms (I can't really imagine a user wanting to plot more 10 splom traces on the same graph).

So it would be worth trying to expose and ♻️ this logic here for large-sploms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, thanks for pointing that out! #2938

@etpinard
Copy link
Contributor

etpinard commented Aug 22, 2018

Great! 💃

Thanks for including that perf fix and opening an issue for the splom case. 🎸

@alexcjohnson alexcjohnson merged commit a8dd8dd into master Aug 22, 2018
@alexcjohnson alexcjohnson deleted the zeroline-fix branch August 22, 2018 16:22
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