Is there a way to prevent the hiding of the last legend item that's being deselected in a line chart?
I've achieved it on a column/pie charts using the legendItemClick event:
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;
}
}
and it works pretty well as you can see on the following fiddle , however, it doesn't work with line charts since the 'this' object doesn't contain the 'series.points' property.
You can refer to the chart variable to get at the series info. I did it like this:
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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.