home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / TeeChartPro / TeeChart5Delphi5Eval.exe / %MAINDIR% / Examples / Features / FourCharts.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-10  |  2.6 KB  |  106 lines

  1. unit FourCharts;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Series, TeEngine, TeeProcs, Chart, ExtCtrls, StdCtrls;
  8.  
  9. type
  10.   TFourChartsForm = class(TForm)
  11.     Panel1: TPanel;
  12.     Chart1: TChart;
  13.     Winter: TLineSeries;
  14.     Summer: TLineSeries;
  15.     Chart2: TChart;
  16.     BarSeries1: TBarSeries;
  17.     Panel2: TPanel;
  18.     Chart3: TChart;
  19.     South: TAreaSeries;
  20.     North: TAreaSeries;
  21.     Chart4: TChart;
  22.     Speaking: TPointSeries;
  23.     Writing: TPointSeries;
  24.     Reading: TPointSeries;
  25.     Panel3: TPanel;
  26.     Button1: TButton;
  27.     SaveDialog1: TSaveDialog;
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure Button1Click(Sender: TObject);
  30.   private
  31.     { Private declarations }
  32.   public
  33.     { Public declarations }
  34.   end;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TFourChartsForm.FormCreate(Sender: TObject);
  41. var t : Integer;
  42. begin
  43.   { Some random points }
  44.   Summer.FillSampleValues(20);
  45.   Winter.FillSampleValues(20);
  46.  
  47.   { We need a Bar Series with special random values,
  48.     so dont call the FillSampleValues method }
  49.   With BarSeries1 do
  50.   for t:=1 to 12 do Add(Random(1000),ShortMonthNames[t],GetDefaultColor(t));
  51.  
  52.   South.FillSampleValues(20);
  53.   North.FillSampleValues(20);
  54.  
  55.   Speaking.FillSampleValues(20);
  56.   Reading.FillSampleValues(20);
  57.   Writing.FillSampleValues(20);
  58. end;
  59.  
  60. procedure TFourChartsForm.Button1Click(Sender: TObject);
  61. var tmpH,tmpW : Integer;
  62. begin
  63.  { This code creates and stores a new BITMAP file
  64.    which contains the FOUR charts.
  65.    Asks previously the user the BMP filename. }
  66.   with SaveDialog1 do
  67.   begin
  68.     if Execute then
  69.     With TBitmap.Create do
  70.     try
  71.       { calculate bitmap size (2x2) }
  72.       tmpW:=Chart1.Width;
  73.       tmpH:=Chart1.Height;
  74.       Width := 2*tmpW;
  75.       Height:= 2*tmpH;
  76.  
  77.       { draw chart 1 }
  78.       Chart1.BufferedDisplay:=False;
  79.       Chart1.Draw(Canvas,Rect(0,0,tmpW,tmpH));
  80.       Chart1.BufferedDisplay:=True;
  81.  
  82.       { draw chart 2 }
  83.       Chart2.BufferedDisplay:=False;
  84.       Chart2.Draw(Canvas,Rect(0,tmpH+1,tmpW,2*tmpH));
  85.       Chart2.BufferedDisplay:=True;
  86.  
  87.       { draw chart 3 }
  88.       Chart3.BufferedDisplay:=False;
  89.       Chart3.Draw(Canvas,Rect(tmpW+1,0,2*tmpW,tmpH));
  90.       Chart3.BufferedDisplay:=True;
  91.  
  92.       { draw chart 4 }
  93.       Chart4.BufferedDisplay:=False;
  94.       Chart4.Draw(Canvas,Rect(tmpW+1,tmpH+1,2*tmpW,2*tmpH));
  95.       Chart4.BufferedDisplay:=True;
  96.       SaveToFile(FileName);
  97.     finally
  98.       Free;
  99.     end;
  100.   end;
  101. end;
  102.  
  103. initialization
  104.   RegisterClass(TFourChartsForm);
  105. end.
  106.