Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52ded31

Browse filesBrowse files
committed
refactor base_plot files
1 parent ec6a9de commit 52ded31
Copy full SHA for 52ded31

File tree

Expand file treeCollapse file tree

5 files changed

+33
-48
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+33
-48
lines changed

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var axisIDs = require('./cartesian/axis_ids');
2323
var animationAttrs = require('./animation_attributes');
2424
var frameAttrs = require('./frame_attributes');
2525

26+
var getModuleCalcData = require('../plots/get_data').getModuleCalcData;
27+
2628
var relinkPrivateKeys = Lib.relinkPrivateKeys;
2729
var _ = Lib._;
2830

@@ -3203,3 +3205,18 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl
32033205
// update moduleName -> calcData hash
32043206
subplot.traceHash = traceHash;
32053207
};
3208+
3209+
plots.plotBasePlot = function(desiredType, gd, traces, transitionOpts, makeOnCompleteCallback) {
3210+
var _module = Registry.getModule(desiredType);
3211+
var cdmodule = getModuleCalcData(gd.calcdata, _module)[0];
3212+
_module.plot(gd, cdmodule, transitionOpts, makeOnCompleteCallback);
3213+
};
3214+
3215+
plots.cleanBasePlot = function(desiredType, newFullData, newFullLayout, oldFullData, oldFullLayout) {
3216+
var had = (oldFullLayout._has && oldFullLayout._has(desiredType));
3217+
var has = (newFullLayout._has && newFullLayout._has(desiredType));
3218+
3219+
if(had && !has) {
3220+
oldFullLayout['_' + desiredType + 'layer'].selectAll('g.trace').remove();
3221+
}
3222+
};

‎src/traces/funnelarea/base_plot.js

Copy file name to clipboardExpand all lines: src/traces/funnelarea/base_plot.js
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@
88

99
'use strict';
1010

11-
var Registry = require('../../registry');
12-
var getModuleCalcData = require('../../plots/get_data').getModuleCalcData;
11+
var plots = require('../../plots/plots');
1312

1413
exports.name = 'funnelarea';
1514

16-
exports.plot = function(gd) {
17-
var Funnelarea = Registry.getModule('funnelarea');
18-
var cdFunnelarea = getModuleCalcData(gd.calcdata, Funnelarea)[0];
19-
Funnelarea.plot(gd, cdFunnelarea);
15+
exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
16+
plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
2017
};
2118

2219
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
23-
var hadFunnelarea = (oldFullLayout._has && oldFullLayout._has('funnelarea'));
24-
var hasFunnelarea = (newFullLayout._has && newFullLayout._has('funnelarea'));
25-
26-
if(hadFunnelarea && !hasFunnelarea) {
27-
oldFullLayout._funnelarealayer.selectAll('g.trace').remove();
28-
}
20+
plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
2921
};

‎src/traces/indicator/base_plot.js

Copy file name to clipboardExpand all lines: src/traces/indicator/base_plot.js
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@
88

99
'use strict';
1010

11-
var Registry = require('../../registry');
12-
var getModuleCalcData = require('../../plots/get_data').getModuleCalcData;
11+
var plots = require('../../plots/plots');
1312

14-
var name = exports.name = 'indicator';
13+
exports.name = 'indicator';
1514

1615
exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
17-
var _module = Registry.getModule(name);
18-
var cdmodule = getModuleCalcData(gd.calcdata, _module)[0];
19-
_module.plot(gd, cdmodule, transitionOpts, makeOnCompleteCallback);
16+
plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
2017
};
2118

2219
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
23-
var had = (oldFullLayout._has && oldFullLayout._has(name));
24-
var has = (newFullLayout._has && newFullLayout._has(name));
25-
26-
if(had && !has) {
27-
oldFullLayout._indicatorlayer.selectAll('g.trace').remove();
28-
}
20+
plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
2921
};

‎src/traces/pie/base_plot.js

Copy file name to clipboardExpand all lines: src/traces/pie/base_plot.js
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@
88

99
'use strict';
1010

11-
var Registry = require('../../registry');
12-
var getModuleCalcData = require('../../plots/get_data').getModuleCalcData;
11+
var plots = require('../../plots/plots');
1312

1413
exports.name = 'pie';
1514

16-
exports.plot = function(gd) {
17-
var Pie = Registry.getModule('pie');
18-
var cdPie = getModuleCalcData(gd.calcdata, Pie)[0];
19-
Pie.plot(gd, cdPie);
15+
exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
16+
plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
2017
};
2118

2219
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
23-
var hadPie = (oldFullLayout._has && oldFullLayout._has('pie'));
24-
var hasPie = (newFullLayout._has && newFullLayout._has('pie'));
25-
26-
if(hadPie && !hasPie) {
27-
oldFullLayout._pielayer.selectAll('g.trace').remove();
28-
}
20+
plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
2921
};

‎src/traces/sunburst/base_plot.js

Copy file name to clipboardExpand all lines: src/traces/sunburst/base_plot.js
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@
88

99
'use strict';
1010

11-
var Registry = require('../../registry');
12-
var getModuleCalcData = require('../../plots/get_data').getModuleCalcData;
11+
var plots = require('../../plots/plots');
1312

14-
var name = exports.name = 'sunburst';
13+
exports.name = 'sunburst';
1514

1615
exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
17-
var _module = Registry.getModule(name);
18-
var cdmodule = getModuleCalcData(gd.calcdata, _module)[0];
19-
_module.plot(gd, cdmodule, transitionOpts, makeOnCompleteCallback);
16+
plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
2017
};
2118

2219
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
23-
var had = (oldFullLayout._has && oldFullLayout._has(name));
24-
var has = (newFullLayout._has && newFullLayout._has(name));
25-
26-
if(had && !has) {
27-
oldFullLayout._sunburstlayer.selectAll('g.trace').remove();
28-
}
20+
plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
2921
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.