I think I know what you mean... it shouldn't be too hard to make such thing.
What you need to implement first is a way to see what member belongs to what usergroup.
You can do this by giving the hyperlink another attribute such as usergroup="6" or usergroup="administrator" and then when someone hovers over the legend rank administrator (which also has some kind of attribute attached to it so you can see what usergroup is being hovered over), it will loop through each of the hyperlinks in the "Who's online" div and find who has the attribute.
I made a quick example for you here:
https://jsfiddle.net/1n5zzof6/