Javascript 如何禁用图例单击以阻止饼图在 Highcharts 中消失?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7833385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:46:06  来源:igfitidea点击:

How to disable legend click to stop pie slice from disappearing in Highcharts?

javascripthighcharts

提问by highchartsdude

How to disable legend click to stop pie slice from disappearing in Highcharts??

如何禁用图例单击以阻止饼图在 Highcharts 中消失?

See example here:

请参阅此处的示例:

http://www.highcharts.com/demo/pie-legend

http://www.highcharts.com/demo/pie-legend

Can anyone help??

有人可以帮忙吗??

回答by eolsson

You do this by attaching a handler to the legendItemClickevent and just returning false. This will prevent the default action which is to toggle the pie sector.

您可以通过将处理程序附加到legendItemClick事件并返回false. 这将阻止切换饼图扇区的默认操作。

point: {
    events: {
        legendItemClick: function () {
            return false; // <== returning false will cancel the default action
        }
    }
}

See this example http://jsfiddle.net/mfras3r/3vVGB/1/

请参阅此示例http://jsfiddle.net/mfras3r/3vVGB/1/

回答by Joseph Lim Shuo Yan

pie: {
   showInLegend: true,
   allowPointSelect: false,
   point:{
       events : {
        legendItemClick: function(e){
            e.preventDefault();
        }
       }
   }
 }

回答by mamian

pie: {
   showInLegend: true,
   allowPointSelect: false,  // disable selected
}