Skip to content

Commit f10910f

Browse files
committed
fixup cartesian dragbox module
- use 'drawOne' mehtod instead of 'draw' as per PR #833 - use Registry instead of Plotly[module] as per PR #845
1 parent 5b92305 commit f10910f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/plots/cartesian/dragbox.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var d3 = require('d3');
1313
var tinycolor = require('tinycolor2');
1414

1515
var Plotly = require('../../plotly');
16+
var Registry = require('../../registry');
1617
var Lib = require('../../lib');
1718
var svgTextUtils = require('../../lib/svg_text_utils');
1819
var Color = require('../../components/color');
@@ -512,20 +513,23 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
512513
Axes.doTicks(gd, activeAxIds[i], true);
513514
}
514515

515-
function redrawObjs(objArray, module) {
516-
var obji;
516+
function redrawObjs(objArray, method) {
517517
for(i = 0; i < objArray.length; i++) {
518-
obji = objArray[i];
518+
var obji = objArray[i];
519+
519520
if((ew && activeAxIds.indexOf(obji.xref) !== -1) ||
520521
(ns && activeAxIds.indexOf(obji.yref) !== -1)) {
521-
module.draw(gd, i);
522+
method(gd, i);
522523
}
523524
}
524525
}
525526

526-
redrawObjs(fullLayout.annotations || [], Plotly.Annotations);
527-
redrawObjs(fullLayout.shapes || [], Plotly.Shapes);
528-
redrawObjs(fullLayout.images || [], Plotly.Images);
527+
// annotations and shapes 'draw' method is slow,
528+
// use the finer-grained 'drawOne' method instead
529+
530+
redrawObjs(fullLayout.annotations || [], Registry.getComponentMethod('annotations', 'drawOne'));
531+
redrawObjs(fullLayout.shapes || [], Registry.getComponentMethod('shapes', 'drawOne'));
532+
redrawObjs(fullLayout.images || [], Registry.getComponentMethod('images', 'draw'));
529533
}
530534

531535
function doubleClick() {

0 commit comments

Comments
 (0)