Page 1 of 1
Drawing on Chart
Posted: Wed Jun 18, 2008 4:35 pm
by 9337074
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.
Posted: Thu Jun 19, 2008 8:59 am
by narcis
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