Page 1 of 1

How to use Spline with Period and PeriodStyle properties ??

Posted: Wed Jun 09, 2010 5:22 am
by 10052502
Hello Steema,

I have a query regarding how to set the period of a Spline function. At the moment I am doing the following but I only get 28 points even though I have set Period to 5000 and PeriodStyle to psNumPoints. Any clues would be great.
The reason I am asking is that I previously asked how to find the y value at a set x value and that works nicely. However in this instance the added points I am using are only able to generate 28 points within the splineseries. Is that normal ?
I have specified that I want 500 but only ever get 28 maximum. I have tried PeriodStyle of psRange as well but it doesn't make any difference either.

Here is the code I am using

Code: Select all

 
    LabNoIndex := 1 ;
    RValuePointSeries[LabNoIndex] := TPointSeries.Create(Self) ;
    RValuePointSeries[LabNoIndex].VertAxis := aRightAxis ;
    [b]SplineFunction := TSmoothingFunction.Create(self) ;
    SplineFunction.PeriodStyle := psNumPoints ;
    SplineFunction.Period :=  400 ;
    SplineFunction.Interpolate := checkbox1.checked ;
    SplineFunction.Factor := 9 ;
    SplineSeries[LabNoIndex] := TLineSeries.Create(Self) ;
    SplineSeries[LabNoIndex].LinePen.Color := clBlack ;
    SplineSeries[LabNoIndex].LinePen.Width := 2 ;
    SplineSeries[LabNoIndex].SeriesColor := clBlack ;

    SplineSeries[LabNoIndex].SetFunction(Splinefunction) ;
    SplineSeries[LabNoIndex].VertAxis := aRightAxis ;
    if LabNoIndex = 1 then
    begin
      Chart1.AddSeries(RValuePointSeries[LabNoIndex]) ;
      Chart1.AddSeries(SplineSeries[LabNoindex]) ;
    end;

    RValueLineSeries[LabNoIndex] := TLineSeries.Create(Self) ;

    Screen.Cursor := CrDefault ;
    RValuePointSeries[LabNoIndex].Pointer.HorizSize := 3 ;
    RValuePointSeries[LabNoIndex].Pointer.VertSize := 3 ;
    RValuePointSeries[LabNoIndex].Pointer.Style := psDiagCross ;
    j := 0 ;


    RValuePointSeries[LabNoIndex].AddXY(453,75,'',clBlue) ;
    RValuePointSeries[LabNoIndex].AddXY(255,64,'',clBlue) ;
    RValuePointSeries[LabNoIndex].AddXY(215,60,'',clBlue) ;

     SplineSeries[LabNoIndex].DataSource := RValuePointSeries[LabNoIndex] ;
     SplineSeries[LabnoIndex].checkDataSource ;

     XPeak := 300 ;

     Showmessage(inttostr(SplineSeries[LabNoIndex].Count)) ;
     for i := 0 to SplineSeries[LabNoIndex].Count-1 do
     begin
       if SplineSeries[LabNoIndex].XValues[i] = XPeak then
        YPeak := SplineSeries[LabNoIndex].YValues[i] ;
     end;
     EstOMC[LabNoIndex] := XPeak ;
     EstMDD[LabNoIndex] := YPeak ;

Thank you,

Steve West

Re: How to use Spline with Period and PeriodStyle properties ??

Posted: Wed Jun 09, 2010 3:17 pm
by yeray
Hi Steve West,

I think that incrementing the SplineFunction.Factor gives the result you are finding. Isn't it?

Re: How to use Spline with Period and PeriodStyle properties ??

Posted: Wed Jun 09, 2010 9:43 pm
by 10052502
Yeray,

Thank you for the reply. Usually the most obvious things are the hardest to see!!
I have tried this and I can only ever get a maximum value of 601 points regardless of factor so I am assuming that must be some internal maximum ?
For example if I have 3 points and set factor to 1000 and 2000 I only see a maximum number of values created at 601. Would this be correct ?
Thanks again and I can actually live with this however just asking if there is some internal maximum.

Kind Regards,
Steve West

Re: How to use Spline with Period and PeriodStyle properties ??

Posted: Fri Jun 11, 2010 9:12 am
by yeray
Hi Steve,

Yes, there is a MaxFragments = 600, if you are source code customer you'll be able to change it to what you want.
The Fragments is the result of the operation Sources.Count * Factor.