Page 1 of 1

Problem with printing (Legend and annotation)

Posted: Tue Nov 23, 2004 12:29 pm
by 9524169
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

Posted: Tue Nov 23, 2004 2:01 pm
by Pep
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 

Posted: Tue Nov 30, 2004 8:54 am
by 9524169
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

Posted: Wed Dec 01, 2004 10:55 am
by Pep
Hi Daniel,

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