$(function () {
// Get chart Point object from coordinates. Might not work very well with old browsers.
// TODO: IE needs clientX/Y instead of pageX/Y for elementFromPoint() method.
// The coords argument is an object containing x and y properties (axis values).
// The series argument is the series to look for points in.
Highcharts.Chart.prototype.getPointAtCoords = function (coords, series) {
var chart = this,
dataLabels = series.dataLabelsGroup && series.dataLabelsGroup.element,
dataLabelsParent,
insertionPoint,
el,
offset = HighchartsAdapter.offset(chart.container),
insertDataLabels = function () {
if (dataLabels) {
if (insertionPoint) {
dataLabelsParent.insertBefore(dataLabels, insertionPoint);
} else {
dataLabelsParent.appendChild(dataLabels);
}
}
};
// Make sure data labels are disabled until we have calculated the location of the lat/lon points.
// Otherwise, the document.getElementFromPoint() method might return the data label element.
if (dataLabels) {
insertionPoint = dataLabels.nextSibling;
dataLabelsParent = dataLabels.parentNode;
dataLabelsParent.removeChild(dataLabels);
}
var x = chart.xAxis[0].toPixels(coords.x) + offset.left,
y = chart.yAxis[0].toPixels(coords.y) + offset.top;
console.log("old:", coords.x, coords.y, "new:", x,y)
// Get SVG element at the point
el = document.elementFromPoint(x, y);
// We loop through the points of the chart to see if their SVG elements match
for (var i = 0, l = series.points.length; i < l; ++i) {
if (series.points[i].graphic.element === el) {
insertDataLabels();
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.