Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23fdd70

Browse files
author
Wayne Douglas
committed
Changes to make redrawObjs work by convention
1 parent 24b2912 commit 23fdd70

File tree

6 files changed

+93
-70
lines changed

6 files changed

+93
-70
lines changed

src/components/annotations/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ var clickModule = require('./click');
1515
module.exports = {
1616
moduleType: 'component',
1717
name: 'annotations',
18-
18+
isDrawable: true,
19+
1920
layoutAttributes: require('./attributes'),
2021
supplyLayoutDefaults: require('./defaults'),
2122
includeBasePlot: require('../../plots/cartesian/include_components')('annotations'),

src/components/images/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
module.exports = {
1212
moduleType: 'component',
1313
name: 'images',
14-
14+
isDrawable: true,
15+
1516
layoutAttributes: require('./attributes'),
1617
supplyLayoutDefaults: require('./defaults'),
1718
includeBasePlot: require('../../plots/cartesian/include_components')('images'),
1819

1920
draw: require('./draw'),
21+
drawOne: require('./draw'),
2022

2123
convertCoords: require('./convert_coords')
2224
};

src/components/shapes/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var drawModule = require('./draw');
1414
module.exports = {
1515
moduleType: 'component',
1616
name: 'shapes',
17+
isDrawable: true,
1718

1819
layoutAttributes: require('./attributes'),
1920
supplyLayoutDefaults: require('./defaults'),

src/plots/cartesian/dragbox.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,11 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
615615
// annotations and shapes 'draw' method is slow,
616616
// use the finer-grained 'drawOne' method instead
617617

618-
redrawObjs(gd._fullLayout.annotations || [], Registry.getComponentMethod('annotations', 'drawOne'));
619-
redrawObjs(gd._fullLayout.shapes || [], Registry.getComponentMethod('shapes', 'drawOne'));
620-
redrawObjs(gd._fullLayout.images || [], Registry.getComponentMethod('images', 'draw'), true);
618+
var componentsNeedingRedraw = Registry.getModules('component', true);
619+
componentsNeedingRedraw.forEach(function(item){
620+
// only issue here is that we cam't short circuit images
621+
redrawObjs(gd._fullLayout[item.name] || [], Registry.getComponentMethod(item.name, 'drawOne'));
622+
});
621623
}
622624

623625
function doubleClick() {

src/plots/cartesian/transition_axes.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
108108
}
109109
}
110110

111-
redrawObjs(fullLayout.annotations || [], Registry.getComponentMethod('annotations', 'drawOne'));
112-
redrawObjs(fullLayout.shapes || [], Registry.getComponentMethod('shapes', 'drawOne'));
113-
redrawObjs(fullLayout.images || [], Registry.getComponentMethod('images', 'draw'), true);
111+
var componentsNeedingRedraw = Registry.getModules('component', true);
112+
componentsNeedingRedraw.forEach(function(item){
113+
// only issue here is that we cam't short circuit images
114+
redrawObjs(gd._fullLayout[item.name] || [], Registry.getComponentMethod(item.name, 'drawOne'));
115+
});
114116
}
115117

116118
if(!affectedSubplots.length) {
@@ -142,9 +144,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
142144
}
143145
}
144146

145-
redrawObjs(fullLayout.annotations || [], Registry.getComponentMethod('annotations', 'drawOne'));
146-
redrawObjs(fullLayout.shapes || [], Registry.getComponentMethod('shapes', 'drawOne'));
147-
redrawObjs(fullLayout.images || [], Registry.getComponentMethod('images', 'draw'), true);
147+
var componentsNeedingRedraw = Registry.getModules('component', true);
148+
componentsNeedingRedraw.forEach(function(item){
149+
// only issue here is that we cam't short circuit images
150+
redrawObjs(gd._fullLayout[item.name] || [], Registry.getComponentMethod(item.name, 'drawOne'));
151+
});
148152
}
149153

150154
function unsetSubplotTransform(subplot) {

0 commit comments

Comments
 (0)