@@ -13,6 +13,7 @@ var d3 = require('d3');
1313var tinycolor = require ( 'tinycolor2' ) ;
1414
1515var Plotly = require ( '../../plotly' ) ;
16+ var Registry = require ( '../../registry' ) ;
1617var Lib = require ( '../../lib' ) ;
1718var svgTextUtils = require ( '../../lib/svg_text_utils' ) ;
1819var 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