Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ed4484

Browse files
committed
Make hasCategory method
1 parent 8546576 commit 7ed4484

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/plots/plots.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ plots.supplyDefaults = function(gd) {
458458

459459
// attach helper method to check whether a plot type is present on graph
460460
newFullLayout._has = plots._hasPlotType.bind(newFullLayout);
461+
newFullLayout._hasCategory = plots._hasCategory.bind(newFullLayout);
461462

462463
// special cases that introduce interactions between traces
463464
var _modules = newFullLayout._modules;
@@ -576,6 +577,21 @@ plots._hasPlotType = function(category) {
576577
return false;
577578
};
578579

580+
// check whether trace has a category
581+
plots._hasCategory = function(category) {
582+
var modules = this._modules || [];
583+
584+
// create canvases only in case if there is at least one regl component
585+
for(var i = 0; i < modules.length; i++) {
586+
var _ = modules[i];
587+
if(_.categories && _.categories.indexOf(category) >= 0) {
588+
return true;
589+
}
590+
}
591+
592+
return false;
593+
};
594+
579595
plots.cleanPlot = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
580596
var i, j;
581597

0 commit comments

Comments
 (0)