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
PrintPartial and Legend.CustomPosition
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.
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
http://www.steema.com
Hi Perry,
we have this issue on our wish list to review it and see if we can do something.
we have this issue on our wish list to review it and see if we can do something.
Pep Jorge
http://support.steema.com
http://support.steema.com