TreeMap Test #5 & #6


I’m having trouble passing tests #5 & #6 for my TreeMap project.

For test #5 (Each tile should have the properties “data-name”, “data-category”, and “data-value” containing their corresponding name, category, and value) when I inspect each ‘rect’ I can see each property with it’s associated value. I can’t figure out why it won’t pass when those values are there.

For test #6 (The area of each tile should correspond to the data-value amount: tiles with a larger data-value should have a bigger area) it’s working visually, but I’m not sure why it won’t pass the test.

Here is a link to my Codepen:

Any help would be appreciated!


1 Like

I am having exactly the same problem. Can anybody help? It really a pain because as he say when inspecting the rect has these “data” properties

1 Like

take a look at here D3 TreeMap Diagram - Test #6 won't pass

1 Like


Any news on this? It seems that I have exactly same issue.

1 Like

Taylor, I think the problem is that in line 66 you’re using root.descendants() which includes the upper level categories (Wii, X360), so when the test looks for a data-name, for example, it will find it blank, since only the deeper level (the leaves) will have them. I used root.leaves() instead of root.descendants(), and it passed all tests. However, this change will cause labels to disappear unless you adjust the part of your code that hides labels. I also could not see the legend displayed, but I think I might know why. Hope this helps you too, ededals.

1 Like

Wow, thanks for that answer raphaeluziel! I always find it interesting how one’s solution can ‘appear’ completely right, but fail tests because of something happening in the background that only matters for the sake of the tests. This fixed my #5 and #6 right up.

1 Like

I’m so happy my answer was of help, Destro168! And agreed, as long as your solution works, the tests don’t really matter.

@raphaeluziel, thanks for the help! Your solution cleared it right up (though for some reason all my text is now invisible, but I’ll look into it). Not sure how I missed this since I used root.leaves() later in my code already :blush: