Add data.xSort option and fix the logic to closest data point - #525