Here’s the project description: https://learn.freecodecamp.org/data-visualization/data-visualization-projects/visualize-data-with-a-treemap-diagram
Most d3.treemap examples I’ve found seem to have a dataset that already contains x0, x1, y0, and y1 values.
In those examples, the height of a treemap tile is calculated as d.y1 - d.y0 and the width as d.x1 - d.x0.
In the given dataset, however, I only have one numerical value for each node, the value of the Kickstarter pledge.
How do I calculate the height and width of a tile with only the overall pledge value, without those coordinate values?
UPDATE: A console.log on the root var revealed what the coordinate values are:
var root = d3.hierarchy(data)
.eachBefore(function(d) {
d.data.id = (d.parent ? d.parent.data.id + "." : "") + d.data.name;
})
.sum(sumByCount)
.sort(function(a, b) { return b.height - a.height || b.value - a.value; });
console.log("the root is: ");
console.log(root);