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...
We'll cover the following...
Solution
Explanation
As shown in the above code:
- Lines 46-50: We have defined a tooltip with the text
tooltipin it, and we have made it hidden until some event occurs. - Lines 74-79: We have defined two event listeners,
mouseoverandmouseout, and every time we hover over the country, amouseoverevent will occur. We will show theparentname of the rectangle, which, in this case, is the name of the continent. We will also make it visible. When we leave the rectangle, themouseoutevent will occur and will make the tooltip hidden again.