fixed onclick events for multiple instances of graph