Skip to content

Splom zoom perf #2527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 11, 2018
20 changes: 9 additions & 11 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,24 +627,22 @@ plots.createTransitionData = function(gd) {
// whether a certain plot type is present on plot
// or trace has a category
plots._hasPlotType = function(category) {
// check plot
var basePlotModules = this._basePlotModules || [];
var i;

// check base plot modules
var basePlotModules = this._basePlotModules || [];
for(i = 0; i < basePlotModules.length; i++) {
var _module = basePlotModules[i];

if(_module.name === category) return true;
if(basePlotModules[i].name === category) return true;
}

// check trace
// check trace modules
var modules = this._modules || [];

for(i = 0; i < modules.length; i++) {
var modulei = modules[i];
if(modulei.categories && modulei.categories.indexOf(category) >= 0) {
return true;
}
var name = modules[i].name;
if(name === category) return true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so calls like fullLayout._has('scattergl') just works w/o having to set a scattergl category in the trace module.

// N.B. this is modules[i] along with 'categories' as a hash object
var _module = Registry.modules[name];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I've forgotten why we wrapped modules like this in the registry... not a big deal, but would it be better to attach the hash directly to the module, or even make categories as a hash from the beginning? Is it ever important that it's a list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referencing #2174 where we like to make building custom trace modules more user friendly:

  • we should try to not mutate the input module object, so that means not replacing the categories list with a hash object nor augmenting the input module object with e.g. a categoryHash key.
  • listing categories as an array feels more natural than {cat1: 1, cat2: 1} hash object

So, I'm voting for the status quo.

if(_module && _module.categories[category]) return true;
}

return false;
Expand Down