Don't show legends for data sources that are not shown.

Fixes #351.