@prem123,
With the help of Equation of Straight Line, you can detect if a point lies on the line or not. Please take a look at this JSFiddle.
Also, please refer this stackoverflow thread for more info on achieving the same in JavaScript.
—
Vishwas R
Team CanvasJS