I am building a line chart and I would like, when I click on a point of the line, to display a popup containing some data about this point. The issue I try to resolve is to get the id, the series associated with this point or something like that.
Here is my code :
plotOptions: {
column: {
pointWidth: 20
},
series: {
cursor: 'pointer',
events: {
click: function(event) {
requestData(event.point);
}
}
}
I tried
requestData(this.point)
,
requestData(this.point.id)
also but it doesn't work.
How do we get the id of a point ?
Thanks a lot.
According to the docs, event.point holds a pointer to the nearest point on the graph.
So I'd write the
event.point
to the console, and see what's available.From the docs:
Example based on the example from the docs: http://jsfiddle.net/5nTYd/
Click a point, and check the console.
To return the 'ID' of the selected point on the chart use the 'X' value:
See an example here: http://jsfiddle.net/engemasa/mxRwg/
i found this old post in my search to ==>add a marker to a point when i click a Highcharts "Trend Line" [in examples: "line-time-series"] chart[when i click anywhere on the drawn line itself]. well, without showing you too much code, look in the
if you would like more detail, i'm happy to provide!
I had the same problem ... if I understand correctly. My solution is this, to get the id of the series ... See if it helps ...
I just did this by passing 3 objects into the series data array and then pulling it out of the object's config attribute from the click.
So you can construct your series data something like this:
In the data attribute above the 1st element is the date (x), the 2nd element is another data point (y), and the 3rd is the id of the object that represent that data object. This "z" will not show up on the graph but will show up as the 3rd element in the config array. For example: using plotOptions point attribute to capture the click, the ID of the object is in the alert as this.config[2]