diff --git a/src/components/annotations/click.js b/src/components/annotations/click.js index dd498458c85..b2f300fb9be 100644 --- a/src/components/annotations/click.js +++ b/src/components/annotations/click.js @@ -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); } /* diff --git a/src/components/annotations/draw.js b/src/components/annotations/draw.js index 16901767b30..d5b2ce2e287 100644 --- a/src/components/annotations/draw.js +++ b/src/components/annotations/draw.js @@ -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); } @@ -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); } @@ -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); diff --git a/src/components/colorbar/draw.js b/src/components/colorbar/draw.js index 32f00b2246f..9ad1ac4017b 100644 --- a/src/components/colorbar/draw.js +++ b/src/components/colorbar/draw.js @@ -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 - ]); + ); } } }); diff --git a/src/components/dragelement/index.js b/src/components/dragelement/index.js index fa57a5263e7..0c008b6e76b 100644 --- a/src/components/dragelement/index.js +++ b/src/components/dragelement/index.js @@ -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) { diff --git a/src/components/legend/draw.js b/src/components/legend/draw.js index b1d9cddf469..609573a851b 100644 --- a/src/components/legend/draw.js +++ b/src/components/legend/draw.js @@ -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) { @@ -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); diff --git a/src/components/legend/handle_click.js b/src/components/legend/handle_click.js index d4b30495eab..b12bf50e8e3 100644 --- a/src/components/legend/handle_click.js +++ b/src/components/legend/handle_click.js @@ -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 = []; @@ -217,6 +217,6 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', [gd, attrUpdate, attrIndices]); + Registry.call('restyle', gd, attrUpdate, attrIndices); } }; diff --git a/src/components/modebar/buttons.js b/src/components/modebar/buttons.js index 096ed72fd8a..d2f8c4d1c30 100644 --- a/src/components/modebar/buttons.js +++ b/src/components/modebar/buttons.js @@ -249,7 +249,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', [gd, aobj]); + Registry.call('relayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -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 = { @@ -344,7 +344,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', [gd, aobj]); + Registry.call('relayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -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 = { @@ -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'); } @@ -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 @@ -555,7 +555,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', [gd, aobj]); + Registry.call('relayout', gd, aobj); } }; @@ -602,5 +602,5 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', [gd, aObj]); + Registry.call('relayout', gd, aObj); } diff --git a/src/components/rangeselector/draw.js b/src/components/rangeselector/draw.js index e156b482923..f729267eed8 100644 --- a/src/components/rangeselector/draw.js +++ b/src/components/rangeselector/draw.js @@ -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() { diff --git a/src/components/rangeslider/draw.js b/src/components/rangeslider/draw.js index dc36005f74c..61d6e9f50fe 100644 --- a/src/components/rangeslider/draw.js +++ b/src/components/rangeslider/draw.js @@ -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]); }); } diff --git a/src/components/shapes/draw.js b/src/components/shapes/draw.js index f710839047e..271e37c4861 100644 --- a/src/components/shapes/draw.js +++ b/src/components/shapes/draw.js @@ -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) { diff --git a/src/components/titles/index.js b/src/components/titles/index.js index 89577f8d4b1..8b66cbacaf3 100644 --- a/src/components/titles/index.js +++ b/src/components/titles/index.js @@ -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() { diff --git a/src/plot_api/subroutines.js b/src/plot_api/subroutines.js index 765f03f86c2..c92faea1f8f 100644 --- a/src/plot_api/subroutines.js +++ b/src/plot_api/subroutines.js @@ -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) { diff --git a/src/plots/cartesian/dragbox.js b/src/plots/cartesian/dragbox.js index 867df3c30f7..6b36f98c82d 100644 --- a/src/plots/cartesian/dragbox.js +++ b/src/plots/cartesian/dragbox.js @@ -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); } }); } @@ -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 @@ -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); } diff --git a/src/plots/cartesian/transition_axes.js b/src/plots/cartesian/transition_axes.js index d3cb5a0bc03..281b9964b9b 100644 --- a/src/plots/cartesian/transition_axes.js +++ b/src/plots/cartesian/transition_axes.js @@ -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]); } @@ -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]); } diff --git a/src/plots/command.js b/src/plots/command.js index b0c8444a349..1a185cad43c 100644 --- a/src/plots/command.js +++ b/src/plots/command.js @@ -263,6 +263,7 @@ 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 = []; @@ -270,7 +271,7 @@ exports.executeAPICommand = function(gd, method, args) { 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); }); diff --git a/src/plots/geo/geo.js b/src/plots/geo/geo.js index d7ebe6b32d5..f5ca806f1bb 100644 --- a/src/plots/geo/geo.js +++ b/src/plots/geo/geo.js @@ -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; } @@ -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); } diff --git a/src/plots/plots.js b/src/plots/plots.js index bbc5c8afed3..bc91864c548 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -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); }); @@ -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); } }; @@ -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); }); } @@ -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, diff --git a/src/plots/polar/polar.js b/src/plots/polar/polar.js index 713828abcdc..5f364aad176 100644 --- a/src/plots/polar/polar.js +++ b/src/plots/polar/polar.js @@ -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) { @@ -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); @@ -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); } } @@ -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) { diff --git a/src/plots/ternary/ternary.js b/src/plots/ternary/ternary.js index db0dd4e1265..590e7c55316 100644 --- a/src/plots/ternary/ternary.js +++ b/src/plots/ternary/ternary.js @@ -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); } @@ -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'); @@ -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() { diff --git a/src/registry.js b/src/registry.js index adc9bbf078d..953e58b285e 100644 --- a/src/registry.js +++ b/src/registry.js @@ -212,10 +212,12 @@ exports.getComponentMethod = function(name, method) { * Call registered api method. * * @param {string} name : api method name - * @param {array} args : array of argument passed to api method + * @param {...array} args : arguments passed to api method * @return {any} : returns api method output */ -exports.call = function(name, args) { +exports.call = function() { + var name = arguments[0]; + var args = [].slice.call(arguments, 1); return exports.apiMethodRegistry[name].apply(null, args); }; diff --git a/src/snapshot/toimage.js b/src/snapshot/toimage.js index 24c4de39fb1..6fd3c03acc5 100644 --- a/src/snapshot/toimage.js +++ b/src/snapshot/toimage.js @@ -63,7 +63,7 @@ function toImage(gd, opts) { var redrawFunc = helpers.getRedrawFunc(clonedGd); - Registry.call('plot', [clonedGd, clone.data, clone.layout, clone.config]) + Registry.call('plot', clonedGd, clone.data, clone.layout, clone.config) .then(redrawFunc) .then(wait) .catch(function(err) {