@@ -312,7 +312,7 @@ module.exports = function draw(gd) {
312
312
} ) ;
313
313
}
314
314
315
- if ( gd . _context . editable ) {
315
+ if ( gd . _context . edits . legendPosition ) {
316
316
var xf , yf , x0 , y0 ;
317
317
318
318
legend . classed ( 'cursor-move' , true ) ;
@@ -385,7 +385,7 @@ function drawTexts(g, gd) {
385
385
} ) ;
386
386
}
387
387
388
- if ( gd . _context . editable && ! isPie ) {
388
+ if ( gd . _context . edits . legendText && ! isPie ) {
389
389
text . call ( svgTextUtils . makeEditable , { gd : gd } )
390
390
. call ( textLayout )
391
391
. on ( 'edit' , function ( text ) {
@@ -597,10 +597,15 @@ function computeTextDimensions(g, gd) {
597
597
}
598
598
599
599
function computeLegendDimensions ( gd , groups , traces ) {
600
- var fullLayout = gd . _fullLayout ,
601
- opts = fullLayout . legend ,
602
- borderwidth = opts . borderwidth ,
603
- isGrouped = helpers . isGrouped ( opts ) ;
600
+ var fullLayout = gd . _fullLayout ;
601
+ var opts = fullLayout . legend ;
602
+ var borderwidth = opts . borderwidth ;
603
+ var isGrouped = helpers . isGrouped ( opts ) ;
604
+
605
+ var extraWidth = 0 ;
606
+
607
+ opts . width = 0 ;
608
+ opts . height = 0 ;
604
609
605
610
if ( helpers . isVertical ( opts ) ) {
606
611
if ( isGrouped ) {
@@ -609,9 +614,6 @@ function computeLegendDimensions(gd, groups, traces) {
609
614
} ) ;
610
615
}
611
616
612
- opts . width = 0 ;
613
- opts . height = 0 ;
614
-
615
617
traces . each ( function ( d ) {
616
618
var legendItem = d [ 0 ] ,
617
619
textHeight = legendItem . height ,
@@ -632,26 +634,9 @@ function computeLegendDimensions(gd, groups, traces) {
632
634
opts . height += ( opts . _lgroupsLength - 1 ) * opts . tracegroupgap ;
633
635
}
634
636
635
- // make sure we're only getting full pixels
636
- opts . width = Math . ceil ( opts . width ) ;
637
- opts . height = Math . ceil ( opts . height ) ;
638
-
639
- traces . each ( function ( d ) {
640
- var legendItem = d [ 0 ] ,
641
- bg = d3 . select ( this ) . select ( '.legendtoggle' ) ;
642
-
643
- bg . call ( Drawing . setRect ,
644
- 0 ,
645
- - legendItem . height / 2 ,
646
- ( gd . _context . editable ? 0 : opts . width ) + 40 ,
647
- legendItem . height
648
- ) ;
649
- } ) ;
637
+ extraWidth = 40 ;
650
638
}
651
639
else if ( isGrouped ) {
652
- opts . width = 0 ;
653
- opts . height = 0 ;
654
-
655
640
var groupXOffsets = [ opts . width ] ,
656
641
groupData = groups . data ( ) ;
657
642
@@ -692,26 +677,8 @@ function computeLegendDimensions(gd, groups, traces) {
692
677
693
678
opts . height += 10 + borderwidth * 2 ;
694
679
opts . width += borderwidth * 2 ;
695
-
696
- // make sure we're only getting full pixels
697
- opts . width = Math . ceil ( opts . width ) ;
698
- opts . height = Math . ceil ( opts . height ) ;
699
-
700
- traces . each ( function ( d ) {
701
- var legendItem = d [ 0 ] ,
702
- bg = d3 . select ( this ) . select ( '.legendtoggle' ) ;
703
-
704
- bg . call ( Drawing . setRect ,
705
- 0 ,
706
- - legendItem . height / 2 ,
707
- ( gd . _context . editable ? 0 : opts . width ) ,
708
- legendItem . height
709
- ) ;
710
- } ) ;
711
680
}
712
681
else {
713
- opts . width = 0 ;
714
- opts . height = 0 ;
715
682
var rowHeight = 0 ,
716
683
maxTraceHeight = 0 ,
717
684
maxTraceWidth = 0 ,
@@ -750,22 +717,23 @@ function computeLegendDimensions(gd, groups, traces) {
750
717
opts . width += borderwidth * 2 ;
751
718
opts . height += 10 + borderwidth * 2 ;
752
719
753
- // make sure we're only getting full pixels
754
- opts . width = Math . ceil ( opts . width ) ;
755
- opts . height = Math . ceil ( opts . height ) ;
720
+ }
756
721
757
- traces . each ( function ( d ) {
758
- var legendItem = d [ 0 ] ,
759
- bg = d3 . select ( this ) . select ( '.legendtoggle' ) ;
722
+ // make sure we're only getting full pixels
723
+ opts . width = Math . ceil ( opts . width ) ;
724
+ opts . height = Math . ceil ( opts . height ) ;
760
725
761
- bg . call ( Drawing . setRect ,
762
- 0 ,
763
- - legendItem . height / 2 ,
764
- ( gd . _context . editable ? 0 : opts . width ) ,
765
- legendItem . height
766
- ) ;
767
- } ) ;
768
- }
726
+ traces . each ( function ( d ) {
727
+ var legendItem = d [ 0 ] ,
728
+ bg = d3 . select ( this ) . select ( '.legendtoggle' ) ;
729
+
730
+ bg . call ( Drawing . setRect ,
731
+ 0 ,
732
+ - legendItem . height / 2 ,
733
+ ( gd . _context . edits . legendText ? 0 : opts . width ) + extraWidth ,
734
+ legendItem . height
735
+ ) ;
736
+ } ) ;
769
737
}
770
738
771
739
function expandMargin ( gd ) {
0 commit comments