QuickReport related
Q: How can I copy one chart I have into a QuickReport Chart ?
CBUILDER CODE: QRChart1->Chart->FreeAllSeries();
QRChart1->Chart->Assign(Chart1);
for (int t=0;t<=Chart1->SeriesCount()-1;t++)
CloneChartSeries(Chart1->Series[t])->ParentChart=QRChart1->Chart;
Q: How can I create a TQRChart at run-time on a QuickReport ?
DELPHI CODE: procedure TForm1.Button1Click(Sender: TObject);
var tmp:TQRChart;
begin
{ Create the QRChart }
tmp:=TQRChart.Create(Self);
{ Create the QRDBChart }
With TQRDBChart.Create(tmp) do
begin
Parent:=TWinControl(tmp);
Name:=TeeGetUniqueName(Owner,'QRChart');
Title.Text.Clear;
Title.Text.Add(tmp.ClassName);
end;
{ add the QRChart to the QuickReport... }
With tmp do
begin
ParentReport:=QuickRep1;
Parent:=TitleBand1;
Width:=300;
Height:=160;
Left:=30;
Top:=20;
{ Create a Series and add sample values... }
Chart.AddSeries( TBarSeries.Create(Self) );
Chart.Series[0].FillSampleValues(7);
end;
end;
CBUILDER CODE: void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
// Create the QRChart
TQRChart *tmp=new TQRChart(this);
// Create the QRDBChart
TQRDBChart *tmpQRDB=new TQRDBChart(tmp);
tmpQRDB->Parent=tmp;
tmpQRDB->Name=TeeGetUniqueName(tmpQRDB->Owner,"QRChart");
tmpQRDB->Title->Text->Clear();
tmpQRDB->Title->Text->Add(tmp->ClassName());
// add the QRChart to the QuickReport...
tmp->ParentReport=QuickRep1;
tmp->Parent=TitleBand1;
tmp->Width=300;
tmp->Height=160;
tmp->Left=30;
tmp->Top=20;
// Create a Series and add sample values...
TBarSeries *tmpSer=new TBarSeries(this);
tmpSer->ParentChart=tmp->Chart;
tmpSer->FillSampleValues(7);
}
Q: How can I install TeeChart4 with new versions of QuickReport?The following example is for Delphi4, but something very similar can be done with Delphi3 and BCB3.
Q: How can I draw some stuff on the TQRChart. It seems TQRChart does not support the OnAfterDraw event ?You can use the TQRChart.Chart.OnAfterDraw event (see the example bellow): unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, TeeProcs, TeEngine, Chart, DBChart, QrTee, QuickRpt;
type
TForm1 = class(TForm)
QRDBChart1: TQRDBChart;
QRChart1: TQRChart;
procedure FormCreate(Sender: TObject);
private
procedure MyTest(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.MyTest(Sender: TObject);
begin
QRChart1.Chart.Canvas.TextOut(200,200,'Test');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
QRChart1.Chart.OnAfterDraw:=MyTest;
end;
end.
CBUILDER CODE: *.H FILE:
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TQuickRep *QuickRep1;
TQRBand *TitleBand1;
TQRDBChart *QRDBChart1;
TQRChart *QRChart1;
void __fastcall AfterDraw(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
*.CPP FILE:
//---------------------------------------------------------------------------
void __fastcall TForm1::AfterDraw(TObject *Sender)
{
QRChart1->Chart->Canvas->TextOut(200,200,"Test");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
QRChart1->Chart->OnAfterDraw=AfterDraw;
}
//---------------------------------------------------------------------------
Q: How can I save/load chart definitions directly into a TQRChart ?DELPHI CODE: procedure TForm1.btnSaveClick(Sender: TObject); begin SaveChartToFile(QRChart1.Chart,'c:\temp\test1.tee'); end; procedure TForm1.btnLoadClick(Sender: TObject); var tmp: TCustomChart; begin QRChart1.Chart.Free; tmp:=TQRDBChart.Create(Self); tmp.Parent:=TWinControl(QRChart1); LoadChartFromFile(tmp,'c:\temp\test1.tee'); QRChart1.Chart.Assign(tmp); end; |