refactor(graph.graph component.legend) moving event-handling and updateDerivations to optimize