rowan.bradley
Posts: 33
Joined: Tue Oct 16, 2018 5:01 pm

Getting Point info when a point is clicked

If the user clicks on a point, how do I access the properties of the point that was clicked? These points have properties x, y, eventName, marker and some others. How do I access the point object so that I can use the properties?

What I'm trying to do is to have a window with some additional information about the point pop up when the point is clicked (i.e. more than the information in the tooltip).

Thanks - Rowan
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: Getting Point info when a point is clicked

Hi, Rowan,

You can use click event. You will see an object with your properties when you e.g console.log(this).
https://api.highcharts.com/highcharts/s ... ents.click

For the future - please don't duplicate the same questions in different threads. You got your answer here: https://forum.highcharts.com/highstock- ... rt-t41151/

Kind regards
Rafal Sebestjanski,
Highcharts Team Lead
rowan.bradley
Posts: 33
Joined: Tue Oct 16, 2018 5:01 pm

Re: Getting Point info when a point is clicked

Sorry if I have asked this question before and in a different thread. I thought that that thread had wandered in many different directions, and it might be easier for people if I separated this topic off.

I'm also sorry if I'm being exceedingly slow to get it. But neither the Y parameter of the point, nor the category (i.e. the X point) is what I need. I need the index of the point in the array of points. If I have this, then I can immediately access other properties of the point, which is what I need to do. If I have only the category value, I will have to search the whole array for that value, and it will be slower than it needs to be. How do I get the index of the point?

Thanks - Rowan
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: Getting Point info when a point is clicked

Rowan,

Actually, this question is so basic and has been asked so many times, that there is no need to create a separate topic. If you create one chart and have many questions about it, please stick to one thread ;)

Referring to your question about point info - you don't need any point's index. You have access to all your point's properties through the same object. Click on the point and look at your console: https://jsfiddle.net/BlackLabel/01ymptha/
But if you really, really want point's index, you can find it... here console.log(point.index)

Also, I gave you an example of how to display all point's info in the tooltip.

Kind regards.
Rafal Sebestjanski,
Highcharts Team Lead
susmita
Posts: 5
Joined: Sun Aug 16, 2020 3:26 pm

Re: Getting Point info when a point is clicked

Hello,
I want to fetch data associated with a point on mouseOver event but I am not able to track the point's data in the event object. Instead I am getting an entire array of all points of the map.

Can anyone please help me with this.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Getting Point info when a point is clicked

Hello susmita!

We appreciate you reaching out to us!

Sure, I'm happy to help you. :) I've modified a little the demo from the previous post, so now the point's data is displayed on mouseOver event. Does it meet your expectations? If no could you reproduce your problem in an online editor that I could work on?

Demo: https://jsfiddle.net/BlackLabel/ybeptg9j/

Let me know if that was what you were looking for!
Best regards.
Dominik Chudy
Highcharts Developer

Return to “Highcharts Stock”