Page 1 of 1
show trend on a zoomed area
Posted: Thu Aug 23, 2012 7:56 am
by 16661390
Hi, how it is possible to show a trend line on a zoomed area ? the trend stays allways on the full serial , is this possible to fix the first element and the last to include in the calculation of the trend?
regards
JP
Re: show trend on a zoomed area
Posted: Thu Aug 23, 2012 10:08 am
by yeray
Hi,
You could populate a dummy series with only the visible values at OnZoom event, and show the Trend of this dummy series.
Ie:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scBar
TChart1.Series(0).Name = "Source"
TChart1.Series(0).FillSampleValues 50
TChart1.AddSeries scBar
TChart1.Series(1).Name = "Dummy"
TChart1.Series(1).ShowInEditor = False
TChart1.Series(1).ShowInLegend = False
TChart1.Series(1).Active = False
TChart1.AddSeries scLine
TChart1.Series(2).Name = "Trend"
TChart1.Series(2).SetFunction tfTrend
TChart1.Series(2).DataSource = TChart1.Series(1)
End Sub
Private Sub TChart1_OnZoom()
TChart1.Environment.InternalRepaint
TChart1.Series(1).Clear
Dim i As Integer
For i = TChart1.Series(0).FirstValueIndex To TChart1.Series(0).LastValueIndex
TChart1.Series(1).AddXY TChart1.Series(0).XValues.Value(i), TChart1.Series(0).YValues.Value(i), "", clTeeColor
Next i
TChart1.Series(2).DataSource = TChart1.Series(1)
TChart1.Series(2).CheckDataSource
End Sub
If you want to get the Trend line of all the values when you zoom out, you could use the OnUndoZoom for it. Then you could use the source series with the trend function:
Code: Select all
Private Sub TChart1_OnUndoZoom()
TChart1.Series(2).DataSource = TChart1.Series(0)
End Sub
Re: show trend on a zoomed area
Posted: Thu Aug 23, 2012 1:07 pm
by 16661390
Hi,
Thanks a lot, I did it, it's fine...
regards
JP