Skip to content

Commit

Permalink
push trace module into fullLayout._modules even if visible:false
Browse files Browse the repository at this point in the history
- so that gl-based trace can call their plot methods w/ an
  empty array of traces and just work.
- this makes restyle(gd, 'visible', false) work properly for
  scattergl traces
  • Loading branch information
etpinard committed Jul 23, 2018
1 parent 1675047 commit 3790734
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ plots._hasPlotType = function(category) {
if(basePlotModules[i].name === category) return true;
}

// check trace modules
// check trace modules (including non-visible:true)
var modules = this._modules || [];
for(i = 0; i < modules.length; i++) {
var name = modules[i].name;
Expand Down Expand Up @@ -912,7 +912,7 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) {
var _module = fullTrace._module;
if(!_module) return;

if(fullTrace.visible === true) Lib.pushUnique(modules, _module);
Lib.pushUnique(modules, _module);

This comment has been minimized.

Copy link
@etpinard

etpinard Jul 23, 2018

Author Contributor

This makes fullLayout._has('gl') === true even when all scattergl traces are visible !== true which in turn makes Cartersian.plot call Scattergl.plot here:

// call Scattergl.plot separately
if(fullLayout._has('scattergl')) {
_module = Registry.getModule('scattergl');
cdModule = getModuleCalcData(cdSubplot, _module)[0];
_module.plot(gd, plotinfo, cdModule);
}

and sets up an empty scene.visibleBatch ready to be skipped on render.

Previously, when all scattergl traces were visible !== true, we would clear the scene here:

var hadGl = (oldFullLayout._has && oldFullLayout._has('gl'));
var hasGl = (newFullLayout._has && newFullLayout._has('gl'));
if(hadGl && !hasGl) {
for(k in oldPlots) {
plotinfo = oldPlots[k];
if(plotinfo._scene) plotinfo._scene.destroy();
}
}

resulting in very slow updates.

Lib.pushUnique(basePlotModules, fullTrace._module.basePlotModule);

cnt++;
Expand Down

0 comments on commit 3790734

Please sign in to comment.