-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Combine geo and ternary genaral update pattern #1291
Conversation
- made useless by #946
- so that the same logic can be share for geo and ternary subplots (and maybe cartesian subplots down the road) - fix bug occurring when the first trace on a given subplot had `visible: false` (which yielded an exception)
- fix bug occurring when the first trace on a given ternary subplot had `visible: false` (which yielded an exception)
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.
💃
} | ||
|
||
this.traceHash = traceHash; | ||
Plots.generalUpdatePerTraceModule(this, geoCalcData, geoLayout); |
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.
Lots of trace-specific code moved elsewhere. I like it already. 👏
* @return {array} array of calcdata traces | ||
*/ | ||
plots.getSubplotCalcData = function(calcData, type, subplotId) { | ||
if(plots.subplotsRegistry[type] === undefined) return []; |
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.
if(!plots.subplotsRegistry[type])
but that's really nitpicky.
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.
Good call. Done in 83c2722
|
||
// when a trace gets deleted, make sure that its module's | ||
// plot method is called so that it is properly | ||
// removed from the DOM. |
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.
👏 Yes.
@@ -2027,3 +2052,67 @@ plots.doCalcdata = function(gd, traces) { | |||
calcdata[i] = cd; | |||
} | |||
}; | |||
|
|||
plots.generalUpdatePerTraceModule = function(subplot, subplotCalcData, subplotLayout) { | |||
var traceHashOld = subplot.traceHash, |
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 always feel like the mutate-existing-data approach contributes a bit to fragility, but I understand why these things are as they are.
expect(out3.traceHash.A.length).toEqual(1); | ||
expect(out3.traceHash.A[0][0].trace.visible).toBe(false); | ||
expect(out3.traceHash.C.length).toEqual(1); | ||
expect(out3.traceHash.C[0][0].trace.visible).toBe(false); |
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.
The tests are great. 👍
by simple `!` checks
Cartesian, geo and ternary subplots (i.e. all SVG/d3 subplots) draw traces using the trace modules'
plot
method which expects as input thecalcdata
traces corresponding to all traces of a given trace type on a given subplot.Previously, geo and ternary subplot used similar but not-exactly-equivalent logic to handle add/remove/modify updates. This PR - mainly by making ternary subplot use
gd.calcdata
instead ofgd._fullData
traces - unifies the geo and ternary logic intoPlots.generalUpdatePerTraceModule
(I hope you like the name). Cartesian subplots on the other hand are (still) in a world of their own - unifying all SVG/d3 subplots will have to wait.By doing so, this PR also fixes a bug where:
would lead to exception and fail to render. See commit in particular this line for more details.