Page 1 of 1

PrintPartial and Legend.CustomPosition

Posted: Tue Feb 10, 2004 9:30 am
by 8576430
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

Posted: Tue Feb 24, 2004 4:52 pm
by Marjan
Hi, Perry.

This problem falls in the same category as custom positioned series marks. Custom positioned elements are not adjusted when chart is exported to image or printed.
As long as printed chart size is exactly the same as original chart, this is not a problem. But as soon as the chart is stretched, "automatic" chart elements are adjusted, but custom positioned elements stay at the same position. This can lead to elements being displayed outside chart printing region (or displayed at wrong position).
A workaround in this case is to create a temporary metafile (the same size as original chart) and then paint it to printer canvas by using StretchDraw method.
Also, check the "custom series marks" threads posted in this forum.

Posted: Mon Mar 01, 2004 10:40 am
by 8576430
Hi Marjan,

Thank you for the work around.
Do you know if this problem will be fixed?

Thanks again,
Perry

Posted: Thu Apr 15, 2004 2:06 pm
by Pep
Hi Perry,

we have this issue on our wish list to review it and see if we can do something.