How to construct a 'retracement' tool on a chart?

TeeChart for ActiveX, COM and ASP
Post Reply
dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

How to construct a 'retracement' tool on a chart?

Post by dcurrier » Thu Dec 09, 2004 11:17 am

I'd like to invoke the drawing tool and do the following:

Hold down the mouse and get the starting coordinates

Drag to another vertical point

Release the mouse and programmatically draw a series of horizontal trend lines between the 2 y values.

Is there an example showing this or something similar that I may examine? Is using the drawing tool the way to do this?

David

(Using V6 Tchart and VB6)

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

Post by Pep » Fri Dec 10, 2004 8:28 am

Hi David,

do you mean something like this : ?

Code: Select all

Dim MDown
Private Sub Form_Load()
MDown = False
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    .Zoom.Enable = False
    .Axis.Left.SetMinMax 0, 10
    .Axis.Bottom.SetMinMax 0, 10
End With
End Sub

Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
MDown = True
TChart1.Series(0).AddXY TChart1.Axis.Bottom.CalcPosPoint(X), TChart1.Axis.Left.CalcPosPoint(Y), "", clTeeColor
End Sub

Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If MDown = True Then
    MDown = False
    TChart1.Series(0).AddXY TChart1.Axis.Bottom.CalcPosPoint(X), TChart1.Axis.Left.CalcPosPoint(Y), "", clTeeColor
End If
End Sub

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Fri Dec 10, 2004 11:45 am

Thanks for the sample. I was trying to actually use the drawing tools instead of a series.

I'm captuing the point from the mouse down and mouse up activity so all I need to do is invoke the drawing tools

I'm having problem with an error on the 'addline' method.

Code: Select all

        With MultiChart.Tools.Items(0).asDrawLine
            .EnableDraw = True
            .AddLine(100,50,200,50)
        End With
The actual values are in another table. I just put in some constants to show you the problem. This should draw a horizontal line.

I get an error in the IDE on the addline statement that says "Compile error - expecting ="

It looks OK to me.

Using VB6 and version 6 of Tchart.

Thanks, David

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

Post by Pep » Fri Dec 10, 2004 4:42 pm

Hi David,

could you please send me an example with which I can reproduce the problem "as is" here ? (please send it to the steema.public.attachments newsgroup or directly to my mail pep@steema.com).

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Fri Dec 10, 2004 9:22 pm

Pep,

I'll send you an email because right now I just cant even enter the code I sent without getting an error in the IDE.

Code: Select all

Private Sub Command1_Click()
        With TChart1.Tools.Items(0).asDrawLine
            .EnableDraw = True
            .AddLine(100,50,200,50)
        End With
End Sub
Maybe I'm doing something wrong altogether but it looks like I'm entering the proper values as indicated by the intellisense in VB 6

You'll see if you try to enter these lines.

Using V6.0.0.6

Thanks,

David

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Sat Dec 11, 2004 2:58 pm

Pep,

I downloaded the eval version of AX v7 and it seems to work the same way producing the same compile error.

V 5 also does the same thing.

David

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

Post by Pep » Mon Dec 13, 2004 7:01 am

Hi David,

yes please, send me it so I can reproduce it here. It works fine here using the following code :

Code: Select all

Private Sub Command1_Click()
With TChart1.Tools.Items(0).asDrawLine
    .AddLine TChart1.Axis.Bottom.Minimum, TChart1.Axis.Left.Minimum, TChart1.Axis.Bottom.Maximum, TChart1.Axis.Left.Maximum
End With
End Sub

Private Sub Form_Load()
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    .AddSeries scLine
    .Series(0).FillSampleValues (10)
    .Series(1).FillSampleValues (10)
    .Tools.Add tcDrawLine
End With
End Sub

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Mon Dec 13, 2004 11:23 am

Pep,

I'll give it a try here.

Why won't my Addline method work in the example?

I'll get back to you later when I get to the office.

Thanks, David

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Mon Dec 13, 2004 12:55 pm

Pep,

Your example helped. All I did was remove the parenthesis from the AddLine statement. In addition, I thought the coordinates that Addline wanted were the x,y points on the screen. I see from your example it wants the axis values.

Now that I'm past that next step, I can keep going.

One side benefit of me having this question was I finally downloaded V7 evaluation and got a chance to see some of the new stuff. I'll be upgrading soon!

Thanks,

David

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

Post by Pep » Mon Dec 13, 2004 3:33 pm

Hi David,

ok, I'm glad to know that works now.

Post Reply