home *** CD-ROM | disk | FTP | other *** search
- {****************************************}
- { TeeChart. TChart Component }
- { Copyright (c) 1995-98 by David Berneda }
- { All Rights Reserved }
- {****************************************}
- unit USingRec;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- TeEngine, Series, Db, DBTables, ExtCtrls, TeeProcs, Chart, DBChart,
- DBCtrls, TeeComma, StdCtrls, Buttons;
-
- type
- TFormDBSingleRecord = class(TForm)
- DBChart1: TDBChart;
- Table1: TTable;
- DataSource1: TDataSource;
- Series1: TBarSeries;
- Panel1: TPanel;
- DBNavigator1: TDBNavigator;
- Label1: TLabel;
- BitBtn1: TBitBtn;
- procedure DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure DataSource1DataChange(Sender: TObject; Field: TField);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TFormDBSingleRecord.DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
-
- Function GetAxisName(Axis:TCustomChartAxis):String;
- begin
- if Axis.IsDepthAxis then result:='Depth'
- else
- if Axis.Horizontal then
- if Axis.OtherSide then result:='Top' else result:='Bottom'
- else
- if Axis.OtherSide then result:='Right' else result:='Left';
- end;
-
- Var Part:TChartClickedPart;
- begin
- With DBChart1 do
- begin
- CalcClickedPart(Point(X,Y),Part);
- case Part.Part of
- cpNone: Hint:='';
- cpLegend: Hint:='Legend';
- cpAxis: Hint:=GetAxisName(Part.AAxis)+' Axis';
- cpSeries: With Part.ASeries do
- begin
- if Title='' then Hint:=Name else Hint:=Title;
- Hint:=Hint+' '+ValueMarkText[Part.PointIndex];
- end;
- cpTitle: Hint:='Title';
- cpFoot : Hint:='Foot';
- cpChartRect: Hint:='Chart';
- end;
- end;
- end;
-
- procedure TFormDBSingleRecord.FormCreate(Sender: TObject);
- begin
- Application.HintPause:=0;
-
- { Properties used:
-
- Series1.DataSource := DataSource1 ;
- Series1.YValues.ValueSource := 'size;weight';
- }
- end;
-
- procedure TFormDBSingleRecord.BitBtn1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TFormDBSingleRecord.DataSource1DataChange(Sender: TObject; Field: TField);
- begin
- with DBChart1.Title.Text do
- begin
- Clear;
- Add( Table1.FieldByName('Name').AsString );
- end;
- end;
-
- end.
-