Calculating distance between charts properly