It is important to note that 2 different input formats can be used to build a treemap:
Basic: from Csv
The most basic treemap you can do in d3.js. Only one level of a hierarchy is represented.
Input: csv format
Basic: from Json
The most basic treemap you can do in d3.js.
Input: Json format. R code to go from csv to json is provided.
Two main reasons for using interactivity in treemaps. i/ Switching from one dataset to the other. ii/ building a zoomable treemap that allows to declutter the figure when several levels of hierarchy exist.
A few blocks with more complicated codes to showcase the possibility of d3 for treemaps