Draw an average line

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Wicket
Newbie
Newbie
Posts: 20
Joined: Mon Jan 15, 2007 12:00 am

Draw an average line

Post by Wicket » Thu Mar 22, 2007 8:26 am

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

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Mar 22, 2007 9:17 am

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"
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Wicket
Newbie
Newbie
Posts: 20
Joined: Mon Jan 15, 2007 12:00 am

Post by Wicket » Thu Mar 22, 2007 5:45 pm

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!

Wicket
Newbie
Newbie
Posts: 20
Joined: Mon Jan 15, 2007 12:00 am

Post by Wicket » Mon Mar 26, 2007 2:35 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 30, 2007 2:20 pm

Hi Andreas,

Please find my reply at your other thread about the same issue:

http://www.teechart.net/support/viewtop ... 1820#21820
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply