Page 1 of 1
User Calculated Chart
Posted: Thu Oct 01, 2009 1:55 pm
by 9533057
Hi,
Is it possible to add user calculated chart ?
ie: I have 2 charts. I want a new chart (chart3) who is the difference between Chart1 and Chart2.
If I add new point in Chart 1 and Chart2, I want Chart3 reflecting this change automatically.
Does it exist a functionnality of Teechart to add chart based on a user formula (in my case it is a difference but I would like to specify my own formula ex Chart1 + 0.75485*Chart2 ...
Thanks for your help
Guilz
Re: User Calculated Chart
Posted: Fri Oct 02, 2009 8:15 am
by narcis
Hi Guilz,
Yes, there are subtract and y=f(x) functions. Please have a look at the All Features\Welcome!\Functions examples in the features demo and read tutorial 7. Demo and tutorials are available at TeeChart's program group.
Re: User Calculated Chart
Posted: Fri Oct 02, 2009 8:33 am
by 9533057
Hi Narcis,
y=f(x) is not what I'am looking for
CalculateMany Function is used to calculate function result if multiple series can be datasource, it is what i am looking for
Tell me if I'm wrong but the
CalculateMany function is not available for Teechart ActiveX but only for VCL...
Guilz
Re: User Calculated Chart
Posted: Fri Oct 02, 2009 10:22 am
by yeray
Hi Guilz,
Note that CalculateMany function is a function present into some TeeChart functions.
Please, try to explain what are you exactly trying to do here and we'll try to suggest you the best way we can find to achieve it.
Re: User Calculated Chart
Posted: Fri Oct 02, 2009 10:36 am
by 9533057
Yeray,
I have 1 chart with 2 series (S1 and S2).
I want to add a new serie S3 reflecting changes of S1 and S2 by a function like S3= S1-S2 (*)
If a new point is added to S1 and S2, S3 must automaticaly reflect this change and add the new calculated point defined by the formula (*)
Hope it is help you to understand what I am looking for
Guilz
Re: User Calculated Chart
Posted: Fri Oct 02, 2009 11:13 am
by yeray
Hi Guilz,
I think I agree with NarcĂs. If I understood well you are trying to do something as follows:
Code: Select all
Private Sub Command1_Click()
Dim diff As Double
diff = TChart1.Series(0).YValues.Maximum - TChart1.Series(0).YValues.Minimum
TChart1.Series(0).Add (Rnd * diff / 5) - diff / 10 + TChart1.Series(0).YValues.Minimum, "", clTeeColor
diff = TChart1.Series(1).YValues.Maximum - TChart1.Series(1).YValues.Minimum
TChart1.Series(1).Add (Rnd * diff / 5) - diff / 10 + TChart1.Series(1).YValues.Minimum, "", clTeeColor
TChart1.Series(2).CheckDataSource
TChart1.Axis.Bottom.SetMinMax 0, TChart1.Series(0).Count - 1
End Sub
Private Sub Form_Load()
TeeCommander1.Chart = TChart1
TChart1.Aspect.View3D = False
TChart1.AddSeries scPoint
TChart1.AddSeries scPoint
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues 25
TChart1.Series(1).FillSampleValues 25
TChart1.Series(2).SetFunction tfCustom
TChart1.Series(2).DataSource = "Series0,Series1"
TChart1.Axis.Bottom.SetMinMax 0, TChart1.Series(0).Count - 1
End Sub
Private Sub TChart1_OnFunctionCalculate(ByVal SeriesIndex As Long, ByVal X As Double, Y As Double)
Y = TChart1.Series(0).YValues.Value(X) - TChart1.Series(1).YValues.Value(X)
End Sub
Re: User Calculated Chart
Posted: Fri Oct 02, 2009 11:21 am
by 9533057
Fantastic Yeray, it is exactly what I was looking for
thanks a lot
Guilz