home *** CD-ROM | disk | FTP | other *** search
- {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- (c) TechInsite Pty. Ltd.
- PO Box 429, Abbotsford, Melbourne. 3067 Australia
- Phone: +61 3 9419 6456
- Fax: +61 3 9419 1682
- Web: www.techinsite.com.au
- EMail: peter_hinrichsen@techinsite.com.au
-
- Created: October 1999
-
- Notes: View the subject (portfolio) as a pie graph
-
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
- unit FObserver_PieGraph;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, TeEngine, Series, ExtCtrls,
- TeeProcs, Chart, FObserver_Abstract ;
-
- type
-
- //--------------------------------------------------------
- TFormObserverPieGraph = class(TFormObserverAbstract)
- Chart1: TChart;
- Series1: TPieSeries;
- procedure FormCreate(Sender: TObject);
- private
- // Get a unique colour to display in the graph
- function GetColour(const pI: integer): TColor;
- public
- procedure DataToObserver ; override ;
- end;
-
- implementation
- uses
- Subject_Portfolio ;
-
- {$R *.DFM}
-
- { TFormViewPieGraph }
-
- procedure TFormObserverPieGraph.DataToObserver ;
- var
- i : integer ;
- lStockTrans : TStockTrans ;
- begin
- chart1.series[0].clear ;
- with (Subject as TPortfolio) do begin
- for i := 0 to Stocks.Count - 1 do begin
- lStockTrans := Stocks.Items[ i ] ;
- chart1.series[0].add( lStockTrans.Value, lStockTrans.StockCode, GetColour( i )) ;
- end ;
- end ;
- end;
-
- procedure TFormObserverPieGraph.FormCreate(Sender: TObject);
- begin
- inherited;
- Subject := gPortfolio ;
- end;
-
- // Get a unique colour to display in the graph
- //----------------------------------------------------------
- function TFormObserverPieGraph.GetColour(const pI:
- integer): TColor;
- begin
- case pI of
- 0 : result := clRed ;
- 1 : result := clBlue ;
- 2 : result := clGreen ;
- 3 : result := clYellow ;
- 4 : result := clAqua ;
- else
- result := clBlack ;
- end ;
- end;
-
- end.
-
-