Trendfunction
Posted: 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;
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;