[英]How to hide/disable the legend box in Highcharts.js?
我想問一下是否可以使用HighCharts.js庫隱藏圖表中的所有圖例框?
var chart_object = {
chart: {
renderTo: render_to,
type: graph_type
},
colors:graph_colors,
title: {
text: ''
},
xAxis: {
min: 0,
title: {
text: x_axis.title,
margin: 15
},
categories: categories,
},
(...)
};
// Create the chart
var chart = new Highcharts.Chart(chart_object);
任何幫助將不勝感激。
好吧,我發現這樣做最簡單的方法就是將圖例屬性添加到chart_object並將enabled設置為false:示例:
var chart_object = {
chart: {
renderTo: render_to,
type: graph_type
},
legend:{ enabled:false },
colors:graph_colors,
(...)
如果您需要動態執行此操作,則可以使用此解決方案
$('#updateLegend').click(function (e) {
var legend = chart.legend;
if(legend.display) {
legend.group.hide();
legend.box.hide();
legend.display = false;
} else {
legend.group.show();
legend.box.show();
legend.display = true;
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.