Figure out the equations of the lines that would define the sides of the viewport, which ViewBox (
http://raphaeljs.com/2.0/#Paper.setViewBox) attributes you should be keeping track of for a graphing app. Then find the line-line intersections and draw a line between the intersection points. Or, which might be simpler, just draw a line that you know is bigger than the viewBox.