views:

468

answers:

3

In my Winforms application I have a small chart. Nothing fancy just a bunch of x/y points I connect with lines.

It would be nice to draw a curve instead of a lines to connect these points. But since mathematics was never my strong side I have no idea how to do that.

Any kind of sample or advice would be helpful.

+2  A: 

Look here.

Gerrie Schenck
+3  A: 

This is very simple - no need for any math - just use Graphics.DrawCurve instead of DrawPolygon/DrawLine (see the very good help on this function).

CKoenig
A: 

Apologies for the thread resurrection, but I had to reply to this one:

Be clear in your mind what you want to achieve. I don't know the details of your project, but the methods being suggested are not appropriate for many applications. The correct solution depends on whether you intend the curves you're drawing to simply look nice, or to represent meaningful data. For the former, drawing a bezier curve is fine, but they are not mathematically meaningful and if you're trying to draw a graph to be interpreted with scientific rigour, they will mislead the user. For many applications what you'd want is a best-fit line. These have clear functional form, for example, a degree-2 polynomial (otherwise known as a parabola), a logarithmic curve, or a moving-average. All these are present in Excel and all have specific applications and are emphatically the wrong choice for anything outside their specific remit. The topic of statistical analysis of data is probably beyond the scope of a StackOverflow post - but to start with, look up 'linear regression', what you're describing is comprehensively dealt with by this area of mathematics.

Tom W