Added code to flip tooltip position if near edge of graph.