{
const container = html`<div">
<style>
div.tooltip {
position: fixed;
display: none;
padding: 12px 6px;
background: #fff;
border: 1px solid #333;
pointer-events: none;
}
</style>
</div>`;
const height = 900;
const path = d3
.geoPath()
.projection(
d3
.geoConicConformal()
.parallels([33, 45])
.rotate([96, -39])
.fitSize([width, height], zip_code_040114)
);
const svg = d3
.select(container)
.append("svg")
.attr("width", width)
.attr("height", height)
.style("background-color", "#fff")
.style("font", "10px sans-serif");
const div = svg.append("div").classed("tooltip", true);
const zipcodes = svg
.selectAll(".zips")
.data(zip_code)
.enter()
.append("path")
.style("fill", (d) => {
return "orange";
})
.attr("d", (d) => {
return path(d);
})
.style("stroke", "lightgrey")
.style("fill-opacity", 0.3)
.style("stroke-width", 0.7)
.style("stroke-opacity", 0.2);
const circle = svg
.selectAll("circle")
.data(zip_code)
.enter()
.append("circle")
.attr("transform", function (d) {
return "translate(" + path.centroid(d) + ")";
})
.attr("r", (d, i) => {
return scale(d.properties.percent);
})
.style("fill", "orange")
.on("mouseover", function (e, d) {
d3.select(this).style("fill", "red");
div
.style("top", e.clientY + "px")
.style("left", e.clientX + "px")
.style("display", "block");
})
.on("mouseout", function (e, d) {
d3.select(this).style("fill", "orange");
});
circle.append("title").text((d) => d.properties.ZIPCODE);
return container;
}