add legend support (first draft)