Trendfunction

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Trendfunction

Post by SPS » Tue Jul 21, 2009 1:38 pm

Hi,

If i want a trend line for a serie, but not for the whole range of the serie, what is the best way to do this?
I couldn't find any methods / properties in the trendfunction that allow me to only do a trend on a part of the serie.

I tried to hack the serie values, remove some values and give the "new" serie to the datasource. But this doesn't seem to work correct:

Steema.TeeChart.Functions.TrendFunction t = new Steema.TeeChart.Functions.TrendFunction();
t.TrendStyle = Steema.TeeChart.Functions.TrendStyles.Normal;

double[] originalX = series.XValues.Value;
double[] originalY = series.YValues.Value;
int orginalCountX = series.XValues.Count;
int orginalCountY = series.YValues.Count;

List<double> xvalues = new List<double>();
for (int i=0; i < series.XValues.Count - 500; i++) //Remove last 500 values
xvalues.Add(series.XValues.Value);

List<double> yvalues = new List<double>();
for (int i=0; i < series.YValues.Count - 500; i++) //remove last 500 values
yvalues.Add(series.YValues.Value);

//Overwrite the current serie with the new values
series.XValues.Count = xvalues.Count;
series.YValues.Count = yvalues.Count;
series.XValues.Value = xvalues.ToArray();
series.YValues.Value = yvalues.ToArray();

Line trendLine = new Line();
trendLine.DataSource = series;//this.Series;
trendLine.Function = t;

this.StartPos = new Steema.TeeChart.Drawing.PointDouble(trendLine[0].X, trendLine[0].Y); //Here the trendline Y value is not correct anymore.
this.EndPos = new Steema.TeeChart.Drawing.PointDouble(trendLine[trendLine.Count - 1].X, trendLine[trendLine.Count - 1].Y);
this.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
this.Pen.Color = this.Series.Color;
this.Pen.Width = 2;

//Restore the serie values to the original ones
int xc = originalX.Count();
int yc = originalY.Count();
series.XValues.Value = originalX;
series.YValues.Value = originalY;
series.XValues.Count = orginalCountX;
series.YValues.Count = orginalCountY;

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Trendfunction

Post by SPS » Tue Jul 21, 2009 2:38 pm

My bad, i changed the series in the end that was used in the datasource. With a new serie it works ok. Just wondering if there isn't an easier way to do this?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trendfunction

Post by Yeray » Tue Jul 21, 2009 2:48 pm

Hi SPS,

The functions are thought to have a series by source, not a part of them. So I'm afraid that I can't think on another way to do this right now.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply