Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZERO circular dependency #2429

Merged
merged 17 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/components/annotations/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var Plotly = require('../../plotly');

var Registry = require('../../registry');

module.exports = {
hasClickToShow: hasClickToShow,
Expand Down Expand Up @@ -59,7 +57,7 @@ function onClick(gd, hoverData) {
update['annotations[' + offSet[i] + '].visible'] = false;
}

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

/*
Expand Down
11 changes: 4 additions & 7 deletions src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var d3 = require('d3');

var Plotly = require('../../plotly');
var Registry = require('../../registry');
var Plots = require('../../plots/plots');
var Lib = require('../../lib');
var Axes = require('../../plots/cartesian/axes');
Expand All @@ -21,10 +20,8 @@ var Fx = require('../fx');
var svgTextUtils = require('../../lib/svg_text_utils');
var setCursor = require('../../lib/setcursor');
var dragElement = require('../dragelement');

var drawArrowHead = require('./draw_arrow_head');


// Annotations are stored in gd.layout.annotations, an array of objects
// index can point to one item in this array,
// or non-numeric to simply add a new one
Expand Down Expand Up @@ -594,7 +591,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
});
},
doneFn: function() {
Plotly.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 @@ -676,7 +673,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
},
doneFn: function() {
setCursor(annTextGroupInner);
Plotly.relayout(gd, update);
Registry.call('relayout', [gd, update]);
var notesBox = document.querySelector('.js-notes-box-panel');
if(notesBox) notesBox.redraw(notesBox.selectedObj);
}
Expand All @@ -701,7 +698,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
update[ya._name + '.autorange'] = true;
}

Plotly.relayout(gd, update);
Registry.call('relayout', [gd, update]);
});
}
else annText.call(textLayout);
Expand Down
7 changes: 4 additions & 3 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
var d3 = require('d3');
var tinycolor = require('tinycolor2');

var Plotly = require('../../plotly');
var Plots = require('../../plots/plots');
var Registry = require('../../registry');
var Axes = require('../../plots/cartesian/axes');
Expand Down Expand Up @@ -588,9 +587,11 @@ module.exports = function draw(gd, id) {
setCursor(container);

if(xf !== undefined && yf !== undefined) {
Plotly.restyle(gd,
Registry.call('restyle', [
gd,
{'colorbar.x': xf, 'colorbar.y': yf},
getTrace().index);
getTrace().index
]);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/dragelement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var mouseOffset = require('mouse-event-offset');
var hasHover = require('has-hover');
var supportsPassive = require('has-passive-events');

var Plotly = require('../../plotly');
var Registry = require('../../registry');
var Lib = require('../../lib');

var constants = require('../../plots/cartesian/constants');
Expand Down Expand Up @@ -278,7 +278,7 @@ dragElement.coverSlip = coverSlip;

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

function pointerOffset(e) {
Expand Down
5 changes: 2 additions & 3 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

var d3 = require('d3');

var Plotly = require('../../plotly');
var Lib = require('../../lib');
var Plots = require('../../plots/plots');
var Registry = require('../../registry');
Expand Down Expand Up @@ -339,7 +338,7 @@ module.exports = function draw(gd) {
},
doneFn: function() {
if(xf !== undefined && yf !== undefined) {
Plotly.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 @@ -431,7 +430,7 @@ function drawTexts(g, gd) {
update.name = text;
}

return Plotly.restyle(gd, update, traceIndex);
return Registry.call('restyle', [gd, update, traceIndex]);
});
} else {
text.call(textLayout);
Expand Down
5 changes: 2 additions & 3 deletions src/components/legend/handle_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

'use strict';

var Plotly = require('../../plotly');
var Lib = require('../../lib');
var Registry = require('../../registry');

Expand Down Expand Up @@ -112,7 +111,7 @@ module.exports = function handleClick(g, gd, numClicks) {
}
}

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

Plotly.restyle(gd, attrUpdate, attrIndices);
Registry.call('restyle', [gd, attrUpdate, attrIndices]);
}
};
19 changes: 9 additions & 10 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@

'use strict';

var Plotly = require('../../plotly');
var Registry = require('../../registry');
var Plots = require('../../plots/plots');
var axisIds = require('../../plots/cartesian/axis_ids');
var Lib = require('../../lib');
var downloadImage = require('../../snapshot/download');
var Icons = require('../../../build/ploticon');


var _ = Lib._;

var modeBarButtons = module.exports = {};
Expand Down Expand Up @@ -250,7 +249,7 @@ function handleCartesian(gd, ev) {
aobj[astr] = val;
}

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

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

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

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

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

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

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

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

Plotly.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 @@ -501,7 +500,7 @@ function toggleHover(gd) {

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

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

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

var aobj = setSpikelineVisibility(gd);

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

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

Plotly.relayout(gd, aObj);
Registry.call('relayout', [gd, aObj]);
}
5 changes: 2 additions & 3 deletions src/components/rangeselector/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var d3 = require('d3');

var Plotly = require('../../plotly');
var Registry = require('../../registry');
var Plots = require('../../plots/plots');
var Color = require('../color');
var Drawing = require('../drawing');
Expand Down Expand Up @@ -69,7 +68,7 @@ module.exports = function draw(gd) {
button.on('click', function() {
if(gd._dragged) return;

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

button.on('mouseover', function() {
Expand Down
5 changes: 2 additions & 3 deletions src/components/rangeslider/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

var d3 = require('d3');

var Plotly = require('../../plotly');
var Registry = require('../../registry');
var Plots = require('../../plots/plots');

var Lib = require('../../lib');
Expand All @@ -25,7 +25,6 @@ var setCursor = require('../../lib/setcursor');

var constants = require('./constants');


module.exports = function(gd) {
var fullLayout = gd._fullLayout,
rangeSliderData = makeRangeSliderData(fullLayout);
Expand Down Expand Up @@ -262,7 +261,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
dataMax = clamp(opts.p2d(opts._pixelMax));

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

Expand Down
4 changes: 2 additions & 2 deletions src/components/shapes/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

var Plotly = require('../../plotly');
var Registry = require('../../registry');
var Lib = require('../../lib');
var Axes = require('../../plots/cartesian/axes');
var Color = require('../color');
Expand Down Expand Up @@ -213,7 +213,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index) {

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

function moveShape(dx, dy) {
Expand Down
9 changes: 6 additions & 3 deletions src/components/titles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
var d3 = require('d3');
var isNumeric = require('fast-isnumeric');

var Plotly = require('../../plotly');
var Plots = require('../../plots/plots');
var Registry = require('../../registry');
var Lib = require('../../lib');
var Drawing = require('../drawing');
var Color = require('../color');
Expand Down Expand Up @@ -237,8 +237,11 @@ Titles.draw = function(gd, titleClass, options) {

el.call(svgTextUtils.makeEditable, {gd: gd})
.on('edit', function(text) {
if(traceIndex !== undefined) Plotly.restyle(gd, prop, text, traceIndex);
else Plotly.relayout(gd, prop, text);
if(traceIndex !== undefined) {
Registry.call('restyle', [gd, prop, text, traceIndex]);
} else {
Registry.call('relayout', [gd, prop, text]);
}
})
.on('cancel', function() {
this.text(this.attr('data-unformatted'))
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 @@ -462,7 +462,7 @@ exports.doColorBars = function(gd) {
exports.layoutReplot = function(gd) {
var layout = gd.layout;
gd.layout = undefined;
return Plotly.plot(gd, '', layout);
return Registry.call('plot', [gd, '', layout]);
};

exports.doLegend = function(gd) {
Expand Down
6 changes: 3 additions & 3 deletions src/plot_api/to_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

'use strict';

var Plotly = require('../plotly');
var Registry = require('../registry');
var Lib = require('../lib');

var helpers = require('../snapshot/helpers');
Expand Down Expand Up @@ -155,7 +155,7 @@ function toImage(gd, opts) {
var width = clonedGd._fullLayout.width;
var height = clonedGd._fullLayout.height;

Plotly.purge(clonedGd);
Registry.call('purge', [clonedGd]);
document.body.removeChild(clonedGd);

if(format === 'svg') {
Expand Down Expand Up @@ -196,7 +196,7 @@ function toImage(gd, opts) {
}

return new Promise(function(resolve, reject) {
Plotly.plot(clonedGd, data, layoutImage, configImage)
Registry.call('plot', [clonedGd, data, layoutImage, configImage])
.then(redrawFunc)
.then(wait)
.then(convert)
Expand Down
Loading