Page 1 of 1

Display a Country Value On Map Chart

Posted: Mon May 08, 2017 9:27 am
by 16678230
Hello

(Newbie here)

I have a map chart on a window. When the user hovers the mouse over a country how I can display a value associated with that country?

Thank you

Re: Display a Country Value On Map Chart

Posted: Mon May 08, 2017 10:50 am
by yeray
Hello,

You can use a MarksTip tool to show a tip when you move the mouse over the shapes/countries.
Then, you can use the OnMouseMove event to get the ValueIndex of the shape/country below the mouse and store it (ie MouseValueIndex).
And then you can use that index stores at OnMarkTipToolGetText to modify the Text string that will be shown.
Ie:

Code: Select all

Dim MouseValueIndex As Integer

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
 
  TChart1.AddSeries scWorld
  TChart1.Series(0).asWorld.Map = wmEurope
  TChart1.Series(0).FillSampleValues
  
  TChart1.Tools.Add tcMarksTip
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  MouseValueIndex = TChart1.Series(0).Clicked(X, Y)
End Sub

Private Sub TChart1_OnMarkTipToolGetText(ByVal Tool As Long, Text As String)
  If MouseValueIndex > -1 Then
    Text = TChart1.Series(0).PointLabel(MouseValueIndex) + " " + Str$(MouseValueIndex)
  End If
End Sub