The title says almost everything. Here is an image explaining what I want.

This is part of the Highcharts configuration that I use so far, but it does not calculate the amount correctly, because the stackTotal property contains the total, even hidden elements.
plotOptions: { series: { events: { legendItemClick: function(event) { // if visible, sum == 0, because this series will be hidden // if hidden, sum == total, because this series will be shown var sum = (this.visible ? this.data[0].stackTotal : 0), index = this.index; $.each(this.chart.series, function(){ if (this.visible && this.index != index) { sum += this.data[0].stackTotal; } }); $('.chart_total', '#doc_chart').text(sum); } } } },
How can I make it show the correct amount for the chart?
source share