Hi,
How can I chart a serie, defined by a function based on others series ?
For example: I have 3 series (each serie does not have the same number of points).
I would like to chart Serie4 = (Serie1+(0.15*Serie2)-0.25*Serie3)/2
If series 1 2 3 are updated (new points added), Serie4 must reflect changes
Thanks for you help
Regards,
Guilz
Calculated serie
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Calculated serie
Hi Guilz,
You can use custom function for that. You'll find an example at All Features\Welcome!\Functions\Extended\Custom y=f(x) in the features demo available at TeeChart's program group.
You can use custom function for that. You'll find an example at All Features\Welcome!\Functions\Extended\Custom y=f(x) in the features demo available at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Calculated serie
Hi Narcis,
I am afraid the example is not very helpful - I like to do this by code and I do not find any example of creating custom function yet.
In the code given as example:
It is working if you have 1 serie but how to adapt this for 3 series ?
Must I specify my series as datasource like this:
A little project should be very appreciate Narcis because this subject is not very clear when you try to do this by code...
Regards,
Guilz
I am afraid the example is not very helpful - I like to do this by code and I do not find any example of creating custom function yet.
In the code given as example:
Code: Select all
Private Sub TChart1_OnFunctionCalculate(ByVal SeriesIndex As Long, ByVal X As Double, Y As Double)
Y = Sin(X / 10)
End Sub
Must I specify my series as datasource like this:
Code: Select all
TChart1.Series(0).DataSource = "Series1, Series2, Series3"
Regards,
Guilz
Re: Calculated serie
Hello Guilz,
I have made for you a simple example using 2 series. Could you please, tell us if next code, works as you want?
If you want more information, you can see ActiveX Tutorials, concretely Tutorial 7: Working with Functions.
I hope will helps.
Thanks,
I have made for you a simple example using 2 series. Could you please, tell us if next code, works as you want?
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
With TChart1
'Add 2 data Series
.AddSeries scLine
.AddSeries scLine
' Populate them with data (here random)
.Series(0).FillSampleValues 25
.Series(1).FillSampleValues 25
.AddSeries scLine
.Series(2).SetFunction tfCustom
.Series(2).DataSource = "Series0,Series1"
End With
End Sub
Private Sub TChart1_OnFunctionCalculate(ByVal SeriesIndex As Long, ByVal X As Double, Y As Double)
Y = X * 2
End Sub
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Calculated serie
Hi Sandra,
I am sorry but your example is not what I am looking for (I would like to work with 3 series as input and create the result serie using the function : Serie0 = (Serie1+(0.15*Serie2)-0.25*Serie3)/2 in my example
Here I would like to have in serie0 the result of my function ((Serie1+(0.15*Serie2)-0.25*Serie3)/2)
I read the tutorial 7 and at the end the Deriving custom functions is similar for what I am looking for BUT I use teechart ActiveX (not VCL) and so it can not be done like this...
Thanks a lot for your help and patience
Regards,
Guilz
I am sorry but your example is not what I am looking for (I would like to work with 3 series as input and create the result serie using the function : Serie0 = (Serie1+(0.15*Serie2)-0.25*Serie3)/2 in my example
Code: Select all
TChart1.Series(1).FillSampleValues 15
TChart1.Series(2).FillSampleValues 10
TChart1.Series(3).FillSampleValues 5
TChart1.Series(0).SetFunction tfCustom
TChart1.Series(0).FunctionType.asCustom.NumPoints = 15
TChart1.Series(0).DataSource = "Series1, Series2, Series3"
I read the tutorial 7 and at the end the Deriving custom functions is similar for what I am looking for BUT I use teechart ActiveX (not VCL) and so it can not be done like this...
Thanks a lot for your help and patience
Regards,
Guilz
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Calculated serie
Hi Guilz,
To achieve what you need custom function would need, at least, ValueIndex parameter in the OnCalculate event too. I'll add this to the wish-list (TV52015259) to be considered for inclusion in future releases.
In the meantime you can add a series without any function that plots its values from existing series values, for example:
To achieve what you need custom function would need, at least, ValueIndex parameter in the OnCalculate event too. I'll add this to the wish-list (TV52015259) to be considered for inclusion in future releases.
In the meantime you can add a series without any function that plots its values from existing series values, for example:
Code: Select all
Private Sub Form_Load()
With TChart1
For i = 0 To 2
.AddSeries scBar
.Series(i).FillSampleValues 15
Next
.AddSeries scLine
For j = 0 To .Series(0).Count - 1
X = .Series(0).XValues.Value(j)
Y = (.Series(0).YValues.Value(j) + (0.15 * .Series(2).YValues.Value(j)) - (0.25 * .Series(2).YValues.Value(j))) / 2
.Series(3).AddXY X, Y, "", clTeeColor
Next
End With
End Sub
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |