Drawing on Chart
Drawing on Chart
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.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi McMClark,
In that case you can use custom drawing doing something like this:
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 |
Instructions - How to post in this forum |