@@ -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 } ,
@@ -709,7 +715,8 @@ $(function() {
709715 export : function ( ) {
710716 return { title : this . title , xlabel : this . xlabel , ylabel : this . ylabel , opacity : this . opacity ,
711717 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 }
718+ ymax : this . ymax , combined : this . combined , locked : this . locked , color_trace : this . color_trace ,
719+ show_legend : this . show_legend }
713720 } ,
714721
715722 import : function ( data ) {
@@ -752,6 +759,11 @@ $(function() {
752759 if ( "color_trace" in data ) {
753760 this . toggle_color_trace ( data . color_trace ) ;
754761 d3 . select ( "#color-trace-checkbox" ) . property ( "checked" , data . color_trace )
762+ } ;
763+
764+ if ( "show_legend" ) {
765+ this . toggle_legend ( data . show_legend ) ;
766+ d3 . select ( "#show-legend-checkbox" ) . property ( "checked" , data . show_legend )
755767 }
756768 } ,
757769
0 commit comments