![](/img/trans.png)
[英]In Highcharts, how to redraw chart after legend item width resized?
[英]HighCharts line chart - How to prevent the deselection of the last legend item?
有沒有辦法防止隱藏折線圖中取消選擇的最后一個圖例項目?
我已經使用legendItemClick事件在柱形圖/餅圖上實現了它:
legendItemClick: function (e) {
var self = this;
var hiddenSeries = function () {
var counter = 0;
$.each(self.series.points, function (i, v) {
if (!v.visible) {
counter++;
}
});
return counter;
}
if (self.series.points.length - 1 == hiddenSeries() && self.visible) {
return false;
} else {
return true;
}
}
而且您可以在下面的小提琴中看到它的效果,但是它不適用於折線圖,因為“ this”對象不包含“ series.points”屬性。
您可以參考圖表變量以獲取系列信息。 我這樣做是這樣的:
legendItemClick: function (e) {
var visibleSeries = function () {
var counter = 0;
$.each(chart.series, function (i, v) {
if (v.visible) {
counter++;
}
});
return counter;
}
if (visibleSeries() <= 1 && this.visible) {
return false;
} else {
return true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.