The legend categories can be filtered to only visible categories. This requires the geometry generators to do intersection calculations, as the legend is created based on intersected cells.