Page 1 of 1

How to use TCurveFittingFunction properties at runtime

Posted: Fri Jun 20, 2008 7:19 am
by 10546084
I am creating a TCurvFittingFunction at runtime.
I wish to set the properties such as FirstPoint, Endpoint and PolyDegree.

How do I do it.

I used the following code.

Code: Select all

tmpPointSeries1:=TPointSeries.Create(self);
  AddSeries(tmpPointSeries1);

  //Populate them with data (here random)
  tmpPointSeries1.FillSampleValues(50);

  //Add a series to be used for an CurveFitting Function
  tmpLineSeries:=TLineSeries.Create(self);
  AddSeries(tmpLineSeries);

  //Define the Function Type for the new Series
  tmpLineSeries.SetFunction(TCurveFittingFunction.Create(self));

  //Define the Datasource for the new Function Series
  tmpLineSeries.DataSources.Clear;
  tmpLineSeries.DataSources.Add(tmpPointSeries1 );

  //tmpLineSeries.FunctionType.PolyDegree := 2; gives error message
Please advise. Thank you.

Posted: Fri Jun 20, 2008 8:17 am
by narcis
Hi bamboo,

This is because you need to typecast series' function:

Code: Select all

    (tmpLineSeries.FunctionType as TCurveFittingFunction).PolyDegree := 2;

Posted: Fri Jun 20, 2008 8:41 am
by 10546084
Thank you.