Skip to content

Commit 6e8a68c

Browse files
committed
coerceTraceIndices earlier so clearAxisTypes can use it
1 parent 388a7fe commit 6e8a68c

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/plot_api/plot_api.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ Plotly.moveTraces = function moveTraces(gd, currentIndices, newIndices) {
12611261
* If the array is too short, it will wrap around (useful for
12621262
* style files that want to specify cyclical default values).
12631263
*/
1264-
Plotly.restyle = function restyle(gd, astr, val, traces) {
1264+
Plotly.restyle = function restyle(gd, astr, val, _traces) {
12651265
gd = helpers.getGraphDiv(gd);
12661266
helpers.clearPromiseQueue(gd);
12671267

@@ -1270,15 +1270,17 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
12701270
else if(Lib.isPlainObject(astr)) {
12711271
// the 3-arg form
12721272
aobj = Lib.extendFlat({}, astr);
1273-
if(traces === undefined) traces = val;
1273+
if(_traces === undefined) _traces = val;
12741274
}
12751275
else {
1276-
Lib.warn('Restyle fail.', astr, val, traces);
1276+
Lib.warn('Restyle fail.', astr, val, _traces);
12771277
return Promise.reject();
12781278
}
12791279

12801280
if(Object.keys(aobj).length) gd.changed = true;
12811281

1282+
var traces = helpers.coerceTraceIndices(gd, _traces);
1283+
12821284
var specs = _restyle(gd, aobj, traces),
12831285
flags = specs.flags;
12841286

@@ -1323,14 +1325,12 @@ function undefinedToNull(val) {
13231325
return val;
13241326
}
13251327

1326-
function _restyle(gd, aobj, _traces) {
1328+
function _restyle(gd, aobj, traces) {
13271329
var fullLayout = gd._fullLayout,
13281330
fullData = gd._fullData,
13291331
data = gd.data,
13301332
i;
13311333

1332-
var traces = helpers.coerceTraceIndices(gd, _traces);
1333-
13341334
// initialize flags
13351335
var flags = editTypes.traceFlags();
13361336

@@ -2071,7 +2071,7 @@ function _relayout(gd, aobj) {
20712071
* integer or array of integers for the traces to alter (all if omitted)
20722072
*
20732073
*/
2074-
Plotly.update = function update(gd, traceUpdate, layoutUpdate, traces) {
2074+
Plotly.update = function update(gd, traceUpdate, layoutUpdate, _traces) {
20752075
gd = helpers.getGraphDiv(gd);
20762076
helpers.clearPromiseQueue(gd);
20772077

@@ -2085,6 +2085,8 @@ Plotly.update = function update(gd, traceUpdate, layoutUpdate, traces) {
20852085
if(Object.keys(traceUpdate).length) gd.changed = true;
20862086
if(Object.keys(layoutUpdate).length) gd.changed = true;
20872087

2088+
var traces = helpers.coerceTraceIndices(gd, _traces);
2089+
20882090
var restyleSpecs = _restyle(gd, Lib.extendFlat({}, traceUpdate), traces),
20892091
restyleFlags = restyleSpecs.flags;
20902092

@@ -2152,10 +2154,6 @@ Plotly.update = function update(gd, traceUpdate, layoutUpdate, traces) {
21522154
// so we auto-set them again
21532155
var axLetters = ['x', 'y', 'z'];
21542156
function clearAxisTypes(gd, traces, layoutUpdate) {
2155-
if(typeof traces === 'number') traces = [traces];
2156-
else if(!Array.isArray(traces) || !traces.length) {
2157-
traces = (gd._fullData).map(function(d, i) { return i; });
2158-
}
21592157
for(var i = 0; i < traces.length; i++) {
21602158
var trace = gd._fullData[i];
21612159
for(var j = 0; j < 3; j++) {

0 commit comments

Comments
 (0)