client/splunk.ui.charting.js
function placeBox(boxWidth, boxHeight, outerLeft, outerTop, outerWidth, outerHeight, point) {
	// keep the box within the chart area
	var pointX = point.x,
		pointY = point.y,
		x = pointX - boxWidth + outerLeft - 25,
		y = pointY - boxHeight + outerTop + 10,
		alignedRight;

	// it is too far to the left, adjust it
	if (x < 7) {
		x = outerLeft + pointX + 15;
	}

	// Test to see if the tooltip is to far to the right,
	// if it is, move it back to be inside and then up to not cover the point.
	if ((x + boxWidth) > (outerLeft + outerWidth)) {
	    
	    // PATCH by Simon Fishel
	    //
	    // if the tooltip is too wide for the plot area, clip it left not right
	    //
	    // - x -= (x + boxWidth) - (outerLeft + outerWidth);
	    // + if(boxWidth > outerWidth) {
        // +     x = 7;
        // + }
	    // + else {
        // +     x -= (x + boxWidth) - (outerLeft + outerWidth);
        // + }
	    
	    if(boxWidth > outerWidth) {
	        x = 7;
	    }
	    else {
	        x -= (x + boxWidth) - (outerLeft + outerWidth);
	    }
		y -= boxHeight;
		alignedRight = true;
	}

	if (y < 5) {
		y = 5; // above

		// If the tooltip is still covering the point, move it below instead
		if (alignedRight && pointY >= y && pointY <= (y + boxHeight)) {
			y = pointY + boxHeight - 5; // below
		}
	} else if (y + boxHeight > outerTop + outerHeight) {
		y = outerTop + outerHeight - boxHeight - 5; // below
	}

	return {x: x, y: y};
}
function placeBox(boxWidth, boxHeight, outerLeft, outerTop, outerWidth, outerHeight, point) {
	// keep the box within the chart area
	var pointX = point.x,
		pointY = point.y,
		x = pointX - boxWidth + outerLeft - 25,
		y = pointY - boxHeight + outerTop + 10,
		alignedRight;

	// it is too far to the left, adjust it
	if (x < 7) {
		x = outerLeft + pointX + 15;
	}

	// Test to see if the tooltip is to far to the right,
	// if it is, move it back to be inside and then up to not cover the point.
	if ((x + boxWidth) > (outerLeft + outerWidth)) {
	    
	    // PATCH by Simon Fishel
	    //
	    // if the tooltip is too wide for the plot area, clip it left not right
	    //
	    // - x -= (x + boxWidth) - (outerLeft + outerWidth);
	    // + if(boxWidth > outerWidth) {
        // +     x = 7;
        // + }
	    // + else {
        // +     x -= (x + boxWidth) - (outerLeft + outerWidth);
        // + }
	    
	    if(boxWidth > outerWidth) {
	        x = 7;
	    }
	    else {
	        x -= (x + boxWidth) - (outerLeft + outerWidth);
	    }
		y -= boxHeight;
		alignedRight = true;
	}

	if (y < 5) {
		y = 5; // above

		// If the tooltip is still covering the point, move it below instead
		if (alignedRight && pointY >= y && pointY <= (y + boxHeight)) {
			y = pointY + boxHeight - 5; // below
		}
	} else if (y + boxHeight > outerTop + outerHeight) {
		y = outerTop + outerHeight - boxHeight - 5; // below
	}

	return {x: x, y: y};
}
function placeBox ( boxWidth , boxHeight , outerLeft , outerTop , outerWidth , outerHeight , point ) { // keep the box within the chart area
 var pointX = point . x , pointY = point . y , x = pointX - boxWidth + outerLeft - 25 , y = pointY - boxHeight + outerTop + 10 , alignedRight ; // it is too far to the left, adjust it
 if ( x < 7 ) { x = outerLeft + pointX + 15 ; } // Test to see if the tooltip is to far to the right,
 // if it is, move it back to be inside and then up to not cover the point.
 if ( ( x + boxWidth ) > ( outerLeft + outerWidth ) ) { // PATCH by Simon Fishel
 //
 // if the tooltip is too wide for the plot area, clip it left not right
 //
 // - x -= (x + boxWidth) - (outerLeft + outerWidth);
 // + if(boxWidth > outerWidth) {
 // +     x = 7;
 // + }
 // + else {
 // +     x -= (x + boxWidth) - (outerLeft + outerWidth);
 // + }
 if ( boxWidth > outerWidth ) { x = 7 ; } else { x -= ( x + boxWidth ) - ( outerLeft + outerWidth ) ; } y -= boxHeight ; alignedRight = true ; } if ( y < 5 ) { y = 5 ; // above
 // If the tooltip is still covering the point, move it below instead
 if ( alignedRight && pointY >= y && pointY <= ( y + boxHeight ) ) { y = pointY + boxHeight - 5 ; // below
 } } else if ( y + boxHeight > outerTop + outerHeight ) { y = outerTop + outerHeight - boxHeight - 5 ; // below
 } return { x : x , y : y } ; }
Utility method extracted from Tooltip code that places a tooltip in a chart without spilling over
and not covering the point it self.
Utility method extracted from Tooltip code that places a tooltip in a chart without spilling over and not covering the point it self .