Page 1 of 1

Legend/annotations tied to chart controls shift when printed

Posted: Mon Oct 25, 2004 12:46 pm
by 9524337
The following code displays a chart with open space on the right side and bottom of the chart area. In these open areas, the code displays a text annotation and the legend. When I print the chart from the print button on the TeeCommander bar, the legend and text annotation are not printed in the correct location. From other posts I have seen in the Forums, I tied the legend and text annotation to chart controls in hopes their locations would not shift when printed. Can you help me understand what I'm missing? Thank you so much!


Private Sub Form_Load()
Dim AnnoID As Integer

TeeCommander1.ChartLink = TChart1.ChartLink

With TChart1
.AddSeries (scLine)
.Series(0).FillSampleValues 10

.Panel.MarginUnits = muPercent
.Panel.MarginTop = 20
.Panel.MarginBottom = 20
.Panel.MarginLeft = 0
.Panel.MarginRight = 25

.Legend.Alignment = laBottom
.Legend.Top = TChart1.Axis.Bottom.Position + 300
.Legend.Left = TChart1.Axis.Left.Position + 10

AnnoID = .Tools.Add(tcAnnotate)
With .Tools.Items(AnnoID).asAnnotation
.Text = "Some text."
.Shape.Font.Name = "Ariel"
.Shape.Font.Color = vbBlack
.Shape.Left = TChart1.Axis.Left.Position + 375
.Shape.Top = TChart1.Axis.Top.Position + 100
End With

End With
End Sub[/img]

Posted: Tue Oct 26, 2004 8:18 am
by Pep
Hi,

have you treid to print from the EXE file ? You must generate the EXE to see a correct results.

legend/annotation still shifting

Posted: Tue Oct 26, 2004 12:18 pm
by 9524337
I had only been trying it from the development environment, but generating the exe, closing down the development environment, and running the stand-alone exe produced the same shifting of legend and annotation. The display of the chart in the print-preview looks great. Also, hitting the TeeCommander Copy button and pasting into Word produces a good display and printout. But for my application, I must be able to print directly from the TeeCommander Print button. More advice is much appreciated! :wink:

Posted: Tue Oct 26, 2004 5:56 pm
by Pep
Hi,

using the following code (from the Exe file) should work fine :

Code: Select all

Private Sub Form_Load()
Dim AnnoID As Integer
TeeCommander1.ChartLink = TChart1.ChartLink
With TChart1
.AddSeries (scLine)
.Series(0).FillSampleValues 10
.Panel.MarginUnits = muPercent
.Panel.MarginTop = 20
.Panel.MarginBottom = 20
.Panel.MarginLeft = 0
.Panel.MarginRight = 25
AnnoID = .Tools.Add(tcAnnotate)
.Legend.CustomPosition = True
End With
End Sub


Private Sub TChart1_OnBeforeDrawSeries()
With TChart1
.Legend.Top = TChart1.Axis.Bottom.Position - 100
.Legend.Left = TChart1.Axis.Left.Position + 10
With .Tools.Items(AnnoID).asAnnotation
.Text = "Some text."
.Shape.Font.Name = "Ariel"
.Shape.Font.Color = vbBlack
.Shape.Left = TChart1.Axis.Left.Position + 375
.Shape.Top = TChart1.Axis.Top.Position + 100
End With
End With
End Sub
Could you please test it ?

Legend/annotations tied to chart controls shift when printed

Posted: Tue Oct 26, 2004 8:13 pm
by 9524337
YES, now we're cooking with grease! :D Thank you, that works!

To sum it all up, to produce printouts where the legend and annotations are exactly as shown on the screen (WYSIWYG-What You See Is What You Get), you need to do three things:
1. Place all positioning statements in the OnBeforeDrawSeries event.
2. Tie the position of these objects to the position of TChart objects.
3. Compile the program and test it from the EXE. It will not print correctly from the development environment.

Hope this helps everyone with this issue!
Dean Darsey
DarseyTech@yahoo.com