@@ -187,6 +187,7 @@ module.exports = function draw(gd, id) {
187
187
titlefont : opts . titlefont ,
188
188
showline : true ,
189
189
anchor : 'free' ,
190
+ side : 'right' ,
190
191
position : 1
191
192
} ,
192
193
cbAxisOut = {
@@ -281,7 +282,8 @@ module.exports = function draw(gd, id) {
281
282
Math . round ( gs . l ) + ',-' +
282
283
Math . round ( gs . t ) + ')' ) ;
283
284
284
- cbAxisOut . _axislayer = container . select ( '.cbaxis' ) ;
285
+ var axisLayer = container . select ( '.cbaxis' ) ;
286
+
285
287
var titleHeight = 0 ;
286
288
if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) !== - 1 ) {
287
289
// draw the title so we know how much room it needs
@@ -357,8 +359,7 @@ module.exports = function draw(gd, id) {
357
359
. attr ( 'transform' , 'translate(0,' +
358
360
Math . round ( gs . h * ( 1 - cbAxisOut . domain [ 1 ] ) ) + ')' ) ;
359
361
360
- cbAxisOut . _axislayer . attr ( 'transform' , 'translate(0,' +
361
- Math . round ( - gs . t ) + ')' ) ;
362
+ axisLayer . attr ( 'transform' , 'translate(0,' + Math . round ( - gs . t ) + ')' ) ;
362
363
363
364
var fills = container . select ( '.cbfills' )
364
365
. selectAll ( 'rect.cbfill' )
@@ -425,20 +426,37 @@ module.exports = function draw(gd, id) {
425
426
} ) ;
426
427
427
428
// 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 ( ) ;
434
430
435
431
// separate out axis and title drawing,
436
432
// so we don't need such complicated logic in Titles.draw
437
433
// if title is on the top or bottom, we've already drawn it
438
434
// this title call only handles side=right
439
435
return Lib . syncOrAsync ( [
440
436
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
+ } ) ;
442
460
} ,
443
461
function ( ) {
444
462
if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) === - 1 ) {
@@ -499,7 +517,7 @@ module.exports = function draw(gd, id) {
499
517
// TODO: why are we redrawing multiple times now with this?
500
518
// I guess autoMargin doesn't like being post-promise?
501
519
var innerWidth = thickPx + opts . outlinewidth / 2 +
502
- Drawing . bBox ( cbAxisOut . _axislayer . node ( ) ) . width ;
520
+ Drawing . bBox ( axisLayer . node ( ) ) . width ;
503
521
titleEl = titleCont . select ( 'text' ) ;
504
522
if ( titleEl . node ( ) && ! titleEl . classed ( cn . jsPlaceholder ) ) {
505
523
var mathJaxNode = titleCont
0 commit comments