Skip to content

Heatmap ordering bug #2917

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 10 commits into from
Aug 17, 2018
Merged

Heatmap ordering bug #2917

merged 10 commits into from
Aug 17, 2018

Conversation

alexcjohnson
Copy link
Collaborator

Fixes #2907 - dynamic ordering of heatmap and carpet traces

🔪 the now-obsolete getUidsFromCalcData

But then I realized this trace group management pattern is identical for all cartesian traces, so I made a single helper makeTraceGroups to handle this in all types, except scatter since animations give it somewhat different needs.

cc @etpinard

@alexcjohnson
Copy link
Collaborator Author

Huh, on my machine as well as on CI connectgaps_2d looks fine, but somehow GH can't display it? I don't know why there are image diffs here. connectgaps_2d I think I can at least see something that changed at the edges of the clip path, contour_heatmap_coloring I really can't even see anything.

since it's inside the contour group now it's unnecessary
and in fact since I removed the uid-based class it was unused
@@ -636,8 +636,6 @@ function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) {
else clipId = null;

plotGroup.call(Drawing.setClipUrl, clipId);
plotinfo.plot.selectAll('.hm' + cd0.trace.uid)
.call(Drawing.setClipUrl, clipId);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alright, GH is working again with these images, must've been an internal glitch last night.

The reason for the image diffs is that in master (right) we were applying the clip-path to both the heatmap group and the contour group... and now that the heatmap is inside the contour group that was redundant but apparently it was still having an effect on antialiasing. The Drawing.setClipUrl here that was supposed to be clipping the heatmap actually wasn't doing anything, since I removed the uid-based class from the heatmap.
screen shot 2018-08-17 at 9 59 51 am
So in fact the image diff in this PR probably nearly (or exactly) reverts the diff from contour-legend https://github.com/plotly/plotly.js/pull/2891/files?short_path=2b47456#diff-2b474566a55f847908961b61d6e0cba4

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.

Great PR. 💃

Thanks for taking a second look at those mock diffs, it got us a few more lines to 🔪 .

My one comment is non-blocking.

traces.enter().append('g')
.attr('class', cls);

traces.each(function(cd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah very nice! That cls.replace(/s/g/, '.') is a nice touch.

I think makeTraceGroups should work with all svg-based subplot types, so perhaps we could move this to src/lib/? No sure where it would belong. There's lib/gup.js which has "general-update-pattern" helpers, maybe that would be a good fit.

Personally, I would not have included plotOneFn as an argument and here just called traces.order(), return traces and make _module.plot handle the trace.each "plot-one" logic. This way we wouldn't be tied down to one plotOneFn call signature and we wouldn't have to pass gd, plotinfo to makeTraceGroups, perhaps making things more reusable. But that's really more of a personal opinion, so consider this comment non-blocking 👌

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to match the existing pattern (from contourPlot.plotWrapper) but yeah, taking plotOne out would be cleaner and even more generalizable, I'll do that. Originally I wasn't returning the final selection but now that we have that this will be easy.

* @param {array} calcdata: as in gd.calcdata (or a subset)
* @return {object} lookup object of uids (`uid: 1`)
*/
exports.getUidsFromCalcData = function(calcdata) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@@ -636,8 +636,6 @@ function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) {
else clipId = null;

plotGroup.call(Drawing.setClipUrl, clipId);
plotinfo.plot.selectAll('.hm' + cd0.trace.uid)
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!

@alexcjohnson
Copy link
Collaborator Author

Alright, more general pattern in 69dee75, and used it to 🌴 pie in 9ddad4c and fix choropleth e892923 and scattergeo 521d27f (⚠️ may make a merge conflict with #2918)

There are likely still similar hide/show ordering bugs in some other standalone svg trace types, eg table and sankey, I didn't feel like wading through these right now, and it seems unlikely BOTH that you'd be hiding/showing these AND that they would overlap each other, so doesn't seem like such a big issue with them.


if(!plotinfo.isRangePlot) cd0.node3 = plotGroup;
var bartraces = Lib.makeTraceGroups(barLayer, cdbar, 'trace bars').each(function(cd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ha yes. Lib.makeTraceGroups looks very similar to Lib.ensureSingle which have similar purpose. 👌

@etpinard
Copy link
Contributor

Alright, more general pattern in 69dee75, and used it to pie in 9ddad4c and fix choropleth e892923 and scattergeo 521d27f

Wow. That's great! Thanks for adding test to scattergeo and choropleth 🔒 this down for good. I'll take care of scatterpolar in the barpolar PR.

( may make a merge conflict with #2918)

I'll take care of it before my fix-intermittent-gl-test-failure commit.

Once again -> 💃

@alexcjohnson alexcjohnson merged commit f28caae into master Aug 17, 2018
@alexcjohnson alexcjohnson deleted the heatmap-ordering-bug branch August 17, 2018 19:13
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