Page 1 of 1
Draw an average line
Posted: Thu Mar 22, 2007 8:26 am
by 9643849
Let's say I have 10 lines (series of line typ) drawn on a chart. It could be the temperature for 10 different temperature meters for a couple of days.
Now I would like to draw an average line, showing the average temperature for each day (every line has one reading per day). Is this possible with the Average function or with the MovingAverage function?
The examples in the FeatureDemo regarding average values only deals with one series.
Regards Andreas
Posted: Thu Mar 22, 2007 9:17 am
by 9348258
Hi Wicket
Yes it's possible, you can do this in design-time with editor or in run-time. You can put more of one serie in a Function, doing array of series as below code:
Code: Select all
//Add a series to be used for an Average Function
Line average = new Line(tChart1.Chart);
//Define the Function Type for the new Series
Steema.TeeChart.Functions.Average average1 = new Steema.TeeChart.Functions.Average();
average.Function = average1;
//Define the Datasource for the new Function Series
average.DataSource = new object[] { this.line1, this.line2, this.line3, this.line5,
this.line6,this.line6, this.line7, this.line8,
this.line9,this.line10};
average.Color = Color.Black;
average.Function.Period = 1;
average.CheckDataSource();
You can find more information about Functions in the Tuturial 7 "Working with Functions"
Posted: Thu Mar 22, 2007 5:45 pm
by 9643849
Oh, thank you!
It was exactly what I needed to know! It works like a charm!
TeeChart is really a great control! Keep up the good work!
Posted: Mon Mar 26, 2007 2:35 pm
by 9643849
Hmm, I think I am in trouble again! =(
I followed your example, and it seemd to work fine!
However... When I add lines with different 'start date' (different start position on the x axis), the average line is calculated wrong. It seems like it adds all 'forst points' (for each line) and divide them by the number of 'first points', then all second points etc...
So, My line that starts in the middle of the graph affects the average to the far left on the graph. What am I doing wrong?
regards Andreas
Posted: Fri Mar 30, 2007 2:20 pm
by narcis
Hi Andreas,
Please find my reply at your other thread about the same issue:
http://www.teechart.net/support/viewtop ... 1820#21820