Zooming and function
-
- Newbie
- Posts: 1
- Joined: Fri Nov 15, 2002 12:00 am
- Contact:
Zooming and function
I use TaverageTeeFunction function. It calculates an average value for all the series. But after zooming the value doesn’t change. Can the function work with zooming?
Hi.
By default the average function calculates the average of all series points (or groups all series points and calculates the average of each group). In your case the function only has to use range of points to calculate the average.
A way around this is to use the average function Calculate method to calculate range average and then use the code in appropriate chart events to adjust function value:
By default the average function calculates the average of all series points (or groups all series points and calculates the average of each group). In your case the function only has to use range of points to calculate the average.
A way around this is to use the average function Calculate method to calculate range average and then use the code in appropriate chart events to adjust function value:
Code: Select all
procedure ConstructAvg(Source: TChartSeries; first,last: Integer; AvgFun: TAverageTeeFunction);
var avg: double;
begin
avg := AvgFun.Calculate(Source,first,last);
with AvgFun.ParentSeries do
begin
Clear;
AddXY(Source.XValues[first],avg);
AddXY(Source.XValues[last],avg);
end;
end;