Page 1 of 1

Multiple Charts to PDF

Posted: Fri Apr 10, 2009 8:35 pm
by 9532498
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.

Posted: Sat Apr 11, 2009 3:14 pm
by 15052934
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

Posted: Fri Jan 29, 2010 8:57 pm
by 9532498
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

Re: Multiple Charts to PDF

Posted: Mon Feb 01, 2010 9:22 am
by narcis
Hi nbp,

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));
At the end, SaveToFile is also a TBitmap method.