@@ -21,11 +21,13 @@ var Axes = require('../cartesian/axes');
2121var dragElement = require ( '../../components/dragelement' ) ;
2222var dragBox = require ( '../cartesian/dragbox' ) ;
2323var Fx = require ( '../../components/fx' ) ;
24+ var Titles = require ( '../../components/titles' ) ;
2425var prepSelect = require ( '../cartesian/select' ) ;
2526var setCursor = require ( '../../lib/setcursor' ) ;
2627
2728var MID_SHIFT = require ( '../../constants/alignment' ) . MID_SHIFT ;
2829
30+ var _ = Lib . _ ;
2931var deg2rad = Lib . deg2rad ;
3032var rad2deg = Lib . rad2deg ;
3133var wrap360 = Lib . wrap360 ;
@@ -203,6 +205,7 @@ proto.updateLayout = function(fullLayout, polarLayout) {
203205 var cy = _this . cy = yOffset2 + radius * sectorBBox [ 3 ] ;
204206
205207 _this . updateRadialAxis ( fullLayout , polarLayout ) ;
208+ _this . updateRadialAxisTitle ( fullLayout , polarLayout ) ;
206209 _this . updateAngularAxis ( fullLayout , polarLayout ) ;
207210
208211 var radialRange = _this . radialAxis . range ;
@@ -331,6 +334,42 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) {
331334 . call ( Color . stroke , radialLayout . linecolor ) ;
332335} ;
333336
337+ proto . updateRadialAxisTitle = function ( fullLayout , polarLayout , _angle ) {
338+ var _this = this ;
339+ var gd = _this . gd ;
340+ var radius = _this . radius ;
341+ var cx = _this . cx ;
342+ var cy = _this . cy ;
343+ var radialLayout = polarLayout . radialaxis ;
344+ var titleClass = _this . id + 'title' ;
345+
346+ var angle = _angle !== undefined ? _angle : radialLayout . position ;
347+ var angleRad = deg2rad ( angle ) ;
348+ var cosa = Math . cos ( angleRad ) ;
349+ var sina = Math . sin ( angleRad ) ;
350+
351+ var pad = 0 ;
352+ if ( radialLayout . title ) {
353+ var h = Drawing . bBox ( _this . layers [ 'radial-axis' ] . node ( ) ) . height ;
354+ var ts = radialLayout . titlefont . size ;
355+ pad = radialLayout . side === 'left' ?
356+ - h - ts * 0.4 :
357+ h + ts * 0.8 ;
358+ }
359+
360+ _this . layers [ 'radial-axis-title' ] = Titles . draw ( gd , titleClass , {
361+ propContainer : radialLayout ,
362+ propName : _this . id + '.radialaxis.title' ,
363+ placeholder : _ ( gd , 'Click to enter radial axis title' ) ,
364+ attributes : {
365+ x : cx + ( radius / 2 ) * cosa + pad * sina ,
366+ y : cy - ( radius / 2 ) * sina + pad * cosa ,
367+ 'text-anchor' : 'middle'
368+ } ,
369+ transform : { rotate : - angle }
370+ } ) ;
371+ } ;
372+
334373proto . updateAngularAxis = function ( fullLayout , polarLayout ) {
335374 var _this = this ;
336375 var gd = _this . gd ;
0 commit comments