I know, zombie thread post. You probably already solved this problem, but here are my thoughts years after the fact...
Since smoothing is dependent on multiple points in the line I think it will be quite difficult to find a smoothing algorithm that looks reasonable without producing some instability in the leading edge. You can probably reduce the scope of the instability, but only at risk of producing a very odd looking trace.
First option would be to use a spline algorithm that limits the projection artifacts. For instance the Catmull-Rom algorithm uses two known points on either side of the curve segment being interpolated. You can synthesize two additional points at each end of the curve or simply draw the first curve segment as a straight line. This will give a straight line as the last segment, plus a curve as the second to last segment which should change very little if at all when another point is added.
Alternatively you can run the actual data points through an initial spline calculation to multiply the points, then run those points through the spline algo a second time. You'll still have to update the most recent 2m
points (where m
is the multiplier of the first pass) or the output will look distorted.
About the only other option I can think of is to try to predict a couple of points ahead based on your prior data, which can be difficult even with a fairly regular input. I used this to synthesize Bezier control points for the ends of my curves - I was calculating CPs for all of the points and needed something to use for the end points - and had some interesting times trying to stop the final curve segments from looking horribly deformed.
Oh, one more... don't graph the final curve segment. If you terminate your curve at Pn-1 the curve should stay stable. Draw the final segment in a different style if you must show it at all. Since C-R splines only need +/- 2 known points from the interpolation the segment Pn-2-Pn-1 should be stable enough.
If you don't have code for the C-R algorithm you can do basically the same thing with synthetic Bezier control points. Rather than attempt to describe the process, check out this blog post which gives a fairly good breakdown of the process. This article has code attached which may be useful.