Solution Review: Add Tooltip to a Treemap

This review provides a detailed analysis to solve the 'Add Tooltip to a Treemap' challenge.

We'll cover the following

Solution

Solution

Explanation

As shown in the above code:

  • Line 45-49: We have defined a tooltip with the text tooltip in it, and we have made it hidden until some event occurs.
  • Line 73-78: We have defined two event listeners, mouseover and mouseout, and every time we hover over the country, a mouseover event will occur. We will show the parent name of the rectangle, which, in this case, is the name of the continent. We will also make it visible. When we leave the rectangle, the mouseout event will occur and will make the tooltip hidden again.