Hi Michael,
the problem is all custom positioned object (rectangles, text, series
marks) use screen pixels coordinates. While this is fine for screen it does
not work for printer. Why ? The reason for this is if you print, TeeChart
will internally change chart size (so that it fits in specified
printer.Canvas region). The result is Chart size will change but the custom
positioned items "positions" on printer canvas will remain the same (in
screen pixel coordinates). This will result in custom items being drawn at
wrong place. The solution : use the following method to print chart(s):
Code: Select all
var tmpMeta: TMetaFile;
OldColor : TColor;
begin
Chart1.BevelOuter := bvNone;
OldColor := Chart1.Color;
Chart1.Color := clNone;
tmpMeta := Chart1.TeeCreateMetafile(true,Chart1.ClientRect);
try
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth - 1,
Printer.PageHeight - 1),tmpMeta);
finally
Printer.EndDoc;
end;
finally
tmpMeta.Free;
Chart1.BevelOuter := bvRaised;
Chart1.Color := OldColor;
end;
end;