home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / DELPHI4.EXE / %MAINDIR% / Examples / 3rdParty / QuickReport / QRDemo1 / Share.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1998-11-17  |  1.4 KB  |  59 lines

  1. unit share;
  2.  
  3. interface
  4.  
  5. uses
  6.   WinTypes,WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   TeEngine, Series, Chart, TeeProcs, DBChart, QrTee, quickrpt, ExtCtrls,
  8.   StdCtrls, Buttons;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     QuickRep1: TQuickRep;
  13.     QRDBChart1: TQRDBChart;
  14.     QRChart1: TQRChart;
  15.     Chart1: TChart;
  16.     BitBtn1: TBitBtn;
  17.     Series1: TPointSeries;
  18.     procedure FormCreate(Sender: TObject);
  19.     procedure BitBtn1Click(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. { This procedure will duplicate one existing Chart in a Form
  34.   inside a QuickReport Chart.
  35.   It can be useful to share Charts both in screen Forms and Reports. }
  36.  
  37. Procedure LinkChart(AChart:TCustomChart; AQRChart:TQRChart);
  38. var t:Integer;
  39. begin
  40.   AQRChart.Chart.FreeAllSeries;  { <-- remove the existing old Series }
  41.   AQRChart.Chart.Assign(AChart);   { <-- duplicate all Chart properties }
  42.   { duplicate the Series and values }
  43.   for t:=0 to AChart.SeriesCount-1 do
  44.       CloneChartSeries(AChart[t]).ParentChart:=AQRChart.Chart;
  45. end;
  46.  
  47. procedure TForm1.FormCreate(Sender: TObject);
  48. begin
  49.   Series1.FillSampleValues(8);  { <-- some random values for the demo }
  50.   LinkChart(Chart1,QRChart1);   { <-- link the Charts ! }
  51. end;
  52.  
  53. procedure TForm1.BitBtn1Click(Sender: TObject);
  54. begin
  55.   QuickRep1.Preview; 
  56. end;
  57.  
  58. end.
  59.