Problem with printing (Legend and annotation)

TeeChart for ActiveX, COM and ASP
Post Reply
Daniel
Newbie
Newbie
Posts: 2
Joined: Tue Sep 14, 2004 4:00 am
Location: Sweden
Contact:

Problem with printing (Legend and annotation)

Post by Daniel » Tue Nov 23, 2004 12:29 pm

Hi,

I have a problem with the print function. We use the internal functions to modify the chart during runtime for our users. We also use the internal function to print.

If I have an annotation object over the axis and a legend on a common line chart and try to print the the chart the legend and annotation is missing compleatly.

If I use the print preview feature and resize the chart to cover the complete page the objects prints perfectly.

I user the Windows XP theme on all charts and the ActiveX version of TeeChart 7.0

Best Regards
Daniel Larsson
Sweden

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

Post by Pep » Tue Nov 23, 2004 2:01 pm

Hi Daniel,

the problem is that all custom positioned object (rectangles, text, series marks) use screen pixels as coordinates. While this is fine for the screen it does not work for a printer. The reason is that when you print, TeeChart will internally change the chart size so that it fits in specified printer. Canvas region. The result is that the Chart size will change but the custom positioned items "positions" on the printer canvas will remain the same (in screen pixel coordinates). This will result in custom items being drawn in the wrong place.

To solve this :
1. Make sure these objects are all placed relative to non-Canvas TChart objects (Axes, Headers, Series Points etc.) rather than in absolute pixel values.
2. To see this work please create an .exe file from your VB project and print from there.

A simple example printing custom Annotation tools could be the following :

Code:

Code: Select all

Private Sub Command1_Click() 
TChart1.Printer.ShowPreview 
End Sub 

Private Sub Form_Load() 
With TChart1 
    .AddSeries scLine 
    .Series(0).FillSampleValues 10 
    .Tools.Add tcAnnotate 
    With .Tools.Items(0).asAnnotation 
        .Text = "HELLO" 
    End With 
End With 
End Sub 

Private Sub TChart1_OnBeforeDrawSeries() 
With TChart1 
    With .Tools.Items(0).asAnnotation 
        .Shape.CustomPosition = True 
        .Shape.Left = TChart1.Axis.Left.Position - 30 
        .Shape.Top = TChart1.Axis.Top.Position - 30 
    End With 
End With 
End Sub 

Daniel
Newbie
Newbie
Posts: 2
Joined: Tue Sep 14, 2004 4:00 am
Location: Sweden
Contact:

Post by Daniel » Tue Nov 30, 2004 8:54 am

Hi again,

The problem is that we let our users use the builtin "designer" tool.
The user themself change the position with your tool. We dont do any chart formatting with code due to the excellent designer tool.

Best Regards
Daniel Larsson

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

Post by Pep » Wed Dec 01, 2004 10:55 am

Hi Daniel,

in that case I think the only solution could be to reposition them in the OnBeforePrint event.

Post Reply