Page 1 of 1

Drawlines Collection

Posted: Tue May 23, 2006 7:13 am
by 9530819
Hi

Using v7 activex control in a financial charting application. I use the Drawlines tool to enable users to create trendlines. I need to know how I can directly work with the Drawlines collection if possible so that I can:
1) Persist trendlines (ie. if user reloads a previous chart that had trendlines, automatically redraw them where they were)
2) Have interactivity on a mouse over event (tooltip popup with point value for example, as well as right-click menu)

Those are just two possiblilities. If I could directly access the drawlines collection I am sure I could add further functionality.

Thanks once again.

Posted: Tue May 23, 2006 8:08 am
by narcis
Hi Rossmc,

If you export a chart, containing a draw lines tool, to a native file and load it, the lines will be loaded as well.

To have interactivity you can do something as the code below. You can also access to the draw lines collection by using TChart2.Tools.Items(0).asDrawLine.Lines.Items array.

Code: Select all

Dim tmpX, tmpY As Integer

Private Sub Command1_Click()
    TChart1.Export.asNative.SaveToFile "e:\temp\tool.tee", True
End Sub

Private Sub Command2_Click()
    TChart2.ClearChart
End Sub

Private Sub Command3_Click()
    TChart2.Import.LoadFromFile "e:\temp\tool.tee"
End Sub

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 10
End Sub

Private Sub TChart2_OnDrawLineToolSelecting(ByVal Index As Long, ByVal AllowSelect As Boolean)
    Dim XVal, YVal As Double
    
    XVal = TChart2.Axis.Bottom.CalcPosPoint(tmpX)
    YVal = TChart2.Axis.Left.CalcPosPoint(tmpY)
    
    TChart2.Header.Text.Clear
    TChart2.Header.Text.Add CStr(XVal) & " - " & CStr(YVal)
End Sub

Private Sub TChart2_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    tmpX = X
    tmpY = Y
End Sub