@@ -17,27 +17,38 @@ var colorbarDefaults = require('../colorbar/defaults');
17
17
var isValidScale = require ( './scales' ) . isValid ;
18
18
var traceIs = require ( '../../registry' ) . traceIs ;
19
19
20
- function npMaybe ( outerCont , prefix ) {
20
+ function npMaybe ( parentCont , prefix ) {
21
21
var containerStr = prefix . slice ( 0 , prefix . length - 1 ) ;
22
22
return prefix ?
23
- Lib . nestedProperty ( outerCont , containerStr ) . get ( ) || { } :
24
- outerCont ;
23
+ Lib . nestedProperty ( parentCont , containerStr ) . get ( ) || { } :
24
+ parentCont ;
25
25
}
26
26
27
- module . exports = function colorScaleDefaults ( outerContIn , outerContOut , layout , coerce , opts ) {
27
+ /**
28
+ * Colorscale / colorbar default handler
29
+ *
30
+ * @param {object } parentContIn : user (input) parent container (e.g. trace or layout coloraxis object)
31
+ * @param {object } parentContOut : full parent container
32
+ * @param {object } layout : (full) layout object
33
+ * @param {fn } coerce : Lib.coerce wrapper
34
+ * @param {object } opts :
35
+ * - prefix {string} : attr string prefix to colorscale container from parent root
36
+ * - cLetter {string} : 'c or 'z' color letter
37
+ */
38
+ module . exports = function colorScaleDefaults ( parentContIn , parentContOut , layout , coerce , opts ) {
28
39
var prefix = opts . prefix ;
29
40
var cLetter = opts . cLetter ;
30
- var inTrace = '_module' in outerContOut ;
31
- var containerIn = npMaybe ( outerContIn , prefix ) ;
32
- var containerOut = npMaybe ( outerContOut , prefix ) ;
33
- var template = npMaybe ( outerContOut . _template || { } , prefix ) || { } ;
41
+ var inTrace = '_module' in parentContOut ;
42
+ var containerIn = npMaybe ( parentContIn , prefix ) ;
43
+ var containerOut = npMaybe ( parentContOut , prefix ) ;
44
+ var template = npMaybe ( parentContOut . _template || { } , prefix ) || { } ;
34
45
35
46
// colorScaleDefaults wrapper called if-ever we need to reset the colorscale
36
47
// attributes for containers that were linked to invalid color axes
37
48
var thisFn = function ( ) {
38
- delete outerContIn . coloraxis ;
39
- delete outerContOut . coloraxis ;
40
- return colorScaleDefaults ( outerContIn , outerContOut , layout , coerce , opts ) ;
49
+ delete parentContIn . coloraxis ;
50
+ delete parentContOut . coloraxis ;
51
+ return colorScaleDefaults ( parentContIn , parentContOut , layout , coerce , opts ) ;
41
52
} ;
42
53
43
54
if ( inTrace ) {
@@ -46,8 +57,8 @@ module.exports = function colorScaleDefaults(outerContIn, outerContOut, layout,
46
57
47
58
if ( colorAx ) {
48
59
var colorbarVisuals = (
49
- traceIs ( outerContOut , 'contour' ) &&
50
- Lib . nestedProperty ( outerContOut , 'contours.coloring' ) . get ( )
60
+ traceIs ( parentContOut , 'contour' ) &&
61
+ Lib . nestedProperty ( parentContOut , 'contours.coloring' ) . get ( )
51
62
) || 'heatmap' ;
52
63
53
64
var stash = colorAxes [ colorAx ] ;
@@ -67,7 +78,7 @@ module.exports = function colorScaleDefaults(outerContIn, outerContOut, layout,
67
78
// - colorbar visual 'type'
68
79
// - colorbar options to help in Colorbar.draw
69
80
// - list of colorScaleDefaults wrapper functions
70
- colorAxes [ colorAx ] = [ colorbarVisuals , outerContOut , [ thisFn ] ] ;
81
+ colorAxes [ colorAx ] = [ colorbarVisuals , parentContOut , [ thisFn ] ] ;
71
82
}
72
83
return ;
73
84
}
0 commit comments