heatmap = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width + margin.left + margin.right, height + margin.top + margin.bottom])
.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
svg.selectAll("rect")
.data(airportDelays)
.enter().append("rect")
.attr("x", d => xScale(d.airport))
.attr("y", d => yScale(d.delayRate))
.attr("width", d => sizeScale(d.flights))
.attr("height", d => height - yScale(d.delayRate))
.attr("fill", d => colorScale(d.delayRate))
.on("mouseover", (event, d) => {
tooltip.style('opacity', 1);
tooltip.html(`Airport: ${d.airport}<br>Delay Rate: ${d.delayRate}<br>Flights: ${d.flights}`)
.style('left', `${event.pageX}px`)
.style('top', `${event.pageY - 28}px`);
})
.on("mouseout", () => tooltip.style('opacity', 0));
return svg.node();
}