@@ -451,19 +451,21 @@ legend.draw = function(td) {
451
451
var legendsvg = fullLayout . _infolayer . selectAll ( 'svg.legend' )
452
452
. data ( [ 0 ] ) ;
453
453
legendsvg . enter ( ) . append ( 'svg' )
454
- . attr ( 'class' , 'legend' )
455
- . attr ( 'pointer-events' , 'all' ) ;
454
+ . attr ( {
455
+ 'class' : 'legend' ,
456
+ 'pointer-events' : 'all'
457
+ } ) ;
456
458
457
459
var bg = legendsvg . selectAll ( 'rect.bg' )
458
460
. data ( [ 0 ] ) ;
459
461
bg . enter ( ) . append ( 'rect' )
460
- . attr ( 'class' , 'bg' )
462
+ . attr ( {
463
+ 'class' : 'bg' ,
464
+ 'shape-rendering' : 'crispEdges'
465
+ } )
461
466
. call ( Color . stroke , opts . bordercolor )
462
467
. 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' ) ;
467
469
468
470
var scrollBox = legendsvg . selectAll ( 'g.scrollbox' )
469
471
. data ( [ 0 ] ) ;
@@ -584,13 +586,21 @@ legend.draw = function(td) {
584
586
scrollheight = Math . min ( plotHeight - ly , opts . height ) ,
585
587
scrollPosition = scrollBox . attr ( 'data-scroll' ) ? scrollBox . attr ( 'data-scroll' ) : 0 ;
586
588
587
- bg . attr ( { width : opts . width , height : scrollheight } ) ;
588
589
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
+ } ) ;
589
596
590
597
legendsvg . call ( Drawing . setRect , lx , ly , opts . width , scrollheight ) ;
591
598
599
+ // If scrollbar should be shown.
592
600
if ( td . firstRender && opts . height - scrollheight > 0 && ! td . _context . staticPlot ) {
593
601
602
+ bg . attr ( { width : opts . width - 2 * opts . borderwidth + constants . scrollBarWidth } ) ;
603
+
594
604
legendsvg . node ( ) . addEventListener ( 'wheel' , function ( e ) {
595
605
e . preventDefault ( ) ;
596
606
scrollHandler ( e . deltaY / 20 ) ;
0 commit comments