Printing chart with legend

TeeChart for ActiveX, COM and ASP
Post Reply
ActiveX
Newbie
Newbie
Posts: 3
Joined: Wed Mar 03, 2004 5:00 am

Printing chart with legend

Post by ActiveX » Thu May 13, 2004 1:01 pm

Hi,

I'm having a problem with printing charts including legends, using TeeChart ActiveX version 6.0.0.4.

I have positioned the legend top-right. Left to the legend there is some header information. The chart is drawn below it. When I try printing the chart, the header information and the chart are printed, but not the legend. By the way, I'm positioning the header by using the chartwidth in combination with the legendwidth.

Am I doing something wrong? As far as I can see, the legend has to be part of the printjob, so I don't understand why it's not printed.

Thanks in advance,

Derk Lennips

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

Post by Pep » Thu May 13, 2004 1:41 pm

Hi Derk,

The problem is that all custom positioned object (rectangles, text, series marks) use screen pixels as coordinates. While this is fine for the screenit 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: 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

ActiveX
Newbie
Newbie
Posts: 3
Joined: Wed Mar 03, 2004 5:00 am

Post by ActiveX » Fri May 14, 2004 8:51 am

Ok, thanks.

Didn't get it work yet, but i've decided to not use the TeeChart's print function anyway. It happens to be that lineseries with linestyle "dash-dot" are not printed at all.

By the way, I believe that printing the legend at a custom position should not be my problem. I'd say that the legend is an object of TeeChart. Properties regarding legendposition are set by me, and then it's up to TeeChart to calculate the correct position for the printercanvas. That's it in my opinion anyway.

I'm now going to export charts to a bitmap, which I then print with my own functionallity. I'm afraid that it's the only way to print correctly from TeeChart.

Derk Lennips

Post Reply