Skip to content

Commit 3e74c80

Browse files
committed
api: relax transform module requirements
- transform module are now required to have a transfrom OR calcTransform method
1 parent 7cfa4ff commit 3e74c80

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/plot_api/register.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@ function registerTransformModule(newModule) {
6161

6262
var prefix = 'Transform module ' + newModule.name;
6363

64-
if(typeof newModule.transform !== 'function') {
65-
throw new Error(prefix + ' is missing a *transform* function.');
64+
var hasTransform = typeof newModule.transform === 'function',
65+
hasCalcTransform = typeof newModule.calcTransform === 'function';
66+
67+
68+
if(!hasTransform && !hasCalcTransform) {
69+
throw new Error(prefix + ' is missing a *transform* or *calcTransform* method.');
70+
}
71+
6672
}
6773
if(!Lib.isPlainObject(newModule.attributes)) {
6874
Lib.log(prefix + ' registered without an *attributes* object.');

src/plots/plots.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ function applyTransforms(fullTrace, fullData, layout) {
792792
var transform = container[i],
793793
_module = transformsRegistry[transform.type];
794794

795-
if(_module) {
795+
if(_module && _module.transform) {
796796
dataOut = _module.transform(dataOut, {
797797
transform: transform,
798798
fullTrace: fullTrace,

src/transforms/filter.js

-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ exports.supplyDefaults = function(transformIn) {
109109
return transformOut;
110110
};
111111

112-
exports.transform = function(data) {
113-
return data;
114-
};
115-
116112
exports.calcTransform = function(gd, trace, opts) {
117113
var filtersrc = opts.filtersrc;
118114

0 commit comments

Comments
 (0)