TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Mon Dec 11, 2006 11:49 am
I am revisiting printing the chats I have. Mainly because I have had such a had time getting some small tweaks just right.
When I use the TeePreviewPanel.Print Method, the printout is great quality. I print out to a 11x17 sheet of paper which causes my charts to be bigger when printed. The code below works great however on larger size paper my charts are huge, while on 8.5x11 they are perfect size although not all the charts will fit onto 1 sheet.
Code:
Code: Select all
topc := 10;
botc := 70;
for i := 0 to charts - 1 do
begin
TeePreviewPanel1.Panels.Add(mychart[i]);
//mychart[i].Height:=Round(1.0*Printer.PageHeight*mychart[i].Width/Printer.PageWidth);
mychart[i].PrintProportional := False;
mychart[i].PrintMargins:=Rect(1,topc,1,botc);
topc := topc + 20;
botc := botc - 20;
end;
TeePreviewPanel1.Orientation := ppoPortrait;
TeePreviewPanel1.Repaint;
TeePreviewPanel1.Print;
Like I said the print is beautiful. I currently do a DrawToMetCanvas and its ok but nothing like this procedure as far as print quality. If I could get the chart sizes to scale the paper correctly this would be great.
Any help appreciated.
Tom
Tom
-
Pep
- Site Admin
- Posts: 3299
- Joined: Fri Nov 14, 2003 5:00 am
-
Contact:
Post
by Pep » Thu Dec 14, 2006 2:52 pm
Hi Tom,
a solution would be to change the Chart size (bigger size) before to print, this would also change the scale for the axis as you said. To solve this you will have to calculate which axis increment is used in the OnAfterDraw event and assign it before to print the Chart, similar to the following code :
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
inc:=chart1.LeftAxis.CalcIncrement;
end;
procedure TForm1.Button2Click(Sender: TObject);
var tmpMeta: TMetafile;
begin
Chart1.Height:=Round(1.0*Printer.PageHeight*Chart1.Width/Printer.PageWidth);
Chart1.Axes.Left.Increment:=inc;
tmpMeta := Chart1.TeeCreateMetafile(True,Chart1.ClientRect);
try
// Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
Printer.Canvas.StretchDraw(Rect(10,10,Printer.PageWidth - 10, Printer.PageHeight - 10),tmpMeta);
finally
Printer.EndDoc;
end;
finally
tmpMeta.Free;
end;
end;
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Fri Dec 15, 2006 12:02 pm
Pep wrote:Hi Tom,
a solution would be to change the Chart size (bigger size) before to print, this would also change the scale for the axis as you said. To solve this you will have to calculate which axis increment is used in the OnAfterDraw event and assign it before to print the Chart, similar to the following code :
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
inc:=chart1.LeftAxis.CalcIncrement;
end;
procedure TForm1.Button2Click(Sender: TObject);
var tmpMeta: TMetafile;
begin
Chart1.Height:=Round(1.0*Printer.PageHeight*Chart1.Width/Printer.PageWidth);
Chart1.Axes.Left.Increment:=inc;
tmpMeta := Chart1.TeeCreateMetafile(True,Chart1.ClientRect);
try
// Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
Printer.Canvas.StretchDraw(Rect(10,10,Printer.PageWidth - 10, Printer.PageHeight - 10),tmpMeta);
finally
Printer.EndDoc;
end;
finally
tmpMeta.Free;
end;
end;
Pep,
I already do this sort of thing. I mean using TeePreviewPanel to print. I tried the code with setting the chart height by rounding page height and all but no luck.
I really like the quality of the print using TeePreviewPanel.Print but getting a bunch of charts to come out the correct size is tricky.
Thanks,
Tom
Tom
-
Pep
- Site Admin
- Posts: 3299
- Joined: Fri Nov 14, 2003 5:00 am
-
Contact:
Post
by Pep » Wed Dec 27, 2006 12:18 pm
Hi Tom,
in that case, I think a trick could be to set the increment in the OnBeforePrint event of the Chart.
There you can also change the panels size.