this is a less than flashy way of accomplishing this... I'll probably sleep on it and think if I can come up with something better. Basically it's selecting from the series the `foo=bar` that has `foo` entered in the input, and returning them to be displayed in the legend.