map = {
const width = 1000,
height = 750;
let huc8chosen = huc8fullnetwork.filter((d) => d.sourcehuc8 == huc8unit);
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("background-color", "white");
let g = svg.append("g").style("fill", "none").style("stroke", "#000");
var performat = d3.format(".1%");
const zoom = d3.zoom().scaleExtent([1, 8]).on("zoom", zoomed);
g.selectAll("path")
.data(HUC8)
.enter()
.append("path")
.style("stroke", "white")
.style("stroke-width", 0.5)
.style("fill", function (d) {
if (networksource != "SPARROW") {
return "steelblue";
} else {
let thishuc8 = huc8fate.filter(
(e) => e.huc8 == +d.properties.huc8int
)[0];
return thishuc8 == undefined
? "steelblue"
: +thishuc8.tn < +thishuc8.tnnew
? "gold"
: "steelblue";
}
})
.attr("class", "huc8")
.attr("d", path);
let gtitle = svg.append("g");
gtitle
.append("text")
.attr("x", 500)
.attr("y", 80)
.style("font-weight", "bold")
.style("font-size", 20)
.style("text-anchor", "middle")
.text(`HUC8 in Contiguous USA`);
function zoomed(event) {
const { transform } = event;
g.attr("transform", transform);
g.attr("stroke-width", 1 / transform.k);
}
return svg.node();
}