Fix legend container selector

Instead of incorrectly assuming the legend container is the parent of
the legend item, select it explicitly.

Fixes #260