Page 1 of 1

Zooming and function

Posted: Wed May 05, 2004 4:38 pm
by 8573713
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?

Posted: Thu May 06, 2004 8:25 pm
by Marjan
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:

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;