home *** CD-ROM | disk | FTP | other *** search
- unit Function_AverageNulls;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Base, StdCtrls, TeEngine, TeeFunci, Series, ExtCtrls, TeeProcs, Chart;
-
- type
- TAverageFunctionNulls = class(TBaseForm)
- CheckBox1: TCheckBox;
- Series1: TBarSeries;
- Series2: TLineSeries;
- TeeFunction1: TAverageTeeFunction;
- Label1: TLabel;
- LabelAverage: TLabel;
- procedure CheckBox1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- Procedure SetLabelAverage;
- public
- { Public declarations }
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TAverageFunctionNulls.CheckBox1Click(Sender: TObject);
- begin
- TeeFunction1.IncludeNulls:=CheckBox1.Checked;
-
- SetLabelAverage;
- end;
-
- Procedure TAverageFunctionNulls.SetLabelAverage;
- var tmp : Double;
- t : Integer;
- tmpCount : Integer;
- begin
- { calculate the sum and number of points... }
- tmp:=0;
- tmpCount:=0;
- for t:=0 to Series1.Count-1 do
- begin
- { consider or not null points... }
- if TeeFunction1.IncludeNulls or (not Series1.IsNull(t)) then
- begin
- tmp:=tmp+Series1.YValues[t];
- Inc(tmpCount);
- end;
- end;
-
- LabelAverage.Caption:=FloatToStr(tmp)+' / '+
- IntToStr(tmpCount)+' = '+
- FloatToStr(tmp/tmpCount);
- end;
-
- procedure TAverageFunctionNulls.FormCreate(Sender: TObject);
- begin
- inherited;
-
- { Add some points and one null point... }
-
- Series1.Clear;
- Series1.Add( 10 ,'One', clRed );
- Series1.Add( 20 ,'Two', clRed );
- Series1.AddNull('Three');
- Series1.Add( 40 ,'Four', clRed );
- Series1.Add( 50 ,'Five', clRed );
-
- Series1.Marks.Style:=smsValue;
-
- SetLabelAverage;
- end;
-
- initialization
- RegisterClass( TAverageFunctionNulls );
- end.
-