88
99'use strict' ;
1010
11- var colorMix = require ( 'tinycolor2' ) . mix ;
12-
1311var Lib = require ( '../../lib' ) ;
1412var Color = require ( '../../components/color' ) ;
1513var Plots = require ( '../plots' ) ;
@@ -20,6 +18,7 @@ var handleTickValueDefaults = require('../cartesian/tick_value_defaults');
2018var handleTickMarkDefaults = require ( '../cartesian/tick_mark_defaults' ) ;
2119var handleTickLabelDefaults = require ( '../cartesian/tick_label_defaults' ) ;
2220var handleCategoryOrderDefaults = require ( '../cartesian/category_order_defaults' ) ;
21+ var handleLineGridDefaults = require ( '../cartesian/line_grid_defaults' ) ;
2322var autoType = require ( '../cartesian/axis_autotype' ) ;
2423var orderedCategories = require ( '../cartesian/ordered_categories' ) ;
2524var setConvert = require ( '../cartesian/set_convert' ) ;
@@ -69,10 +68,17 @@ function handleDefaults(contIn, contOut, coerce, opts) {
6968 handleCalendarDefaults ( axIn , axOut , 'calendar' , layoutOut . calendar ) ;
7069 }
7170
72- coerceAxis ( 'visible' ) ;
73-
71+ var visible = coerceAxis ( 'visible' ) ;
7472 setConvert ( axOut , layoutOut ) ;
7573
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+
7682 // We don't want to make downstream code call ax.setScale,
7783 // as both radial and angular axes don't have a set domain.
7884 // Furthermore, angular axes don't have a set range.
@@ -89,11 +95,13 @@ function handleDefaults(contIn, contOut, coerce, opts) {
8995 coerceAxis ( 'range' ) ;
9096 axOut . cleanRange ( 'range' , { dfltRange : [ 0 , 1 ] } ) ;
9197
92- if ( axOut . visible ) {
98+ if ( visible ) {
9399 coerceAxis ( 'side' ) ;
94100 coerceAxis ( 'position' , sector [ 0 ] ) ;
101+
95102 }
96103 break ;
104+
97105 case 'angularaxis' :
98106 if ( axType === 'linear' ) {
99107 coerceAxis ( 'thetaunit' ) ;
@@ -111,10 +119,42 @@ function handleDefaults(contIn, contOut, coerce, opts) {
111119 break ;
112120 }
113121
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' ) ;
116154 }
117155
156+ coerceAxis ( 'hoverformat' ) ;
157+
118158 axOut . _input = axIn ;
119159 }
120160}
@@ -151,47 +191,6 @@ function handleAxisTypeDefaults(axIn, axOut, coerce, subplotData, dataAttr) {
151191 return axOut . type ;
152192}
153193
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-
195194module . exports = function supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) {
196195 handleSubplotDefaults ( layoutIn , layoutOut , fullData , {
197196 type : constants . name ,
0 commit comments