Drawing on Chart

TeeChart for ActiveX, COM and ASP
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Drawing on Chart

Post by McMClark » Wed Jun 18, 2008 4:35 pm

I would like to enable a user too highlight a part of a graph by draw a box or circle around a section of the chart. I have tried to use the rectangle tool but at runtime the only effect I get is to in act the zoom feature. If the rectangle is the right tool then how do I enable it? I have also tried the annotation tool but I can not enact it.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 19, 2008 8:59 am

Hi McMClark,

In that case you can use custom drawing doing something like this:

Code: Select all

Option Explicit

Dim X0, Y0, X1, Y1 As Integer

Private Sub Form_Load()
    TeeCommander1.Chart = TChart1
    
    TChart1.AddSeries scPoint
    TChart1.Series(0).FillSampleValues 10
    
    X0 = -1
    Y0 = -1
    
    TChart1.Zoom.Enable = False
End Sub

Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    X0 = X
    Y0 = Y
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    X1 = X
    Y1 = Y
    
    If X0 <> -1 And Y0 <> -1 Then
        TChart1.Canvas.Brush.Style = bsClear
        TChart1.Canvas.Rectangle X0, Y0, X1, Y1
        TChart1.Environment.InternalRepaint
    End If
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 X0 <> -1 And Y0 <> -1 Then
        TChart1.Canvas.Brush.Style = bsClear
        TChart1.Canvas.Rectangle X0, Y0, X1, Y1
    End If
    
    X0 = -1
    Y0 = -1
End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply