PrintPartial and Legend.CustomPosition

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Perry
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: Holland

PrintPartial and Legend.CustomPosition

Post by Perry » 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

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Feb 24, 2004 4:52 pm

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.
Marjan Slatinek,
http://www.steema.com

Perry
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: Holland

Post by Perry » Mon Mar 01, 2004 10:40 am

Hi Marjan,

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

Thanks again,
Perry

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Apr 15, 2004 2:06 pm

Hi Perry,

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

Post Reply