diff --git a/src/plots/cartesian/dragbox.js b/src/plots/cartesian/dragbox.js index 5b18574482f..eb7ad269d1d 100644 --- a/src/plots/cartesian/dragbox.js +++ b/src/plots/cartesian/dragbox.js @@ -13,6 +13,7 @@ var d3 = require('d3'); var tinycolor = require('tinycolor2'); var Plotly = require('../../plotly'); +var Registry = require('../../registry'); var Lib = require('../../lib'); var svgTextUtils = require('../../lib/svg_text_utils'); var Color = require('../../components/color'); @@ -512,20 +513,23 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) { Axes.doTicks(gd, activeAxIds[i], true); } - function redrawObjs(objArray, module) { - var obji; + function redrawObjs(objArray, method) { for(i = 0; i < objArray.length; i++) { - obji = objArray[i]; + var obji = objArray[i]; + if((ew && activeAxIds.indexOf(obji.xref) !== -1) || (ns && activeAxIds.indexOf(obji.yref) !== -1)) { - module.draw(gd, i); + method(gd, i); } } } - redrawObjs(fullLayout.annotations || [], Plotly.Annotations); - redrawObjs(fullLayout.shapes || [], Plotly.Shapes); - redrawObjs(fullLayout.images || [], Plotly.Images); + // annotations and shapes 'draw' method is slow, + // use the finer-grained 'drawOne' method instead + + redrawObjs(fullLayout.annotations || [], Registry.getComponentMethod('annotations', 'drawOne')); + redrawObjs(fullLayout.shapes || [], Registry.getComponentMethod('shapes', 'drawOne')); + redrawObjs(fullLayout.images || [], Registry.getComponentMethod('images', 'draw')); } function doubleClick() {