@@ -451,19 +451,21 @@ legend.draw = function(td) {
451451 var legendsvg = fullLayout . _infolayer . selectAll ( 'svg.legend' )
452452 . data ( [ 0 ] ) ;
453453 legendsvg . enter ( ) . append ( 'svg' )
454- . attr ( 'class' , 'legend' )
455- . attr ( 'pointer-events' , 'all' ) ;
454+ . attr ( {
455+ 'class' : 'legend' ,
456+ 'pointer-events' : 'all'
457+ } ) ;
456458
457459 var bg = legendsvg . selectAll ( 'rect.bg' )
458460 . data ( [ 0 ] ) ;
459461 bg . enter ( ) . append ( 'rect' )
460- . attr ( 'class' , 'bg' )
462+ . attr ( {
463+ 'class' : 'bg' ,
464+ 'shape-rendering' : 'crispEdges'
465+ } )
461466 . call ( Color . stroke , opts . bordercolor )
462467 . call ( Color . fill , opts . bgcolor )
463- . style ( {
464- 'stroke-width' : opts . borderwidth + 'px' ,
465- 'box-sizing' : 'border-box'
466- } ) ;
468+ . style ( 'stroke-width' , opts . borderwidth + 'px' ) ;
467469
468470 var scrollBox = legendsvg . selectAll ( 'g.scrollbox' )
469471 . data ( [ 0 ] ) ;
@@ -584,13 +586,21 @@ legend.draw = function(td) {
584586 scrollheight = Math . min ( plotHeight - ly , opts . height ) ,
585587 scrollPosition = scrollBox . attr ( 'data-scroll' ) ? scrollBox . attr ( 'data-scroll' ) : 0 ;
586588
587- bg . attr ( { width : opts . width , height : scrollheight } ) ;
588589 scrollBox . attr ( 'transform' , 'translate(0, ' + scrollPosition + ')' ) ;
590+ bg . attr ( {
591+ width : opts . width - 2 * opts . borderwidth ,
592+ height : scrollheight - 2 * opts . borderwidth ,
593+ x : opts . borderwidth ,
594+ y : opts . borderwidth
595+ } ) ;
589596
590597 legendsvg . call ( Drawing . setRect , lx , ly , opts . width , scrollheight ) ;
591598
599+ // If scrollbar should be shown.
592600 if ( td . firstRender && opts . height - scrollheight > 0 && ! td . _context . staticPlot ) {
593601
602+ bg . attr ( { width : opts . width - 2 * opts . borderwidth + constants . scrollBarWidth } ) ;
603+
594604 legendsvg . node ( ) . addEventListener ( 'wheel' , function ( e ) {
595605 e . preventDefault ( ) ;
596606 scrollHandler ( e . deltaY / 20 ) ;
0 commit comments