Getting hand pixels values using gauge series

TeeChart for ActiveX, COM and ASP
Post Reply
yvb
Newbie
Newbie
Posts: 18
Joined: Mon Jul 13, 2009 12:00 am

Getting hand pixels values using gauge series

Post by yvb » Sun Feb 21, 2010 1:37 pm

Hi,
I am using Guage series. After diplaying a value by using:
m_Chart.Series(m_lSeriesId).AddXY(...) I see the hand in a specific correct postion pointing to value.

I would like to get the pixels coordinates of the end point of the hand.
How can I get it?

Thanks,
yvb

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Getting hand pixels values using gauge series

Post by Yeray » Mon Feb 22, 2010 4:39 pm

Hi yvb,

Here is an example of how you could find the end point of the hand in VB6. Note that I've hidden the pen and used the calculated end hand point to draw the line where the hand would be.

Code: Select all

Private Sub Form_Load() 
  TChart1.AddSeries scGauge
  TChart1.Series(0).asGauge.Value = 70
  TChart1.Series(0).Pen.Visible = False
End Sub

Private Sub TChart1_OnAfterDraw()
  Dim tmpRange, tmpAngle As Double
  Dim EndHandX, EndHandY As Integer
  
  Dim PI As Double
  PI = 4 * Math.Atn(1)
  
  With TChart1.Series(0).asGauge
    tmpRange = .Maximum - .Minimum
    If tmpRange = 0 Then
     tmpAngle = 0.5 * PI
    Else
     tmpAngle = PI / 180 * (360 - (.TotalAngle - ((.Value - .Minimum) * .TotalAngle / tmpRange)) + .RotationAngle)
    End If
        
    Dim tmpSin, tmpCos As Double
    tmpSin = Sin(tmpAngle)
    tmpCos = Cos(tmpAngle)
    
    EndHandX = .XCenter - Round(.XRadius * tmpCos) + Round(.HandDistance * tmpCos)
    EndHandY = .YCenter - Round(.YRadius * tmpSin) + Round(.HandDistance * tmpSin)
      
    TChart1.Canvas.Pen.Color = vbRed
    TChart1.Canvas.DrawLine .XCenter, .YCenter, EndHandX, EndHandY
  End With
End Sub
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply