Added dynamic adding and removing of legend details