The line of the graph is not constant, it jumps all over again

Do you want a continuous line?

Use the AI2 Chart component.

P.S. Regarding your code, capturing the previous x and y values should be done AFTER using them to plot the incoming data, not BEFORE. Check the FAQ's Canvas based samples.