@@ -19,6 +19,7 @@ $(function() {
1919 color_trace : false ,
2020 locked : false ,
2121 enable_tooltip : true ,
22+ show_legend : true ,
2223
2324 _elements : {
2425 main_plot : null ,
@@ -497,6 +498,11 @@ $(function() {
497498 . style ( "display" , d => d [ 1 ] )
498499 } ,
499500
501+ toggle_legend : function ( show ) {
502+ this . show_legend = show ;
503+ this . _elements . legend . style ( "display" , show ? null : "none" )
504+ } ,
505+
500506 change_label : function ( label , text ) {
501507 this [ label ] = text
502508 } ,
@@ -706,10 +712,18 @@ $(function() {
706712 a . dispatchEvent ( e )
707713 } ,
708714
715+ toggle_svg_button : function ( ) {
716+ let disable = this . _elements . main_plot . selectAll ( "foreignObject" ) . size ( ) > 0 ;
717+ d3 . select ( "#download-svg-button" )
718+ . property ( "disabled" , disable )
719+ . attr ( "title" , disable ? "Cannot download SVG while labels are being edited" : null )
720+ } ,
721+
709722 export : function ( ) {
710723 return { title : this . title , xlabel : this . xlabel , ylabel : this . ylabel , opacity : this . opacity ,
711724 smoothing : this . smoothing , bp_shift : this . bp_shift , xmin : this . xmin , xmax : this . xmax ,
712- ymax : this . ymax , combined : this . combined , locked : this . locked , color_trace : this . color_trace }
725+ ymax : this . ymax , combined : this . combined , locked : this . locked , color_trace : this . color_trace ,
726+ show_legend : this . show_legend }
713727 } ,
714728
715729 import : function ( data ) {
@@ -752,6 +766,11 @@ $(function() {
752766 if ( "color_trace" in data ) {
753767 this . toggle_color_trace ( data . color_trace ) ;
754768 d3 . select ( "#color-trace-checkbox" ) . property ( "checked" , data . color_trace )
769+ } ;
770+
771+ if ( "show_legend" ) {
772+ this . toggle_legend ( data . show_legend ) ;
773+ d3 . select ( "#show-legend-checkbox" ) . property ( "checked" , data . show_legend )
755774 }
756775 } ,
757776
@@ -826,7 +845,10 @@ $(function() {
826845
827846 this . foreign_object . select ( "input" )
828847 . on ( "keypress" , function ( e ) { $ ( label_group . node ( ) ) . editable_svg_text ( "enter_input" , e ) } )
829- . node ( ) . focus ( )
848+ . attr ( "title" , "Press enter to submit" )
849+ . node ( ) . focus ( ) ;
850+
851+ $ ( "#main-plot" ) . main_plot ( "toggle_svg_button" )
830852 } ,
831853
832854 enter_input : function ( ev ) {
@@ -837,7 +859,9 @@ $(function() {
837859 this . change_label ( ev . target . value )
838860 } else {
839861 this . text_label . style ( "display" , null )
840- }
862+ } ;
863+
864+ $ ( "#main-plot" ) . main_plot ( "toggle_svg_button" )
841865 }
842866 } ,
843867
0 commit comments