@@ -1740,6 +1740,13 @@ describe('legend interaction', function() {
1740
1740
} ;
1741
1741
}
1742
1742
1743
+ function assertVisibleShapes ( expectation ) {
1744
+ return function ( ) {
1745
+ var actual = extractVisibilities ( gd . _fullLayout . shapes ) ;
1746
+ expect ( actual ) . toEqual ( expectation ) ;
1747
+ } ;
1748
+ }
1749
+
1743
1750
describe ( 'for regular traces' , function ( ) {
1744
1751
beforeEach ( function ( done ) {
1745
1752
Plotly . newPlot ( gd , [
@@ -1782,6 +1789,34 @@ describe('legend interaction', function() {
1782
1789
} ) ;
1783
1790
} ) ;
1784
1791
1792
+ describe ( 'click shape legends' , function ( ) {
1793
+ beforeEach ( function ( done ) {
1794
+ Plotly . newPlot ( gd , [ ] , {
1795
+ shapes : [
1796
+ { showlegend : true , type : 'line' , xref : 'paper' , yref : 'paper' , x0 : 0.1 , y0 : 0.2 , x1 : 0.2 , y1 : 0.1 , visible : false } ,
1797
+ { showlegend : true , type : 'line' , xref : 'paper' , yref : 'paper' , x0 : 0.3 , y0 : 0.4 , x1 : 0.4 , y1 : 0.3 , visible : 'legendonly' } ,
1798
+ { showlegend : true , type : 'line' , xref : 'paper' , yref : 'paper' , x0 : 0.5 , y0 : 0.6 , x1 : 0.6 , y1 : 0.5 }
1799
+ ]
1800
+ } ) . then ( done ) ;
1801
+ } ) ;
1802
+
1803
+ it ( 'clicking once toggles legendonly -> true' , function ( done ) {
1804
+ Promise . resolve ( )
1805
+ . then ( assertVisibleShapes ( [ false , 'legendonly' , true ] ) )
1806
+ . then ( click ( 0 ) )
1807
+ . then ( assertVisibleShapes ( [ false , true , true ] ) )
1808
+ . then ( done , done . fail ) ;
1809
+ } ) ;
1810
+
1811
+ it ( 'clicking once toggles true -> legendonly' , function ( done ) {
1812
+ Promise . resolve ( )
1813
+ . then ( assertVisibleShapes ( [ false , 'legendonly' , true ] ) )
1814
+ . then ( click ( 1 ) )
1815
+ . then ( assertVisibleShapes ( [ false , 'legendonly' , 'legendonly' ] ) )
1816
+ . then ( done , done . fail ) ;
1817
+ } ) ;
1818
+ } ) ;
1819
+
1785
1820
describe ( 'legendgroup visibility' , function ( ) {
1786
1821
beforeEach ( function ( done ) {
1787
1822
Plotly . newPlot ( gd , [ {
0 commit comments