chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("font", "14px sans-serif");
const root = treemapLayout();
var treemapLayout = d3.treemap()
.size([width, height])
.paddingOuter(50)
(root);
treemap = data => d3.treemap()
.size([width, height])
.paddingOuter(50)
svg.selectAll('g rect')
.data(root.leaves())
.enter()
.append('rect')
.attr('x', d => d.x0)
.attr('y', d => d.y0)
.attr('width', d => d.x1 - d.x0)
.attr('height', d => d.y1 - d.y0)
.attr('fill', 'pink')
.style("stroke", "#000")
.attr('opacity', '0.35')
svg.selectAll('g rect')
.data(root.leaves())
.enter()
.append('text')
.text(d => d.data.country)
.attr('dx', d => d.x0)
.attr('dy', d => d.y0)
var nodes = svg.selectAll('g rect')
.selectAll('g')
.data(root.leaves())
.enter()
.append('g')
.attr('transform', d => 'translate(' + [d.x0, d.y0] + ')');
nodes
.append('rect')
.attr('width', function(d) { return d.x1 - d.x0; })
.attr('height', function(d) { return d.y1 - d.y0; });
nodes
.append('text')
.attr('dx', 4)
.attr('dy', 14)
.text(d => d.data.department);
svg.append('text').text('Treemap of Met data by Department')
.attr('x', 20)
.attr('y',40)
.style('font-weight', '600')
.style('font-size', '2rem')
return svg.node();
}