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
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
andmouseout
, and every time we hover over the country, amouseover
event will occur. We will show theparent
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, themouseout
event will occur and will make the tooltip hidden again.