Skip to content

Commit

Permalink
fixup cartesian dragbox module
Browse files Browse the repository at this point in the history
- use 'drawOne' mehtod instead of 'draw' as per PR #833
- use Registry instead of Plotly[module] as per PR #845
  • Loading branch information
etpinard committed Aug 24, 2016
1 parent 5b92305 commit f10910f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit f10910f

Please sign in to comment.