src/core/core.tooltip.js
function(elements, eventPosition) {
		var x = eventPosition.x;
		var y = eventPosition.y;
		var minDistance = Number.POSITIVE_INFINITY;
		var i, len, nearestElement;

		for (i = 0, len = elements.length; i < len; ++i) {
			var el = elements[i];
			if (el && el.hasValue()) {
				var center = el.getCenterPoint();
				var d = helpers.distanceBetweenPoints(eventPosition, center);

				if (d < minDistance) {
					minDistance = d;
					nearestElement = el;
				}
			}
		}

		if (nearestElement) {
			var tp = nearestElement.tooltipPosition();
			x = tp.x;
			y = tp.y;
		}

		return {
			x: x,
			y: y
		};
	}
function(elements, eventPosition) {
		var x = eventPosition.x;
		var y = eventPosition.y;
		var minDistance = Number.POSITIVE_INFINITY;
		var i, len, nearestElement;

		for (i = 0, len = elements.length; i < len; ++i) {
			var el = elements[i];
			if (el && el.hasValue()) {
				var center = el.getCenterPoint();
				var d = helpers.distanceBetweenPoints(eventPosition, center);

				if (d < minDistance) {
					minDistance = d;
					nearestElement = el;
				}
			}
		}

		if (nearestElement) {
			var tp = nearestElement.tooltipPosition();
			x = tp.x;
			y = tp.y;
		}

		return {
			x: x,
			y: y
		};
	}
function ( elements , eventPosition ) { var x = eventPosition . x ; var y = eventPosition . y ; var minDistance = Number . POSITIVE_INFINITY ; var i , len , nearestElement ; for ( i = 0 , len = elements . length ; i < len ; ++ i ) { var el = elements [ i ] ; if ( el && el . hasValue ( ) ) { var center = el . getCenterPoint ( ) ; var d = helpers . distanceBetweenPoints ( eventPosition , center ) ; if ( d < minDistance ) { minDistance = d ; nearestElement = el ; } } } if ( nearestElement ) { var tp = nearestElement . tooltipPosition ( ) ; x = tp . x ; y = tp . y ; } return { x : x , y : y } ; }
Gets the tooltip position nearest of the item nearest to the event position
@function Chart.Tooltip.positioners.nearest
@param elements {Chart.Element[]} the tooltip elements
@param eventPosition {object} the position of the event in canvas coordinates
@returns {object} the tooltip position
Gets the tooltip position nearest of the item nearest to the event position