Reputation: 321
I have a category Heatmap with both colorAxis and seriesLegend using solution here Show Series and colorAxis both in Legend and highchart-category-grouped plugin. Fiddle here https://jsfiddle.net/k16sdhrz/
When i toggle the series, I am left with empty rows which belonged to the series.
Is there a highchart setting that would remove these categories from axis and hence remove the empty rows. So space can be freed up?
chart: {
type: 'heatmap',
},
yAxis: {
categories: [{
name: 'Cat 1',
categories: ['Item 1_1', 'Item 1_2']
},
{
name: 'Cat 2',
categories: ['Item 2_1', 'item 2_2']
}
]
},
Thanks for your help.
Upvotes: 1
Views: 433
Reputation: 39139
Since Highcharts v7.2 it is enough to set showInLegend: true
for series to show it with colorAxis
.
As to your question - you can dynamically add and remove breaks to hide empty rows:
series: [{
...,
events: {
legendItemClick: function() {
if (this.visible) {
this.yAxis.update({
breaks: [{
from: 1.5,
to: 2.5,
breakSize: 0
}]
}, false);
} else {
this.yAxis.update({
breaks: []
}, false);
}
}
}
}, ...]
Live demo: https://jsfiddle.net/BlackLabel/0d9a4whz/
API Reference:
https://api.highcharts.com/highcharts/yAxis.breaks
https://api.highcharts.com/highcharts/series.heatmap.events.legendItemClick
Upvotes: 1