-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Heatmap ordering bug #2917
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d553142
fix dynamic heatmap ordering
alexcjohnson 8faefde
fix dynamic ordering of carpets, and :hocho: getUidsFromCalcData
alexcjohnson 4e01efe
DRY trace group management for (nearly) all cartesian traces
alexcjohnson b0693da
updated baseline images
alexcjohnson 07aee8f
:hocho: obsolete setClipUrl on contour heatmap fill
alexcjohnson 69dee75
refactor make_trace_groups to more general lib function
alexcjohnson e892923
fix ordering for choropleths
alexcjohnson 9ddad4c
use makeTraceGroups in pie
alexcjohnson 521d27f
fix ordering for scattergeo
alexcjohnson d295d36
oops - put scattergeo in the right container
alexcjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright 2012-2018, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
|
||
'use strict'; | ||
|
||
var d3 = require('d3'); | ||
|
||
/** | ||
* helper for cartesian trace types to manage trace groups and plot traces | ||
* into them | ||
* | ||
* @param {div} gd: plot div | ||
* @param {object} plotinfo: the cartesian subplot info object | ||
* @param {array} cdModule: array of calcdata items for this | ||
* module and subplot combination | ||
* @param {d3.selection} traceLayer: a selection containing a single group | ||
* to draw these traces into | ||
* @param {string} cls: the class attribute to give each trace group | ||
* so you can give multiple classes separated by spaces | ||
* @param {function} plotOneFn: a function that will plot one trace | ||
* takes arguments: | ||
* gd | ||
* plotinfo | ||
* cd: calcdata array for this one trace | ||
* plotGroup: d3 selection of the single group to draw into | ||
*/ | ||
module.exports = function makeTraceGroups(gd, plotinfo, cdModule, traceLayer, cls, plotOneFn) { | ||
var traces = traceLayer.selectAll('g.' + cls.replace(/\s/g, '.')) | ||
.data(cdModule, function(cd) { return cd[0].trace.uid; }); | ||
|
||
traces.exit().remove(); | ||
|
||
traces.enter().append('g') | ||
.attr('class', cls); | ||
|
||
traces.each(function(cd) { | ||
plotOneFn(gd, plotinfo, cd, d3.select(this)); | ||
}) | ||
.order(); | ||
|
||
return traces; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,20 +124,3 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { | |
|
||
return subplotData; | ||
}; | ||
|
||
/** | ||
* Get a lookup object of trace uids corresponding in a given calcdata array. | ||
* | ||
* @param {array} calcdata: as in gd.calcdata (or a subset) | ||
* @return {object} lookup object of uids (`uid: 1`) | ||
*/ | ||
exports.getUidsFromCalcData = function(calcdata) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
var out = {}; | ||
|
||
for(var i = 0; i < calcdata.length; i++) { | ||
var trace = calcdata[i][0].trace; | ||
out[trace.uid] = 1; | ||
} | ||
|
||
return out; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 tosrc/lib/
? No sure where it would belong. There'slib/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 calledtraces.order()
, returntraces
and make_module.plot
handle thetrace.each
"plot-one" logic. This way we wouldn't be tied down to oneplotOneFn
call signature and we wouldn't have to passgd
,plotinfo
tomakeTraceGroups
, perhaps making things more reusable. But that's really more of a personal opinion, so consider this comment non-blocking 👌There was a problem hiding this comment.
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, takingplotOne
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.