8
8
9
9
'use strict' ;
10
10
11
- var colorMix = require ( 'tinycolor2' ) . mix ;
12
-
13
11
var Lib = require ( '../../lib' ) ;
14
12
var Color = require ( '../../components/color' ) ;
15
13
var Plots = require ( '../plots' ) ;
@@ -20,6 +18,7 @@ var handleTickValueDefaults = require('../cartesian/tick_value_defaults');
20
18
var handleTickMarkDefaults = require ( '../cartesian/tick_mark_defaults' ) ;
21
19
var handleTickLabelDefaults = require ( '../cartesian/tick_label_defaults' ) ;
22
20
var handleCategoryOrderDefaults = require ( '../cartesian/category_order_defaults' ) ;
21
+ var handleLineGridDefaults = require ( '../cartesian/line_grid_defaults' ) ;
23
22
var autoType = require ( '../cartesian/axis_autotype' ) ;
24
23
var orderedCategories = require ( '../cartesian/ordered_categories' ) ;
25
24
var setConvert = require ( '../cartesian/set_convert' ) ;
@@ -69,10 +68,17 @@ function handleDefaults(contIn, contOut, coerce, opts) {
69
68
handleCalendarDefaults ( axIn , axOut , 'calendar' , layoutOut . calendar ) ;
70
69
}
71
70
72
- coerceAxis ( 'visible' ) ;
73
-
71
+ var visible = coerceAxis ( 'visible' ) ;
74
72
setConvert ( axOut , layoutOut ) ;
75
73
74
+ var dfltColor ;
75
+ var dfltFontColor ;
76
+
77
+ if ( visible ) {
78
+ dfltColor = coerceAxis ( 'color' ) ;
79
+ dfltFontColor = ( dfltColor === axIn . color ) ? dfltColor : opts . font . color ;
80
+ }
81
+
76
82
// We don't want to make downstream code call ax.setScale,
77
83
// as both radial and angular axes don't have a set domain.
78
84
// Furthermore, angular axes don't have a set range.
@@ -89,11 +95,13 @@ function handleDefaults(contIn, contOut, coerce, opts) {
89
95
coerceAxis ( 'range' ) ;
90
96
axOut . cleanRange ( 'range' , { dfltRange : [ 0 , 1 ] } ) ;
91
97
92
- if ( axOut . visible ) {
98
+ if ( visible ) {
93
99
coerceAxis ( 'side' ) ;
94
100
coerceAxis ( 'position' , sector [ 0 ] ) ;
101
+
95
102
}
96
103
break ;
104
+
97
105
case 'angularaxis' :
98
106
if ( axType === 'linear' ) {
99
107
coerceAxis ( 'thetaunit' ) ;
@@ -111,10 +119,42 @@ function handleDefaults(contIn, contOut, coerce, opts) {
111
119
break ;
112
120
}
113
121
114
- if ( axOut . visible ) {
115
- handleAxisStyleDefaults ( axIn , axOut , coerceAxis , opts ) ;
122
+ if ( visible ) {
123
+ handleTickValueDefaults ( axIn , axOut , coerceAxis , axOut . type ) ;
124
+ handleTickLabelDefaults ( axIn , axOut , coerceAxis , axOut . type , {
125
+ noHover : false ,
126
+ tickSuffixDflt : axOut . thetaunit === 'degrees' ? '°' : undefined
127
+ } ) ;
128
+ handleTickMarkDefaults ( axIn , axOut , coerceAxis , { outerTicks : true } ) ;
129
+
130
+ var showTickLabels = coerceAxis ( 'showticklabels' ) ;
131
+ if ( showTickLabels ) {
132
+ Lib . coerceFont ( coerceAxis , 'tickfont' , {
133
+ family : opts . font . family ,
134
+ size : opts . font . size ,
135
+ color : dfltFontColor
136
+ } ) ;
137
+ coerceAxis ( 'tickangle' ) ;
138
+ coerceAxis ( 'tickformat' ) ;
139
+ }
140
+
141
+ handleLineGridDefaults ( axIn , axOut , coerceAxis , {
142
+ dfltColor : dfltColor ,
143
+ bgColor : opts . bgColor ,
144
+ // default grid color is darker here (60%, vs cartesian default ~91%)
145
+ // because the grid is not square so the eye needs heavier cues to follow
146
+ blend : 60 ,
147
+ showLine : true ,
148
+ showGrid : true ,
149
+ noZeroLine : true ,
150
+ attributes : layoutAttributes [ axName ]
151
+ } ) ;
152
+
153
+ coerceAxis ( 'layer' ) ;
116
154
}
117
155
156
+ coerceAxis ( 'hoverformat' ) ;
157
+
118
158
axOut . _input = axIn ;
119
159
}
120
160
}
@@ -151,47 +191,6 @@ function handleAxisTypeDefaults(axIn, axOut, coerce, subplotData, dataAttr) {
151
191
return axOut . type ;
152
192
}
153
193
154
- function handleAxisStyleDefaults ( axIn , axOut , coerce , opts ) {
155
- var dfltColor = coerce ( 'color' ) ;
156
- var dfltFontColor = ( dfltColor === axIn . color ) ? dfltColor : opts . font . color ;
157
-
158
- handleTickValueDefaults ( axIn , axOut , coerce , axOut . type ) ;
159
- handleTickLabelDefaults ( axIn , axOut , coerce , axOut . type , {
160
- noHover : false ,
161
- tickSuffixDflt : axOut . thetaunit === 'degrees' ? '°' : undefined
162
- } ) ;
163
- handleTickMarkDefaults ( axIn , axOut , coerce , { outerTicks : true } ) ;
164
-
165
- var showTickLabels = coerce ( 'showticklabels' ) ;
166
- if ( showTickLabels ) {
167
- Lib . coerceFont ( coerce , 'tickfont' , {
168
- family : opts . font . family ,
169
- size : opts . font . size ,
170
- color : dfltFontColor
171
- } ) ;
172
- coerce ( 'tickangle' ) ;
173
- coerce ( 'tickformat' ) ;
174
- }
175
-
176
- // TODO should use coerce2 pattern !!
177
-
178
- var showLine = coerce ( 'showline' ) ;
179
- if ( showLine ) {
180
- coerce ( 'linecolor' , dfltColor ) ;
181
- coerce ( 'linewidth' ) ;
182
- }
183
-
184
- var showGridLines = coerce ( 'showgrid' ) ;
185
- if ( showGridLines ) {
186
- // default grid color is darker here (60%, vs cartesian default ~91%)
187
- // because the grid is not square so the eye needs heavier cues to follow
188
- coerce ( 'gridcolor' , colorMix ( dfltColor , opts . bgColor , 60 ) . toRgbString ( ) ) ;
189
- coerce ( 'gridwidth' ) ;
190
- }
191
-
192
- coerce ( 'layer' ) ;
193
- }
194
-
195
194
module . exports = function supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) {
196
195
handleSubplotDefaults ( layoutIn , layoutOut , fullData , {
197
196
type : constants . name ,
0 commit comments