score:1

Accepted answer

body.In your mouseover event you can get the mouse position with pageX and pageY. Then you know where the mouse is on the screen. With this information you can create a div and position it where the mouse is. You can use your html string that is returned from createLegendTooltip and apply it to the div with .innerHTML

Very generic example below. Theres more you have to do. For example set the z-index and also creates a function that updates the position of the coolDiv if you want it to move when the mouse moves.

var coolDiv = document.createElement('div');
coolDiv.innerHTML = createLegendTooltip(data);
coolDiv.style.left = yourValueYouGetFrom_pageX;
coolDiv.style.top = yourValueYouGetFrom_pageY;
document.body.appendChild(coolDiv);

Related Query

More Query from same tag