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

Skip to content

Commit 51fd6fc

Browse files
committed
loop over plot modules to look for supplyLayoutDefaults,
instead of hard-coding the module names
1 parent fcc00c1 commit 51fd6fc

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/plots/plots.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,17 +658,29 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut) {
658658
plots.supplyLayoutModuleDefaults = function(layoutIn, layoutOut, fullData) {
659659
var moduleLayoutDefaults = [
660660
'Axes', 'Annotations', 'Shapes', 'Fx',
661-
'Bar', 'Box', 'Gl3dLayout', 'GeoLayout', 'Pie', 'Legend'
661+
'Bar', 'Box', 'Pie', 'Legend'
662662
];
663663

664-
var i, module;
664+
var i, _module;
665665

666666
// don't add a check for 'function in module' as it is better to error out and
667667
// secure the module API then not apply the default function.
668668
for(i = 0; i < moduleLayoutDefaults.length; i++) {
669-
module = moduleLayoutDefaults[i];
670-
if(Plotly[module]) {
671-
Plotly[module].supplyLayoutDefaults(layoutIn, layoutOut, fullData);
669+
_module = moduleLayoutDefaults[i];
670+
671+
if(Plotly[_module]) {
672+
Plotly[_module].supplyLayoutDefaults(layoutIn, layoutOut, fullData);
673+
}
674+
}
675+
676+
var plotTypes = Object.keys(subplotsRegistry);
677+
678+
for(i = 0; i < plotTypes.length; i++) {
679+
_module = subplotsRegistry[plotTypes[i]];
680+
681+
// e.g. gl2d does not have a layout-defaults step
682+
if(_module.supplyLayoutDefaults) {
683+
_module.supplyLayoutDefaults(layoutIn, layoutOut, fullData);
672684
}
673685
}
674686
};

0 commit comments

Comments
 (0)