Page 1 of 1
Printing Problem
Posted: Fri Aug 11, 2006 8:11 pm
by 9334878
The printing in TChart is very strange. The printout will be different depending on the size of the window containing the graph. This is not a normal behavior. I would like the printout to be exactly the same each time I print my graph (font size, border, line width,...). Is there a way to achieve that?
Regards,
D Brillon
Posted: Sat Aug 12, 2006 9:48 am
by Pep
Hi Brillon,
yes, please take a look at this
link on our FAQ.
Posted: Sat Aug 12, 2006 2:53 pm
by 9334878
Hello Pep
I already tried that and it doest not work as I would expect. The size of the graph wil be ok but the fonts would not have a fixed size and the line width will change depending on the size of the graph windows. I want the behavior of the printout to be the same as the behaviour of the graph windows. If I change the size of the graph window, the fonts, the lines width, etc... does not changed.
Thanks
Posted: Mon Aug 14, 2006 9:59 am
by Pep
Hi Brillon,
perhaps the problem is you're using Canvas.Font.Size to set font "size" ?, when printing, you should always use Font.Height instead of Font.Size.
Something like this should work:
Chart1.Canvas.Font.Height = -13; // note the - sign!
Chart1.Canvas.TextOut(100,100,'Hello World');
Posted: Mon Aug 14, 2006 1:20 pm
by 9334878
Josep,
I don't think that's the problem because all aspect of the graph are changed. The line width the cursor, etc. Take a look at the result of printing the same graph first with a large window and secondly with a small window. (The results are generated using Printer.Canvas.StretchDraw as described in the FAQ )
Large window:
small window:
When the user want to print a graph from my application they want to have the same printout whatever the size of the window on the screen is.
I would like the print routine to do the same thing the draw window does but on the printer canvas.
Thanks,
David Brillon
Printing
Posted: Thu Oct 12, 2006 2:56 pm
by 9347345
I ran into this same issue. I resolved it by creating a 'Resize' function.
I basically Resize everything to allow the user to see the graph zoomed in or out, and when printing I pass Zoom = 100;
Here's some of the code lines:
Graph1.Font.Height := -Round(Int(8 * Zoom / 100));
Graph1.LeftAxis.LabelsFont.Height := -Round(Int(8 * Zoom / 100));
Graph1.BottomAxis.LabelsFont.Height := -Round(Int(8 * Zoom / 100));
Graph1.Legend.Font.Height := -Round(Int(8 * Zoom / 100));
Graph1.Title.Font.Height := -Round(Int(8 * Zoom / 100));
Graph1.Foot.Font.Height := -Round(Int(8 * Zoom / 100));
for X := 0 to Graph1.SeriesCount - 1 do
begin
//Graph1.Series[X].Marks.Font.Size := Round(Int(8 * Zoom / 100));
Graph1.Series[X].Marks.Font.Height := -Round(Int(8 * Zoom / 100));
if (GraphObject.View.BarMulti in [2, 3]) then
Graph1.Series[X].Marks.ArrowLength := -Round(Int(17 * Zoom /100))
else
Graph1.Series[X].Marks.ArrowLength := Round(Int(10 * Zoom /100));
if (Graph1.Series[X] is TPieSeries) then
begin
with Graph1.Series[X] as TPieSeries do
begin
if (not Circled) then
begin
if (GraphObject.View.PieXRadius > 0) then
CustomXRadius := Round(GraphObject.View.PieXRadius *
Zoom / 100);
if (GraphObject.View.PieYRadius > 0) then
CustomYRadius := Round(GraphObject.View.PieYRadius *
Zoom / 100);
end;
end;
end;
if (Graph1.Series[X] is TGaugeSeries) then
begin
with Graph1.Series[X] as TGaugeSeries do
begin
CustomXRadius := Round(134 * Zoom / 100);
CustomYRadius := Round(126 * Zoom / 100);
end;
end;
for Y := 0 to Graph1.Series[X].YValues.Count - 1 do
//Graph1.Series[X].Marks.Item[Y].Font.Size := Round(Int(8 *
Zoom / 100));
Graph1.Series[X].Marks.Item[Y].Font.Height := -Round(Int(8 *
Zoom / 100));
end;