home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / EXTENDED / USINGREC.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  2.5 KB  |  100 lines

  1. {****************************************}
  2. {    TeeChart. TChart Component          }
  3. { Copyright (c) 1995-98 by David Berneda }
  4. {    All Rights Reserved                 }
  5. {****************************************}
  6. unit USingRec;
  7.  
  8. interface
  9.  
  10. uses
  11.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  12.   TeEngine, Series, Db, DBTables, ExtCtrls, TeeProcs, Chart, DBChart,
  13.   DBCtrls, TeeComma, StdCtrls, Buttons;
  14.  
  15. type
  16.   TFormDBSingleRecord = class(TForm)
  17.     DBChart1: TDBChart;
  18.     Table1: TTable;
  19.     DataSource1: TDataSource;
  20.     Series1: TBarSeries;
  21.     Panel1: TPanel;
  22.     DBNavigator1: TDBNavigator;
  23.     Label1: TLabel;
  24.     BitBtn1: TBitBtn;
  25.     procedure DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  26.       Y: Integer);
  27.     procedure FormCreate(Sender: TObject);
  28.     procedure BitBtn1Click(Sender: TObject);
  29.     procedure DataSource1DataChange(Sender: TObject; Field: TField);
  30.   private
  31.     { Private declarations }
  32.   public
  33.     { Public declarations }
  34.   end;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TFormDBSingleRecord.DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  41.   Y: Integer);
  42.  
  43.   Function GetAxisName(Axis:TCustomChartAxis):String;
  44.   begin
  45.     if Axis.IsDepthAxis then result:='Depth'
  46.     else
  47.     if Axis.Horizontal then
  48.        if Axis.OtherSide then result:='Top' else result:='Bottom'
  49.     else
  50.        if Axis.OtherSide then result:='Right' else result:='Left';
  51.   end;
  52.  
  53. Var Part:TChartClickedPart;
  54. begin
  55.   With DBChart1 do
  56.   begin
  57.     CalcClickedPart(Point(X,Y),Part);
  58.     case Part.Part of
  59.     cpNone:   Hint:='';
  60.     cpLegend: Hint:='Legend';
  61.     cpAxis:   Hint:=GetAxisName(Part.AAxis)+' Axis';
  62.     cpSeries: With Part.ASeries do
  63.               begin
  64.                 if Title='' then Hint:=Name else Hint:=Title;
  65.                 Hint:=Hint+' '+ValueMarkText[Part.PointIndex];
  66.               end;
  67.     cpTitle:  Hint:='Title';
  68.     cpFoot :  Hint:='Foot';
  69.  cpChartRect: Hint:='Chart';
  70.     end;
  71.   end;
  72. end;
  73.  
  74. procedure TFormDBSingleRecord.FormCreate(Sender: TObject);
  75. begin
  76.   Application.HintPause:=0;
  77.  
  78.   { Properties used:
  79.  
  80.     Series1.DataSource := DataSource1 ;
  81.     Series1.YValues.ValueSource := 'size;weight';
  82.   }
  83. end;
  84.  
  85. procedure TFormDBSingleRecord.BitBtn1Click(Sender: TObject);
  86. begin
  87.   Close;
  88. end;
  89.  
  90. procedure TFormDBSingleRecord.DataSource1DataChange(Sender: TObject; Field: TField);
  91. begin
  92.   with DBChart1.Title.Text do
  93.   begin
  94.     Clear;
  95.     Add( Table1.FieldByName('Name').AsString );
  96.   end;
  97. end;
  98.  
  99. end.
  100.