MarksTip and chart printing

TeeChart for ActiveX, COM and ASP
Post Reply
Luigi
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

MarksTip and chart printing

Post by Luigi » Tue Sep 21, 2004 12:20 pm

I'm using TeeChart Pro ActiveX versione 5 and VB6.
On a Gannt chart I'm showing MarksTip in order to display some information about Gannt segment.
User is allowed to move MarksTip (I used DragMarks tool). The problem is that when I print the chart, moved MarksTips are not printed in the correct position even if in print preview are displayed correctly.

Does anybody can suggest me any way to solve this problem ?

Best regards

Luigi

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

Post by Pep » Wed Sep 22, 2004 9:09 am

Hi Luigi,

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

To print custom-positioned objects out to the right positions you need to:
1) Position objects relative to other TeeChart objects
2) Create an EXE for test printing in VB
3) Draw your objects to the TeeChart Canvas using TeeChart's
On##Draw##() events , e.g.

Example :

Code: Select all

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

Private Sub Form_Load()
With TChart1
    .Aspect.View3D = False
    .AddSeries scBar
    .Series(0).FillSampleValues 10
    .Tools.Add tcAnnotate
    .Tools.Items(0).asAnnotation.Shape.CustomPosition = True
    .Environment.InternalRepaint
End With
End Sub

Private Sub TChart1_OnBeforeDrawSeries()
With TChart1
    .Canvas.ClipRectangle .Axis.Left.Position, 0, .Axis.Right.Position,
.Axis.Bottom.Position
End With
End Sub

Private Sub TChart1_OnSeriesBeforeDrawValues(ByVal SeriesIndex As Long)
With TChart1
    .Tools.Items(0).asAnnotation.Shape.Top = .Axis.Top.Position
    .Tools.Items(0).asAnnotation.Shape.Left =
.Series(0).CalcXPosValue(5)
    .Tools.Items(0).asAnnotation.Text = "Custom Position"
End With
End Sub

Luigi
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

Post by Luigi » Tue Oct 05, 2004 1:00 pm

Hi
Thanks for you suggestion. I could review your answer only today.

Is it possible to do what you suggest me also with marks tips ?
My problem is that I need to allow users to change marks tip position and send a correct print to the printer


Thank you very much

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

Post by Pep » Wed Oct 06, 2004 11:47 am

Hi Luigi,
Is it possible to do what you suggest me also with marks tips ?
Yes, using the same techniques.
Solutions:
1. Re-position the image relative to other TeeChart objects - unfortunately
this has to be done in events which are fired after the TChart has been
drawn.
2. Export the TeeChart to one of the Metafile formats and then use the
Windows API to print this metafile out to the printer.

Luigi
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

Post by Luigi » Tue Oct 12, 2004 3:20 pm

Hi Jose

I tried your suggestion about positioning marks tips relative to other objects in the chart. What happens is that on the screen the mark tips is correctly handled (if I scroll, marks tip is correctly scrolled with the chart); when I print out the chart marks tip I changed position of are printed shifted away from the the correct position that I can see on the screen.

What I'm doing wrong ?
The following is the code I use in the OnSeriesBeforeDrawValues event handler of the chart. Variables x, y, fromX, fromY ... are variables I use to store correct position of the mark tip (and his arrow) in the chart.
Thank you very much.

Private Sub TChart1_OnSeriesBeforeDrawValues(ByVal SeriesIndex As Long)
TChart1.Series(0).Marks.Positions.Position(0).Custom = True
TChart1.Series(0).Marks.Positions.Position(0).LeftTop.x = TChart1.Series(0).CalcXPosValue(x)
TChart1.Series(0).Marks.Positions.Position(0).LeftTop.y = TChart1.Series(0).CalcYPosValue(y)
TChart1.Series(0).Marks.Positions.Position(0).ArrowFrom.x = TChart1.Series(0).CalcXPosValue(fromX)
TChart1.Series(0).Marks.Positions.Position(0).ArrowFrom.y=TChart1.Series(0).CalcYPosValue(fromY)
TChart1.Series(0).Marks.Positions.Position(0).ArrowTo.x = TChart1.Series(0).CalcXPosValue(toX)
TChart1.Series(0).Marks.Positions.Position(0).ArrowTo.y = TChart1.Series(0).CalcYPosValue(toY)

End Sub

Post Reply