I’m doing the Treemap Diagram and I’m using the Video Game dataset.
Here’s my code:
document.addEventListener("DOMContentLoaded", function() {
$.getJSON(
"https://cdn.rawgit.com/freeCodeCamp/testable-projects-fcc/a80ce8f9/src/data/tree_map/video-game-sales-data.json",
function(dataset) {
const w = 1000;
const h = 600;
const tooltip = d3
.select("body")
.append("div")
.attr("class", "tooltip")
.attr("id", "tooltip");
const container = d3
.select("body")
.append("svg")
.attr("height", h)
.attr("width", w);
for (let i=0; i < dataset.children.length; i++) {
container
.selectAll("rect")
.data(dataset.children[i].children)
.enter()
.append("rect")
.attr("class", "tile")
.attr("data-name", d => d.name)
.attr("data-category", d => d.category)
.attr("data-value", d => d.value);
}
}
);
});
However, I get only 15 rect
elements… Why is this so? What am I doing wrong> Any help would be appreciated!