@@ -471,20 +471,16 @@ plots.supplyDefaults = function(gd) {
471
471
var fullTrace = plots . supplyDataDefaults ( newData [ i ] , i , newFullLayout ) ;
472
472
newFullData . push ( fullTrace ) ;
473
473
474
- // detect plot type
475
- if ( plots . traceIs ( fullTrace , 'cartesian' ) ) newFullLayout . _hasCartesian = true ;
476
- else if ( plots . traceIs ( fullTrace , 'gl3d' ) ) newFullLayout . _hasGL3D = true ;
477
- else if ( plots . traceIs ( fullTrace , 'geo' ) ) newFullLayout . _hasGeo = true ;
478
- else if ( plots . traceIs ( fullTrace , 'pie' ) ) newFullLayout . _hasPie = true ;
479
- else if ( plots . traceIs ( fullTrace , 'gl2d' ) ) newFullLayout . _hasGL2D = true ;
480
- else if ( plots . traceIs ( fullTrace , 'ternary' ) ) newFullLayout . _hasTernary = true ;
481
- else if ( 'r' in fullTrace ) newFullLayout . _hasPolar = true ;
474
+ // detect polar
475
+ if ( 'r' in fullTrace ) newFullLayout . _hasPolar = true ;
482
476
483
477
// fill in modules list
484
478
_module = fullTrace . _module ;
485
479
if ( _module && modules . indexOf ( _module ) === - 1 ) modules . push ( _module ) ;
486
480
}
487
481
482
+ // attach helper method
483
+ newFullLayout . _has = hasPlotType . bind ( newFullLayout ) ;
488
484
// special cases that introduce interactions between traces
489
485
for ( i = 0 ; i < modules . length ; i ++ ) {
490
486
_module = modules [ i ] ;
@@ -526,6 +522,23 @@ plots.supplyDefaults = function(gd) {
526
522
}
527
523
} ;
528
524
525
+ // helper function to be bound to fullLayout to check
526
+ // whether a certain plot type or layout categories is present on plot
527
+ function hasPlotType ( category ) {
528
+ var modules = this . _modules || [ ] ;
529
+
530
+ for ( var i = 0 ; i < modules . length ; i ++ ) {
531
+ var _module = modules [ i ] ;
532
+
533
+ if ( _module . basePlotModule . name === category ) return true ;
534
+
535
+ var layoutCategories = _module . layoutCategories || [ ] ;
536
+ if ( layoutCategories . indexOf ( category ) !== - 1 ) return true ;
537
+ }
538
+
539
+ return false ;
540
+ }
541
+
529
542
plots . cleanPlot = function ( newFullData , newFullLayout , oldFullData , oldFullLayout ) {
530
543
var i , j ;
531
544
0 commit comments