@@ -187,6 +187,7 @@ module.exports = function draw(gd, id) {
187187 titlefont : opts . titlefont ,
188188 showline : true ,
189189 anchor : 'free' ,
190+ side : 'right' ,
190191 position : 1
191192 } ,
192193 cbAxisOut = {
@@ -281,7 +282,8 @@ module.exports = function draw(gd, id) {
281282 Math . round ( gs . l ) + ',-' +
282283 Math . round ( gs . t ) + ')' ) ;
283284
284- cbAxisOut . _axislayer = container . select ( '.cbaxis' ) ;
285+ var axisLayer = container . select ( '.cbaxis' ) ;
286+
285287 var titleHeight = 0 ;
286288 if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) !== - 1 ) {
287289 // draw the title so we know how much room it needs
@@ -357,8 +359,7 @@ module.exports = function draw(gd, id) {
357359 . attr ( 'transform' , 'translate(0,' +
358360 Math . round ( gs . h * ( 1 - cbAxisOut . domain [ 1 ] ) ) + ')' ) ;
359361
360- cbAxisOut . _axislayer . attr ( 'transform' , 'translate(0,' +
361- Math . round ( - gs . t ) + ')' ) ;
362+ axisLayer . attr ( 'transform' , 'translate(0,' + Math . round ( - gs . t ) + ')' ) ;
362363
363364 var fills = container . select ( '.cbfills' )
364365 . selectAll ( 'rect.cbfill' )
@@ -425,20 +426,37 @@ module.exports = function draw(gd, id) {
425426 } ) ;
426427
427428 // force full redraw of labels and ticks
428- cbAxisOut . _axislayer . selectAll ( 'g.' + cbAxisOut . _id + 'tick,path' )
429- . remove ( ) ;
430-
431- cbAxisOut . _pos = xLeft + thickPx +
432- ( opts . outlinewidth || 0 ) / 2 - ( opts . ticks === 'outside' ? 1 : 0 ) ;
433- cbAxisOut . side = 'right' ;
429+ axisLayer . selectAll ( 'g.' + cbAxisOut . _id + 'tick,path' ) . remove ( ) ;
434430
435431 // separate out axis and title drawing,
436432 // so we don't need such complicated logic in Titles.draw
437433 // if title is on the top or bottom, we've already drawn it
438434 // this title call only handles side=right
439435 return Lib . syncOrAsync ( [
440436 function ( ) {
441- return Axes . doTicksSingle ( gd , cbAxisOut , true ) ;
437+ var shift = xLeft + thickPx +
438+ ( opts . outlinewidth || 0 ) / 2 - ( opts . ticks === 'outside' ? 1 : 0 ) ;
439+
440+ var vals = Axes . calcTicks ( cbAxisOut ) ;
441+ var transFn = Axes . makeTransFn ( cbAxisOut ) ;
442+ var labelFns = Axes . makeLabelFns ( cbAxisOut , shift ) ;
443+ var tickSign = Axes . getTickSigns ( cbAxisOut ) [ 2 ] ;
444+
445+ Axes . drawTicks ( gd , cbAxisOut , {
446+ vals : cbAxisOut . ticks === 'inside' ? Axes . clipEnds ( cbAxisOut , vals ) : vals ,
447+ layer : axisLayer ,
448+ path : Axes . makeTickPath ( cbAxisOut , shift , tickSign ) ,
449+ transFn : transFn
450+ } ) ;
451+
452+ return Axes . drawLabels ( gd , cbAxisOut , {
453+ vals : vals ,
454+ layer : axisLayer ,
455+ transFn : transFn ,
456+ labelXFn : labelFns . labelXFn ,
457+ labelYFn : labelFns . labelYFn ,
458+ labelAnchorFn : labelFns . labelAnchorFn
459+ } ) ;
442460 } ,
443461 function ( ) {
444462 if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) === - 1 ) {
@@ -499,7 +517,7 @@ module.exports = function draw(gd, id) {
499517 // TODO: why are we redrawing multiple times now with this?
500518 // I guess autoMargin doesn't like being post-promise?
501519 var innerWidth = thickPx + opts . outlinewidth / 2 +
502- Drawing . bBox ( cbAxisOut . _axislayer . node ( ) ) . width ;
520+ Drawing . bBox ( axisLayer . node ( ) ) . width ;
503521 titleEl = titleCont . select ( 'text' ) ;
504522 if ( titleEl . node ( ) && ! titleEl . classed ( cn . jsPlaceholder ) ) {
505523 var mathJaxNode = titleCont
0 commit comments