I'm using TChart ActiveX V7 with C++. Is there a way to export multiple charts to the same PDF file?
I've already got code to export a single chart to a pdf file but I need the ability to export more than 1 chart to the same pdf file. If this function is not available in V7, will it be available in a future release?
Thanks.
Multiple Charts to PDF
I asked this question on the news group last week before buying a license. Here's the reply I received...
This can be done manually. We don't have a TeeChart ActiveX example of that.
Below you'l find a TeeChart VCL example. Same should be possible using the
ActiveX version.
procedure TFourChartsForm.Button1Click(Sender: TObject);
var tmpH,tmpW : Integer;
begin
{ This code creates and stores a new BITMAP file
which contains the FOUR charts.
It asks previously the end user for the BMP filename
where to save the bitmap.
}
with SaveDialog1 do
begin
if Execute then
With TBitmap.Create do
try
{ calculate bitmap size (2x2) }
tmpW:=Chart1.Width;
tmpH:=Chart1.Height;
Width := 2*tmpW;
Height:= 2*tmpH;
{ draw chart 1 }
Chart1.BufferedDisplay:=False;
Chart1.Draw(Canvas,Rect(0,0,tmpW,tmpH));
Chart1.BufferedDisplay:=True;
{ draw chart 2 }
Chart2.BufferedDisplay:=False;
Chart2.Draw(Canvas,Rect(0,tmpH+1,tmpW,2*tmpH));
Chart2.BufferedDisplay:=True;
{ draw chart 3 }
Chart3.BufferedDisplay:=False;
Chart3.Draw(Canvas,Rect(tmpW+1,0,2*tmpW,tmpH));
Chart3.BufferedDisplay:=True;
{ draw chart 4 }
Chart4.BufferedDisplay:=False;
Chart4.Draw(Canvas,Rect(tmpW+1,tmpH+1,2*tmpW,2*tmpH));
Chart4.BufferedDisplay:=True;
SaveToFile(FileName);
finally
Free;
end;
end;
end;
--
Best Regards,
Narcís Calvet
Steema Support Central
Re: Multiple Charts to PDF
I'm still unclear how the canvas is associated with the Bitmap? In Visual C++ (ActiveX) does the CBMPExport class have a "Canvas" property?
I don't undestand how drawing the chart to the canvas will cause the bitmap to be dumped to the file via SaveToFile?
Thanks
--nbp
I don't undestand how drawing the chart to the canvas will cause the bitmap to be dumped to the file via SaveToFile?
Thanks
--nbp
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Multiple Charts to PDF
Hi nbp,
In this example, when using the "with" clause (With TBitmap.Create do) charts are being painted into bitmap's canvas, for example:
At the end, SaveToFile is also a TBitmap method.
In this example, when using the "with" clause (With TBitmap.Create do) charts are being painted into bitmap's canvas, for example:
Code: Select all
Chart1.Draw(Canvas,Rect(0,0,tmpW,tmpH));
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |