sxmpasch commented on issue #9308: disable a serie by default
URL: 
https://github.com/apache/incubator-echarts/issues/9308#issuecomment-434445368
 
 
   1.
   Yes, have a look at legend.selected option for disabling/enabling a single 
series.
   E.g. take example 
https://ecomfe.github.io/echarts-examples/public/editor.html?c=bar-label-rotation
   and fill in e.g.
   ```
       legend: {
           data: ['Forest', 'Steppe', 'Desert', 'Wetland'],
           selected:{'Forest':false, 'Steppe':true,'Desert':false},
       },
   
   ```
   
   2.
   Yes, this would be possible as well. To demonstrate, I take the example 
mentioned above.
   Add a variable outside of option:
   ```
   var showLegend=true;
   
   ```
   
   Then you simply can add a custom button to the toolbox:
   ```
       toolbox: {
           show: true,
           orient: 'vertical',
           left: 'right',
           top: 'center',
           feature: {
               mark: {show: true},
               dataView: {show: true, readOnly: false},
               magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
               restore: {show: true},
               saveAsImage: {show: true},
               myTool1: {
                   show: true,
                   title: 'show/hide legend',
                   icon: 
'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z
 
M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z
 
M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
                   onclick: function (){
                       showLegend = (showLegend)?false:true;
                       myChart.setOption(
                           { legend: { show:showLegend }}
                       )
                   }
               },
           }
       },
   
   
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@echarts.apache.org
For additional commands, e-mail: dev-h...@echarts.apache.org

Reply via email to