Page 1 of 1

Map Chart

Posted: Fri May 05, 2017 6:48 pm
by 16678230
Hi

TeeChart Newbie here :)

I have a Map Chart on a window. I can hover over countries and they outline. I can click on a country and receive the OnClickSeries event. How do I change the colour of the country I clicked on?

Using TeeChart 2016

TIA

Re: Map Chart

Posted: Mon May 08, 2017 7:52 am
by yeray
Hello,

Here it is a simple example:

Code: Select all

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
End Sub

Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If SeriesIndex > -1 And ValueIndex > -1 Then
    If TChart1.Series(SeriesIndex).PointColor(ValueIndex) = vbRed Then
      TChart1.Series(SeriesIndex).PointColor(ValueIndex) = clTeeColor
    Else
      TChart1.Series(SeriesIndex).PointColor(ValueIndex) = vbRed
    End If
  End If
End Sub

Re: Map Chart

Posted: Mon May 08, 2017 8:17 am
by 16678230
Hi Yeray

Thanks for this. I have got your suggestion working. One problem I have with Steema Help Documentation is finding out what the properties and methods are for the various things. For example, you wrote in our reply:

TChart1.Series(SeriesIndex).PointColor(ValueIndex) = vbRed

Where can I find out these properties like PointColor etc.? I have been looking through the help files but cant seem to find this ... ?

Thank you.

JP

Re: Map Chart

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

It's difficult to have an example of every property. However, we use to recommend looking at the Fetures Demo program shipped with the installation to see the majority of features in action.
There's also the documentation, with a list of all the properties and methods. Ie, you can find the PointColor property in the online documentation, going to the TeeChart Pro ActiveX Library Reference -> TeeChartx -> Series -> Properties -> Point Color.

Re: Map Chart

Posted: Mon May 08, 2017 11:41 am
by 16678230
Hi Yeray

Thanks again. So how would I set the tooltip for a data point (i.e. a country) using a similar way as to PointColor()?

e.g. AX_TeeChartX.Series(ISeries).PointColor(ValueIndex) = RGB(255,123,32)

For example? Is it possible something similar for tooltip?

Re: Map Chart

Posted: Mon May 08, 2017 11:54 am
by yeray

Re: Map Chart

Posted: Mon May 08, 2017 12:08 pm
by 16678230
I'm sorry Yeray, but I dont see in the example how I set the text for any specific point (i.e. country) in the chart ? Sorry for being a newb ...

Re: Map Chart

Posted: Mon May 08, 2017 1:28 pm
by yeray
Hello,

The OnMarkTipToolGetText is fired every time the MarkTip tool is going to be drawn. When it is fired, you have the ValueIndex of the point (MouseValueIndex), and the Text before being modified.
That should be enough information to modify the Text as you want.

Code: Select all

Private Sub TChart1_OnMarkTipToolGetText(ByVal Tool As Long, Text As String)
  If MouseValueIndex > -1 Then
    Text = "Put the text you want for the ValueIndex: " + Str$(MouseValueIndex) + " here"
  End If
End Sub

Re: Map Chart

Posted: Mon May 08, 2017 2:37 pm
by 16678230
Yeray

Thanks. So to add a MarkTip Tool to the chart I need to us something like: TChart1.Tools.Add tcMarksTip

What is the value of the constant tcMarksTip ? Where do I find these in the help?

Thanks

Re: Map Chart

Posted: Mon May 08, 2017 2:55 pm
by 16678230
Yeray

Almost have it :)

I have added a MarkTip tool to the chart
I have the call to OnMarkTipToolGetText() working and can set the tooltip text.

However, I do not know how to convert the OnMouseMouse() x and y values into a country ValueIndex ? I can receive the OnMouseMouse() function but it only gives me x and y parameters, not a ValueIndex. How to find the ValueIndex from the x and y values?

Thanks!

Re: Map Chart

Posted: Tue May 09, 2017 6:33 am
by yeray
Hello,
JPTP wrote:What is the value of the constant tcMarksTip ? Where do I find these in the help?
You can find the value for each constant at the TeeChartDefines.h, at the "Utilities\New VC Classes" folder in the TeeChart installation path.
JPTP wrote:However, I do not know how to convert the OnMouseMouse() x and y values into a country ValueIndex ? I can receive the OnMouseMouse() function but it only gives me x and y parameters, not a ValueIndex. How to find the ValueIndex from the x and y values?
In the example here I used the series Clicked function to return the ValueIndex of the point at the given X, Y coordinates:

Code: Select all

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

Re: Map Chart

Posted: Tue May 09, 2017 6:12 pm
by 16680934
Hi Yeray

Thanks I did not notice there was more code in the code window you provided - didn't see the scroll bar. I have it all working for now. Thanks very much.

Is there any place where one can see an exhaustive list of available functions that one can call?

Thanks!

Re: Map Chart

Posted: Wed May 10, 2017 8:53 am
by yeray
Hello,
JPTP wrote: Is there any place where one can see an exhaustive list of available functions that one can call?
The options are:
- Online documentation including Tutorials and Library Reference. Documentation is also shipped with the installation for offline access.
- Compiled examples (with sources) shipped with the installation.
- IntellSense built-in the IDE of your choice to list properties or methods available for an object.

Re: Map Chart

Posted: Wed May 10, 2017 9:29 am
by 16680934
Thanks Yeray. I have been looking through those CHM help files but find them hard to find things I am looking for. Your help is awesome though. Thanks.

Any suggestion regarding changing the colour of the country outline highlight colour when mouse over a country? Currently it is orange on my system but I prefer to change the colour if possible (and outline line thickness).

Thanks

Re: Map Chart

Posted: Wed May 10, 2017 1:52 pm
by yeray
JPTP wrote:Any suggestion regarding changing the colour of the country outline highlight colour when mouse over a country? Currently it is orange on my system but I prefer to change the colour if possible (and outline line thickness).
I'll reply you here.