Skip to content

Commit 3787d47

Browse files
committed
loop over basePlotModules instead of subplotRegistry in:
- in Plots.cleanPlot (use basePlotModules list in old fullLayout) - in Plots.supplyLayoutModulesDefaults (making those !_has??? obsolete) - in main drawData function (instead of _has??? switch block)
1 parent 392619c commit 3787d47

File tree

5 files changed

+20
-27
lines changed

5 files changed

+20
-27
lines changed

src/plot_api/plot_api.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,12 @@ Plotly.plot = function(gd, data, layout, config) {
250250

251251
// Now plot the data
252252
function drawData() {
253-
var calcdata = gd.calcdata;
253+
var calcdata = gd.calcdata,
254+
i;
254255

255256
// in case of traces that were heatmaps or contour maps
256257
// previously, remove them and their colorbars explicitly
257-
for(var i = 0; i < calcdata.length; i++) {
258+
for(i = 0; i < calcdata.length; i++) {
258259
var trace = calcdata[i][0].trace,
259260
isVisible = (trace.visible === true),
260261
uid = trace.uid;
@@ -272,17 +273,11 @@ Plotly.plot = function(gd, data, layout, config) {
272273
}
273274
}
274275

275-
var plotRegistry = Plots.subplotsRegistry;
276-
277-
if(fullLayout._hasGL3D) plotRegistry.gl3d.plot(gd);
278-
if(fullLayout._hasGeo) plotRegistry.geo.plot(gd);
279-
if(fullLayout._hasGL2D) plotRegistry.gl2d.plot(gd);
280-
if(fullLayout._hasCartesian) plotRegistry.cartesian.plot(gd);
281-
if(fullLayout._hasPie) plotRegistry.pie.plot(gd);
282-
if(fullLayout._hasTernary) plotRegistry.ternary.plot(gd);
283-
284-
// clean up old scenes that no longer have associated data
285-
// will this be a performance hit?
276+
// loop over the base plot modules present on graph
277+
var basePlotModules = fullLayout._basePlotModules;
278+
for(i = 0; i < basePlotModules.length; i++) {
279+
basePlotModules[i].plot(gd);
280+
}
286281

287282
// styling separate from drawing
288283
Plots.style(gd);

src/plots/geo/layout/defaults.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ var supplyGeoAxisLayoutDefaults = require('./axis_defaults');
1616

1717

1818
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
19-
if(!layoutOut._hasGeo) return;
20-
2119
handleSubplotDefaults(layoutIn, layoutOut, fullData, {
2220
type: 'geo',
2321
attributes: layoutAttributes,

src/plots/gl3d/layout/defaults.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ var supplyGl3dAxisLayoutDefaults = require('./axis_defaults');
1717

1818

1919
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
20-
if(!layoutOut._hasGL3D) return;
21-
2220
var hasNon3D = (
2321
layoutOut._hasCartesian ||
2422
layoutOut._hasGeo ||

src/plots/plots.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,9 @@ function hasPlotType(category) {
553553
plots.cleanPlot = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
554554
var i, j;
555555

556-
var plotTypes = Object.keys(subplotsRegistry);
557-
for(i = 0; i < plotTypes.length; i++) {
558-
var _module = subplotsRegistry[plotTypes[i]];
556+
var basePlotModules = oldFullLayout._basePlotModules || [];
557+
for(i = 0; i < basePlotModules.length; i++) {
558+
var _module = basePlotModules[i];
559559

560560
if(_module.clean) {
561561
_module.clean(newFullData, newFullLayout, oldFullData, oldFullLayout);
@@ -745,13 +745,17 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut) {
745745
plots.supplyLayoutModuleDefaults = function(layoutIn, layoutOut, fullData) {
746746
var i, _module;
747747

748-
// TODO incorporate into subplotsRegistry
748+
// can't be be part of basePlotModules loop
749+
// in order to handle the orphan axes case
749750
Plotly.Axes.supplyLayoutDefaults(layoutIn, layoutOut, fullData);
750751

751-
// plot module layout defaults
752-
var plotTypes = Object.keys(subplotsRegistry);
753-
for(i = 0; i < plotTypes.length; i++) {
754-
_module = subplotsRegistry[plotTypes[i]];
752+
// base plot module layout defaults
753+
var basePlotModules = layoutOut._basePlotModules;
754+
for(i = 0; i < basePlotModules.length; i++) {
755+
_module = basePlotModules[i];
756+
757+
// done above already
758+
if(_module.name === 'cartesian') continue;
755759

756760
// e.g. gl2d does not have a layout-defaults step
757761
if(_module.supplyLayoutDefaults) {

src/plots/ternary/layout/defaults.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ var handleAxisDefaults = require('./axis_defaults');
1818
var axesNames = ['aaxis', 'baxis', 'caxis'];
1919

2020
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
21-
if(!layoutOut._hasTernary) return;
22-
2321
handleSubplotDefaults(layoutIn, layoutOut, fullData, {
2422
type: 'ternary',
2523
attributes: layoutAttributes,

0 commit comments

Comments
 (0)