8000 make Plotly.register handle transform modules · xiaoaiwhc/plotly.js@323e57d · GitHub
[go: up one dir, main page]

Skip to content

Commit 323e57d

Browse files
committed
make Plotly.register handle transform modules
1 parent 0c741cc commit 323e57d

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/plotly.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,27 @@ exports.register = function register(_modules) {
6161
for(var i = 0; i < _modules.length; i++) {
6262
var newModule = _modules[i];
6363

64-
if(newModule && newModule.moduleType !== 'trace') {
64+
if(!newModule) {
6565
throw new Error('Invalid module was attempted to be registered!');
66-
} else {
67-
Plots.register(newModule, newModule.name, newModule.categories, newModule.meta);
66+
}
67+
68+
switch(newModule.moduleType) {
69+
case 'trace':
70+
Plots.register(newModule, newModule.name, newModule.categories, newModule.meta);
71+
72+
if(!Plots.subplotsRegistry[newModule.basePlotModule.name]) {
73+
Plots.registerSubplot(newModule.basePlotModule);
74+
}
75+
76+
break;
77+
78+
case 'transform':
79+
Plots.transformsRegistry[newModule.name] = newModule;
80+
81+
break;
6882

69-
if(!Plots.subplotsRegistry[newModule.basePlotModule.name]) {
70-
Plots.registerSubplot(newModule.basePlotModule);
71-
}
83+
default:
84+
throw new Error('Invalid module was attempted to be registered!');
7285
}
7386
}
7487
};

src/plots/plots.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ var plots = module.exports = {};
2121
var modules = plots.modules = {},
2222
allTypes = plots.allTypes = [],
2323
allCategories = plots.allCategories = {},
24-
subplotsRegistry = plots.subplotsRegistry = {};
24+
subplotsRegistry = plots.subplotsRegistry = {},
25+
transformsRegistry = plots.transformsRegistry = {};
2526

2627
plots.attributes = require('./attributes');
2728
plots.attributes.type.values = allTypes;

0 commit comments

Comments
 (0)
0