PrintPartial and Legend.CustomPosition
Posted: Tue Feb 10, 2004 9:30 am
Hi,
I have a project where I need to print several TDBcharts on one page.
I do this with PrintPartialCanvas where I calculate the Rect coordinates for each Chart based on the Pageheight and PageWidth. This works perfect with only one problem.
For displaying the DBCharts on the Form I set for each DBChart the Legend.CustomPosition to True and in the OnBeforeDrawSeries event I set the Top and Left of the Legend:
(Sender as TDBChart).Legend.Left := (Sender as TDBChart).Axes.Left.PosAxis;
(Sender as TDBChart).Legend.Top := 17;
On the Form the Legend is nicely postioned along the Right Axis.
But when I print the charts then the charts are printed correct over the page but there are no Legends!
I managed to find the reason with the following example:
One DBChart with Legend.CustomPosition:= True;
And the Legend Position to Top.
Place the above code in the OnBeforeDrawSeries.
Place a button with the following code:
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
DBChart1.PrintPartialCanvas(Printer.Canvas, Rect(0,
0,
Printer.PageWidth,
Printer.PageHeight)
);
finally
Printer.EndDoc();
end;
Start the application an press the button. It will print the chart with Legend on the page.
Now change the Rect to :
Rect(200,400,Printer.PageWidth, Printer.PageHeight)
Start the application again and press the button.
Now you see that the second print the chart is some pixels lower but the Legend not! It disappears!
My question:
What can I do to get the Legend printed anyway? Keeping in mind that the custom position is maintained.
Thanks in advance,
Perry
I have a project where I need to print several TDBcharts on one page.
I do this with PrintPartialCanvas where I calculate the Rect coordinates for each Chart based on the Pageheight and PageWidth. This works perfect with only one problem.
For displaying the DBCharts on the Form I set for each DBChart the Legend.CustomPosition to True and in the OnBeforeDrawSeries event I set the Top and Left of the Legend:
(Sender as TDBChart).Legend.Left := (Sender as TDBChart).Axes.Left.PosAxis;
(Sender as TDBChart).Legend.Top := 17;
On the Form the Legend is nicely postioned along the Right Axis.
But when I print the charts then the charts are printed correct over the page but there are no Legends!
I managed to find the reason with the following example:
One DBChart with Legend.CustomPosition:= True;
And the Legend Position to Top.
Place the above code in the OnBeforeDrawSeries.
Place a button with the following code:
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
DBChart1.PrintPartialCanvas(Printer.Canvas, Rect(0,
0,
Printer.PageWidth,
Printer.PageHeight)
);
finally
Printer.EndDoc();
end;
Start the application an press the button. It will print the chart with Legend on the page.
Now change the Rect to :
Rect(200,400,Printer.PageWidth, Printer.PageHeight)
Start the application again and press the button.
Now you see that the second print the chart is some pixels lower but the Legend not! It disappears!
My question:
What can I do to get the Legend printed anyway? Keeping in mind that the custom position is maintained.
Thanks in advance,
Perry