Javascript 海图图例';启用';功能不工作
下面是我为Highchart编写的脚本,用于在特定条件下启用/禁用图例。但它不起作用Javascript 海图图例';启用';功能不工作,javascript,highcharts,Javascript,Highcharts,下面是我为Highchart编写的脚本,用于在特定条件下启用/禁用图例。但它不起作用 legend: { layout: 'horizontal', itemStyle: { color: '#333333', cursor: 'none', fontSize: '10px', fontWeight: 'normal' }, labelFormatter: functio
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,他们都是对的,由你决定