I am building a line graph application using Raphael.js and need to draw a line that passes through two points and reach the viewport.
I have uploaded a mockup that shows what I need to achieve:

Any help is appreciated.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
SVGs and, by extension, Raphaël, cannot do infinite lines, but that doesn’t mean you can’t fake it.
You’ll need to to a bit of math.
First, take the two points (start and mouse) and get the formula for it.
Once you have that, calculate where it hits the edges of the viewport. (You can do this by setting x or y to the left/right/top/bottom of the viewport and solving for that variable.) Once you know where the line is hitting your viewport’s edges, put it back into the line formula to calculate the two points you need to draw between.
Once you have these two points, the rest is easy: