Page 1 of 1
Applying Functions to Teechart
Posted: Thu Oct 06, 2011 2:49 am
by 15660116
I need to apply a function to a Points Series.
I have tried
PolyFitting1.PolyDegree = 2
Points1.Function = PolyFitting1
PolyFitting1.Calculate(Points1, 0, Numberofsamples)
This does not appear to be correct.
Re: Applying Functions to Teechart
Posted: Thu Oct 06, 2011 9:41 am
by 10050769
Hello lilo,
I recommend you that take a look in the demo example All features\Welcome !\Functions\Extended\Polynomial fitting\Finding coefficients, where there is an example of you need to apply a Polynomial fitting function and I think, you can do something as do in the example. If you have any problems, please let me know.
I hope will helps.
Thanks,
Re: Applying Functions to Teechart
Posted: Sat Oct 15, 2011 5:22 am
by 15660116
Thanks Sandra,
I am using the example code but the coefficients keep returning 0.
PolyFitting1.PolyDegree = 2
Points1.DataSource = Points1
PolyFitting1.Chart = TChart1.Chart
Points1.Function = PolyFitting1
Points1.Function.Period = 2
Points1.CheckDataSource()
Points1.Function.Calculate(TChart1.Series(0), 0, NumofPoints - 1)
Dim t As Short
Dim txt = "y="
For t = 0 To PolyFitting1.PolyDegree - 1
txt += " "
If PolyFitting1.Coefficient(t) >= 0.0 Then txt += "+"
txt += PolyFitting1.Coefficient(t).ToString("0.00##")
If (t > 0) Then txt += "*x"
If (t > 1) Then txt += "^" + t.ToString()
Next
I am missing something in the code, but cannot figure out what it is?
Re: Applying Functions to Teechart
Posted: Mon Oct 17, 2011 11:10 am
by 10050769
Hello lilo,
Can you try to arrange a simple project so we can reproduce your example exactly here and try to find where there is the problem?
Thanks,
Re: Applying Functions to Teechart
Posted: Mon Oct 17, 2011 11:19 am
by 15660116
Just a thought - I could add PolyFitting1.AddPoints method to the code.
What is the correct format for array Addpoints - there is no detailed reference in the documentation
Should I add an array of X Values or X and Y Values?
How should the Array be Declared?
Thanks,
Re: Applying Functions to Teechart
Posted: Mon Oct 17, 2011 12:29 pm
by 15660116
Got the original code working. Just had to activate and relate the charts in the editor.
Thanks,
Re: Applying Functions to Teechart
Posted: Mon Oct 17, 2011 2:57 pm
by 10050769
Hi lilo,
I am glad that you have found the solution for your problem
.
Thanks,