-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
restyle/relayout refactor #1999
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
Changes from 1 commit
4d3e2ec
95d7d71
3326ecc
a948cce
dd52922
f90f079
e036fea
69e0188
bbfe399
29931ec
fad72a2
e895b32
7a7dc6d
c87b01a
658e5cb
f49ae5e
7ea0d25
284c87f
b9826c8
7c38a4a
96cc57f
cb94e95
238e248
42662ba
50aa1ca
62a1392
87b26d5
040ed1b
388a7fe
6e8a68c
4f8fc66
97ddf48
fe7db79
68f5dbc
d15e541
7ec1634
a107466
42805c2
8d9feaf
0a98a6d
e4227aa
0729921
407ae5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1282,8 +1282,9 @@ Plotly.restyle = function restyle(gd, astr, val, traces) { | |
var specs = _restyle(gd, aobj, traces), | ||
flags = specs.flags; | ||
|
||
// clear calcdata if required | ||
// clear calcdata and/or axis types if required so they get regenerated | ||
if(flags.clearCalc) gd.calcdata = undefined; | ||
if(flags.clearAxisTypes) clearAxisTypes(gd, traces, {}); | ||
|
||
// fill in redraw sequence | ||
var seq = []; | ||
|
@@ -1340,12 +1341,6 @@ function _restyle(gd, aobj, _traces) { | |
axlist, | ||
flagAxForDelete = {}; | ||
|
||
// these ones may alter the axis type | ||
// (at least if the first trace is involved) | ||
var axtypeAttrs = [ | ||
'type', 'x', 'y', 'x0', 'y0', 'orientation', 'xaxis', 'yaxis' | ||
]; | ||
|
||
// make a new empty vals array for undoit | ||
function a0() { return traces.map(function() { return undefined; }); } | ||
|
||
|
@@ -1557,11 +1552,6 @@ function _restyle(gd, aobj, _traces) { | |
} | ||
} | ||
|
||
// check if we need to call axis type | ||
if((traces.indexOf(0) !== -1) && (axtypeAttrs.indexOf(ai) !== -1)) { | ||
Plotly.Axes.clearTypes(gd, traces); | ||
} | ||
|
||
// major enough changes deserve autoscale, autobin, and | ||
// non-reversed axes so people don't get confused | ||
if(['orientation', 'type'].indexOf(ai) !== -1) { | ||
|
@@ -2101,8 +2091,9 @@ Plotly.update = function update(gd, traceUpdate, layoutUpdate, traces) { | |
var relayoutSpecs = _relayout(gd, Lib.extendFlat({}, layoutUpdate)), | ||
relayoutFlags = relayoutSpecs.flags; | ||
|
||
// clear calcdata if required | ||
// clear calcdata and/or axis types if required | ||
if(restyleFlags.clearCalc || relayoutFlags.calc) gd.calcdata = undefined; | ||
if(restyleFlags.clearAxisTypes) clearAxisTypes(gd, traces, layoutUpdate); | ||
|
||
// fill in redraw sequence | ||
var seq = []; | ||
|
@@ -2157,6 +2148,37 @@ Plotly.update = function update(gd, traceUpdate, layoutUpdate, traces) { | |
}); | ||
}; | ||
|
||
// empty out types for all axes containing these traces | ||
// so we auto-set them again | ||
var axLetters = ['x', 'y', 'z']; | ||
function clearAxisTypes(gd, traces, layoutUpdate) { | ||
if(typeof traces === 'number') traces = [traces]; | ||
else if(!Array.isArray(traces) || !traces.length) { | ||
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. Do we really need this?
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. I suppose I can move the |
||
traces = (gd._fullData).map(function(d, i) { return i; }); | ||
} | ||
for(var i = 0; i < traces.length; i++) { | ||
var trace = gd._fullData[i]; | ||
for(var j = 0; j < 3; j++) { | ||
var ax = Plotly.Axes.getFromTrace(gd, trace, axLetters[j]); | ||
|
||
// do not clear log type - that's never an auto result so must have been intentional | ||
if(ax && ax.type !== 'log') { | ||
var axAttr = ax._name; | ||
var sceneName = ax._id.substr(1); | ||
if(sceneName.substr(0, 5) === 'scene') { | ||
if(layoutUpdate[sceneName] !== undefined) continue; | ||
axAttr = sceneName + '.' + axAttr; | ||
} | ||
var typeAttr = axAttr + '.type'; | ||
|
||
if(layoutUpdate[axAttr] === undefined && layoutUpdate[typeAttr] === undefined) { | ||
Lib.nestedProperty(gd.layout, typeAttr).set(null); | ||
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. Much better than |
||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Animate to a frame, sequence of frame, frame group, or frame definition | ||
* | ||
|
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.
See ya ⚾