Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 海图图例';启用';功能不工作_Javascript_Highcharts - Fatal编程技术网

Javascript 海图图例';启用';功能不工作

Javascript 海图图例';启用';功能不工作,javascript,highcharts,Javascript,Highcharts,下面是我为Highchart编写的脚本,用于在特定条件下启用/禁用图例。但它不起作用 legend: { layout: 'horizontal', itemStyle: { color: '#333333', cursor: 'none', fontSize: '10px', fontWeight: 'normal' }, labelFormatter: functio

下面是我为Highchart编写的脚本,用于在特定条件下启用/禁用图例。但它不起作用

               legend: {
                layout: 'horizontal',
                itemStyle: { color: '#333333', cursor: 'none', fontSize: '10px', fontWeight: 'normal' },
                labelFormatter: function () {
                    return this.name;
                },
                enabled: function () {
                    if (ChartType == "column") {
                        return true;
                    } else {
                        return false;
                    }
                }
            },

看起来函数根本没有调用。如果我提到'enabled:true',它就可以正常工作。。请提供帮助。

启用的
类型是布尔值,因此无法将其设置为函数


最好将条件转换为Highchart后处理:

var type = 'show', display = true;
if (ChartType == "column") {
    type = 'hide';
    display = false;
}

chart.legend.group[type]();
chart.legend.box[type]();
chart.legend.display = display;
chart.legend.render();

哦正确的。你们有什么办法可以建议吗?你们可以声明一个变量,比如enable,你们可以将默认值设为false,你们可以在处理图表之前声明一个函数运行
function(){if(ChartType==“column”){enable=true;}else{enable=false;}
Thnq.Answer/Comment by@VõMinh Phong.fixissue@SandeepMogaveer,他们都是对的,由你决定