Skip to content

Commit

Permalink
replace Registry.call('', []) with Registry.call('', ...[])
Browse files Browse the repository at this point in the history
... everywhere except for plots/command.js where
    and fn.apply would work better, for now just
    grab api method for registry cache.
  • Loading branch information
etpinard committed Mar 2, 2018
1 parent e05f4f0 commit 705aed6
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/components/annotations/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function onClick(gd, hoverData) {
update['annotations[' + offSet[i] + '].visible'] = false;
}

return Registry.call('update', [gd, {}, update]);
return Registry.call('update', gd, {}, update);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
});
},
doneFn: function() {
Registry.call('relayout', [gd, update]);
Registry.call('relayout', gd, update);
var notesBox = document.querySelector('.js-notes-box-panel');
if(notesBox) notesBox.redraw(notesBox.selectedObj);
}
Expand Down Expand Up @@ -673,7 +673,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
},
doneFn: function() {
setCursor(annTextGroupInner);
Registry.call('relayout', [gd, update]);
Registry.call('relayout', gd, update);
var notesBox = document.querySelector('.js-notes-box-panel');
if(notesBox) notesBox.redraw(notesBox.selectedObj);
}
Expand All @@ -698,7 +698,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
update[ya._name + '.autorange'] = true;
}

Registry.call('relayout', [gd, update]);
Registry.call('relayout', gd, update);
});
}
else annText.call(textLayout);
Expand Down
4 changes: 2 additions & 2 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ module.exports = function draw(gd, id) {
setCursor(container);

if(xf !== undefined && yf !== undefined) {
Registry.call('restyle', [
Registry.call('restyle',
gd,
{'colorbar.x': xf, 'colorbar.y': yf},
getTrace().index
]);
);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/dragelement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ dragElement.coverSlip = coverSlip;

function finishDrag(gd) {
gd._dragging = false;
if(gd._replotPending) Registry.call('plot', [gd]);
if(gd._replotPending) Registry.call('plot', gd);
}

function pointerOffset(e) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ module.exports = function draw(gd) {
},
doneFn: function() {
if(xf !== undefined && yf !== undefined) {
Registry.call('relayout', [gd, {'legend.x': xf, 'legend.y': yf}]);
Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf});
}
},
clickFn: function(numClicks, e) {
Expand Down Expand Up @@ -430,7 +430,7 @@ function drawTexts(g, gd) {
update.name = text;
}

return Registry.call('restyle', [gd, update, traceIndex]);
return Registry.call('restyle', gd, update, traceIndex);
});
} else {
text.call(textLayout);
Expand Down
4 changes: 2 additions & 2 deletions src/components/legend/handle_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = function handleClick(g, gd, numClicks) {
}
}

Registry.call('relayout', [gd, 'hiddenlabels', hiddenSlices]);
Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices);
} else {
var hasLegendgroup = legendgroup && legendgroup.length;
var traceIndicesInGroup = [];
Expand Down Expand Up @@ -217,6 +217,6 @@ module.exports = function handleClick(g, gd, numClicks) {
}
}

Registry.call('restyle', [gd, attrUpdate, attrIndices]);
Registry.call('restyle', gd, attrUpdate, attrIndices);
}
};
16 changes: 8 additions & 8 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function handleCartesian(gd, ev) {
aobj[astr] = val;
}

Registry.call('relayout', [gd, aobj]);
Registry.call('relayout', gd, aobj);
}

modeBarButtons.zoom3d = {
Expand Down Expand Up @@ -305,7 +305,7 @@ function handleDrag3d(gd, ev) {
var val2d = (val === 'pan') ? val : 'zoom';
layoutUpdate.dragmode = val2d;

Registry.call('relayout', [gd, layoutUpdate]);
Registry.call('relayout', gd, layoutUpdate);
}

modeBarButtons.resetCameraDefault3d = {
Expand Down Expand Up @@ -344,7 +344,7 @@ function handleCamera3d(gd, ev) {
}
}

Registry.call('relayout', [gd, aobj]);
Registry.call('relayout', gd, aobj);
}

modeBarButtons.hoverClosest3d = {
Expand Down Expand Up @@ -405,7 +405,7 @@ function handleHover3d(gd, ev) {
button._previousVal = Lib.extendDeep({}, currentSpikes);
}

Registry.call('relayout', [gd, layoutUpdate]);
Registry.call('relayout', gd, layoutUpdate);
}

modeBarButtons.zoomInGeo = {
Expand Down Expand Up @@ -461,7 +461,7 @@ function handleGeo(gd, ev) {
var scale = geoLayout.projection.scale;
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale;

Registry.call('relayout', [gd, id + '.projection.scale', newScale]);
Registry.call('relayout', gd, id + '.projection.scale', newScale);
} else if(attr === 'reset') {
resetView(gd, 'geo');
}
Expand Down Expand Up @@ -500,7 +500,7 @@ function toggleHover(gd) {

var newHover = gd._fullLayout.hovermode ? false : onHoverVal;

Registry.call('relayout', [gd, 'hovermode', newHover]);
Registry.call('relayout', gd, 'hovermode', newHover);
}

// buttons when more then one plot types are present
Expand Down Expand Up @@ -555,7 +555,7 @@ modeBarButtons.toggleSpikelines = {

var aobj = setSpikelineVisibility(gd);

Registry.call('relayout', [gd, aobj]);
Registry.call('relayout', gd, aobj);
}
};

Expand Down Expand Up @@ -602,5 +602,5 @@ function resetView(gd, subplotType) {
}
}

Registry.call('relayout', [gd, aObj]);
Registry.call('relayout', gd, aObj);
}
2 changes: 1 addition & 1 deletion src/components/rangeselector/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = function draw(gd) {
button.on('click', function() {
if(gd._dragged) return;

Registry.call('relayout', [gd, update]);
Registry.call('relayout', gd, update);
});

button.on('mouseover', function() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/rangeslider/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
dataMax = clamp(opts.p2d(opts._pixelMax));

window.requestAnimationFrame(function() {
Registry.call('relayout', [gd, axisOpts._name + '.range', [dataMin, dataMax]]);
Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/shapes/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index) {

function endDrag() {
setCursor(shapePath);
Registry.call('relayout', [gd, update]);
Registry.call('relayout', gd, update);
}

function moveShape(dx, dy) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/titles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ Titles.draw = function(gd, titleClass, options) {
el.call(svgTextUtils.makeEditable, {gd: gd})
.on('edit', function(text) {
if(traceIndex !== undefined) {
Registry.call('restyle', [gd, prop, text, traceIndex]);
Registry.call('restyle', gd, prop, text, traceIndex);
} else {
Registry.call('relayout', [gd, prop, text]);
Registry.call('relayout', gd, prop, text);
}
})
.on('cancel', function() {
Expand Down
2 changes: 1 addition & 1 deletion src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ exports.doColorBars = function(gd) {
exports.layoutReplot = function(gd) {
var layout = gd.layout;
gd.layout = undefined;
return Registry.call('plot', [gd, '', layout]);
return Registry.call('plot', gd, '', layout);
};

exports.doLegend = function(gd) {
Expand Down
6 changes: 3 additions & 3 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
.on('edit', function(text) {
var v = ax.d2r(text);
if(v !== undefined) {
Registry.call('relayout', [gd, attrStr, v]);
Registry.call('relayout', gd, attrStr, v);
}
});
}
Expand Down Expand Up @@ -654,7 +654,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
}

gd.emit('plotly_doubleclick', null);
Registry.call('relayout', [gd, attrs]);
Registry.call('relayout', gd, attrs);
}

// dragTail - finish a drag event with a redraw
Expand All @@ -668,7 +668,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
// accumulated MathJax promises - wait for them before we relayout.
Lib.syncOrAsync([
Plots.previousPromises,
function() { Registry.call('relayout', [gd, updates]); }
function() { Registry.call('relayout', gd, updates); }
], gd);
}

Expand Down
4 changes: 2 additions & 2 deletions src/plots/cartesian/transition_axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
// Signal that this transition has completed:
onComplete && onComplete();

return Registry.call('relayout', [gd, aobj]).then(function() {
return Registry.call('relayout', gd, aobj).then(function() {
for(var i = 0; i < affectedSubplots.length; i++) {
unsetSubplotTransform(affectedSubplots[i]);
}
Expand All @@ -289,7 +289,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
axi.range = axi._r.slice();
}

return Registry.call('relayout', [gd, aobj]).then(function() {
return Registry.call('relayout', gd, aobj).then(function() {
for(var i = 0; i < affectedSubplots.length; i++) {
unsetSubplotTransform(affectedSubplots[i]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/plots/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,15 @@ function bindingValueHasChanged(gd, binding, cache) {
exports.executeAPICommand = function(gd, method, args) {
if(method === 'skip') return Promise.resolve();

var _method = Registry.apiMethodRegistry[method];
var allArgs = [gd];
if(!Array.isArray(args)) args = [];

for(var i = 0; i < args.length; i++) {
allArgs.push(args[i]);
}

return Registry.call(method, allArgs).catch(function(err) {
return _method.apply(null, allArgs).catch(function(err) {
Lib.warn('API call to Plotly.' + method + ' rejected.', err);
return Promise.reject(err);
});
Expand Down
4 changes: 2 additions & 2 deletions src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ proto.updateProjection = function(fullLayout, geoLayout) {
this.viewInitial = null;

Lib.warn(msg);
gd._promises.push(Registry.call('relayout', [gd, updateObj]));
gd._promises.push(Registry.call('relayout', gd, updateObj));
return msg;
}

Expand Down Expand Up @@ -365,7 +365,7 @@ proto.updateFx = function(fullLayout, geoLayout) {
updateObj[_this.id + '.' + k] = viewInitial[k];
}

Registry.call('relayout', [gd, updateObj]);
Registry.call('relayout', gd, updateObj);
gd.emit('plotly_doubleclick', null);
}

Expand Down
8 changes: 4 additions & 4 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ plots.resize = function(gd) {
// nor should it be included in the undo queue
gd.autoplay = true;

Registry.call('relayout', [gd, { autosize: true }]).then(function() {
Registry.call('relayout', gd, {autosize: true}).then(function() {
gd.changed = oldchanged;
resolve(gd);
});
Expand Down Expand Up @@ -1670,7 +1670,7 @@ plots.doAutoMargin = function(gd) {
// if things changed and we're not already redrawing, trigger a redraw
if(!fullLayout._replotting && oldmargins !== '{}' &&
oldmargins !== JSON.stringify(fullLayout._size)) {
return Registry.call('plot', [gd]);
return Registry.call('plot', gd);
}
};

Expand Down Expand Up @@ -2162,7 +2162,7 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)

if(frameOpts.redraw) {
gd._transitionData._interruptCallbacks.push(function() {
return Registry.call('redraw', [gd]);
return Registry.call('redraw', gd);
});
}

Expand Down Expand Up @@ -2234,7 +2234,7 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)

return Promise.resolve().then(function() {
if(frameOpts.redraw) {
return Registry.call('redraw', [gd]);
return Registry.call('redraw', gd);
}
}).then(function() {
// Set transitioning false again once the redraw has occurred. This is used, for example,
Expand Down
10 changes: 5 additions & 5 deletions src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ proto.updateMainDrag = function(fullLayout, polarLayout) {
radialRange[0] + r1 * drange / radius
];

Registry.call('relayout', [gd, updateObj]);
Registry.call('relayout', gd, updateObj);
}

dragOpts.prepFn = function(evt, startX, startY) {
Expand Down Expand Up @@ -718,7 +718,7 @@ proto.updateMainDrag = function(fullLayout, polarLayout) {
}

gd.emit('plotly_doubleclick', null);
Registry.call('relayout', [gd, updateObj]);
Registry.call('relayout', gd, updateObj);
}

Fx.click(gd, evt, _this.id);
Expand Down Expand Up @@ -788,9 +788,9 @@ proto.updateRadialDrag = function(fullLayout, polarLayout) {

function doneFn() {
if(angle1 !== null) {
Registry.call('relayout', [gd, _this.id + '.radialaxis.angle', angle1]);
Registry.call('relayout', gd, _this.id + '.radialaxis.angle', angle1);
} else if(rng1 !== null) {
Registry.call('relayout', [gd, _this.id + '.radialaxis.range[1]', rng1]);
Registry.call('relayout', gd, _this.id + '.radialaxis.range[1]', rng1);
}
}

Expand Down Expand Up @@ -970,7 +970,7 @@ proto.updateAngularDrag = function(fullLayout, polarLayout) {
scatterTextPoints.select('text').attr('transform', null);
var updateObj = {};
updateObj[_this.id + '.angularaxis.rotation'] = rot1;
Registry.call('relayout', [gd, updateObj]);
Registry.call('relayout', gd, updateObj);
}

dragOpts.prepFn = function(evt, startX, startY) {
Expand Down
6 changes: 3 additions & 3 deletions src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ proto.initInteractions = function() {
attrs[_this.id + '.baxis.min'] = 0;
attrs[_this.id + '.caxis.min'] = 0;
gd.emit('plotly_doubleclick', null);
Registry.call('relayout', [gd, attrs]);
Registry.call('relayout', gd, attrs);
}
Fx.click(gd, evt, _this.id);
}
Expand Down Expand Up @@ -600,7 +600,7 @@ proto.initInteractions = function() {
attrs[_this.id + '.baxis.min'] = mins.b;
attrs[_this.id + '.caxis.min'] = mins.c;

Registry.call('relayout', [gd, attrs]);
Registry.call('relayout', gd, attrs);

if(SHOWZOOMOUTTIP && gd.data && gd._context.showTips) {
Lib.notifier(_(gd, 'Double-click to zoom back out'), 'long');
Expand Down Expand Up @@ -679,7 +679,7 @@ proto.initInteractions = function() {
attrs[_this.id + '.baxis.min'] = mins.b;
attrs[_this.id + '.caxis.min'] = mins.c;

Registry.call('relayout', [gd, attrs]);
Registry.call('relayout', gd, attrs);
}

function clearSelect() {
Expand Down
Loading

0 comments on commit 705aed6

Please sign in to comment.