2014-04-01 165 views
1

我有一个高图,并使用导出功能创建导出生成的图片。仅在导出中过滤仅可见系列的Highcharts图例

我该如何让隐藏系列的图例在出口中完全不显示(我不希望它们变灰)? 我试过这个,但它只隐藏文本,符号仍然存在。

exporting: { //the export button 
     type: 'image/jpeg', 
     chartOptions: { 
      legend: { 
       enabled: true, 
       itemHiddenStyle: { 
        display: 'none', 
       } 
      } 
     } 

    },... 

我也看到了这样的回答:Filtering legend of a Highcharts by only visible series 但我需要它只有在出口完成。这也会将它从屏幕上移除。

回答

4

在你的情况下,你会有空的项目,更好的是使用负载事件和摧毁系列是不可见的。

exporting: { //the export button 
     type: 'image/jpeg', 
     chartOptions: { 
      chart: { 
       events: { 
        load: function() { 
          var chart = this; 

          $.each(chart.series,function(i,serie) { 
           if(!serie.visible) { 
            serie.update({ 
             showInLegend:false 
            }); 
           } 
          }); 
        } 
       } 
      } 
     } 

    }, 

见例如:http://jsfiddle.net/DMJf5/3/