refactor render legend before draw the graph