@@ -207,9 +207,48 @@ proto.updateLayout = function(fullLayout, polarLayout) {
207207 var cxx = _this . cxx = cx - xOffset2 ;
208208 var cyy = _this . cyy = cy - yOffset2 ;
209209
210+ var mockOpts = {
211+ // to get _boundingBox computation right when showticklabels is false
212+ anchor : 'free' ,
213+ position : 0 ,
214+ // dummy truthy value to make Axes.doTicksSingle draw the grid
215+ _counteraxis : true ,
216+ // don't use automargins routine for labels
217+ automargin : false
218+ } ;
219+
220+ _this . radialAxis = Lib . extendFlat ( { } , polarLayout . radialaxis , mockOpts , {
221+ _axislayer : layers [ 'radial-axis' ] ,
222+ _gridlayer : layers [ 'radial-grid' ] ,
223+ // make this an 'x' axis to make positioning (especially rotation) easier
224+ _id : 'x' ,
225+ _pos : 0 ,
226+ // convert to 'x' axis equivalent
227+ side : {
228+ counterclockwise : 'top' ,
229+ clockwise : 'bottom'
230+ } [ polarLayout . radialaxis . side ] ,
231+ // spans length 1 radius
232+ domain : [ 0 , radius / gs . w ]
233+ } ) ;
234+
235+ _this . angularAxis = Lib . extendFlat ( { } , polarLayout . angularaxis , mockOpts , {
236+ _axislayer : layers [ 'angular-axis' ] ,
237+ _gridlayer : layers [ 'angular-grid' ] ,
238+ // angular axes need *special* logic
239+ _id : 'angular' ,
240+ _pos : 0 ,
241+ side : 'right' ,
242+ // to get auto nticks right
243+ domain : [ 0 , Math . PI ] ,
244+ // don't pass through autorange logic
245+ autorange : false
246+ } ) ;
247+
248+ _this . doAutoRange ( fullLayout , polarLayout ) ;
249+ _this . updateAngularAxis ( fullLayout , polarLayout ) ;
210250 _this . updateRadialAxis ( fullLayout , polarLayout ) ;
211251 _this . updateRadialAxisTitle ( fullLayout , polarLayout ) ;
212- _this . updateAngularAxis ( fullLayout , polarLayout ) ;
213252
214253 var radialRange = _this . radialAxis . range ;
215254 var rSpan = radialRange [ 1 ] - radialRange [ 0 ] ;
@@ -253,49 +292,30 @@ proto.updateLayout = function(fullLayout, polarLayout) {
253292 _this . framework . selectAll ( '.crisp' ) . classed ( 'crisp' , 0 ) ;
254293} ;
255294
295+ proto . doAutoRange = function ( fullLayout , polarLayout ) {
296+ var radialLayout = polarLayout . radialaxis ;
297+ var ax = this . radialAxis ;
298+
299+ setScale ( ax , radialLayout , fullLayout ) ;
300+ doAutoRange ( ax ) ;
301+
302+ radialLayout . range = ax . range . slice ( ) ;
303+ radialLayout . _input . range = ax . range . slice ( ) ;
304+ } ;
305+
256306proto . updateRadialAxis = function ( fullLayout , polarLayout ) {
257307 var _this = this ;
258308 var gd = _this . gd ;
259309 var layers = _this . layers ;
260310 var radius = _this . radius ;
261311 var cx = _this . cx ;
262312 var cy = _this . cy ;
263- var gs = fullLayout . _size ;
264313 var radialLayout = polarLayout . radialaxis ;
265314 var sector = polarLayout . sector ;
266315 var a0 = wrap360 ( sector [ 0 ] ) ;
316+ var ax = _this . radialAxis ;
267317
268318 _this . fillViewInitialKey ( 'radialaxis.angle' , radialLayout . angle ) ;
269-
270- var ax = _this . radialAxis = Lib . extendFlat ( { } , radialLayout , {
271- _axislayer : layers [ 'radial-axis' ] ,
272- _gridlayer : layers [ 'radial-grid' ] ,
273-
274- // make this an 'x' axis to make positioning (especially rotation) easier
275- _id : 'x' ,
276- _pos : 0 ,
277-
278- // convert to 'x' axis equivalent
279- side : { counterclockwise : 'top' , clockwise : 'bottom' } [ radialLayout . side ] ,
280-
281- // spans length 1 radius
282- domain : [ 0 , radius / gs . w ] ,
283-
284- // to get _boundingBox computation right when showticklabels is false
285- anchor : 'free' ,
286- position : 0 ,
287-
288- // dummy truthy value to make Axes.doTicksSingle draw the grid
289- _counteraxis : true ,
290-
291- // don't use automargins routine for labels
292- automargin : false
293- } ) ;
294-
295- setScale ( ax , radialLayout , fullLayout ) ;
296- doAutoRange ( ax ) ;
297- radialLayout . range = ax . range . slice ( ) ;
298- radialLayout . _input . range = ax . range . slice ( ) ;
299319 _this . fillViewInitialKey ( 'radialaxis.range' , ax . range . slice ( ) ) ;
300320
301321 // rotate auto tick labels by 180 if in quadrant II and III to make them
@@ -393,34 +413,20 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) {
393413 var angularLayout = polarLayout . angularaxis ;
394414 var sector = polarLayout . sector ;
395415 var sectorInRad = sector . map ( deg2rad ) ;
416+ var ax = _this . angularAxis ;
396417
397418 _this . fillViewInitialKey ( 'angularaxis.rotation' , angularLayout . rotation ) ;
398419
399- var ax = _this . angularAxis = Lib . extendFlat ( { } , angularLayout , {
400- _axislayer : layers [ 'angular-axis' ] ,
401- _gridlayer : layers [ 'angular-grid' ] ,
402-
403- // angular axes need *special* logic
404- _id : 'angular' ,
405- _pos : 0 ,
406- side : 'right' ,
407-
408- // to get auto nticks right
409- domain : [ 0 , Math . PI ] ,
410-
411- // to get _boundingBox computation right when showticklabels is false
412- anchor : 'free' ,
413- position : 0 ,
414-
415- // dummy truthy value to make Axes.doTicksSingle draw the grid
416- _counteraxis : true ,
417-
418- // don't use automargins routine for labels
419- automargin : false ,
420+ // wrapper around c2rad from setConvertAngular
421+ // note that linear ranges are always set in degrees for Axes.doTicksSingle
422+ function c2rad ( d ) {
423+ return ax . c2rad ( d . x , 'degrees' ) ;
424+ }
420425
421- // don't pass through autorange logic
422- autorange : false
423- } ) ;
426+ // (x,y) at max radius
427+ function rad2xy ( rad ) {
428+ return [ radius * Math . cos ( rad ) , radius * Math . sin ( rad ) ] ;
429+ }
424430
425431 // Set the angular range in degrees to make auto-tick computation cleaner,
426432 // changing rotation/direction should not affect the angular tick labels.
@@ -458,17 +464,6 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) {
458464
459465 setScale ( ax , angularLayout , fullLayout ) ;
460466
461- // wrapper around c2rad from setConvertAngular
462- // note that linear ranges are always set in degrees for Axes.doTicksSingle
463- function c2rad ( d ) {
464- return ax . c2rad ( d . x , 'degrees' ) ;
465- }
466-
467- // (x,y) at max radius
468- function rad2xy ( rad ) {
469- return [ radius * Math . cos ( rad ) , radius * Math . sin ( rad ) ] ;
470- }
471-
472467 ax . _transfn = function ( d ) {
473468 var rad = c2rad ( d ) ;
474469 var xy = rad2xy ( rad ) ;
0 commit comments