dom manipulation for switching between graphs