chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [-60, 0, width, height]);
var projection = d3
.geoMercator()
.fitSize([width - 60, height - 60], zips);
var path = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var path4 = d3.geoPath().projection(projection);
var path5 = d3.geoPath().projection(projection);
var path6 = d3.geoPath().projection(projection);
var path7 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path")
.data(zips.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "white")
.style('fill-opacity','.25')
.style("stroke-width", "1")
.style("stroke", "#ccc")
g.selectAll("path4") //d3 geopath
//svg
//.selectAll('path')
.data(leveltwo.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(25,117,164)")
.style('fill-opacity','.3')
.style("stroke-width", "0")
.style("stroke", "ccc")
g.selectAll("path5") //d3 geopath
//svg
//.selectAll('path')
.data(levelthree.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(25,117,164)")
.style('fill-opacity','.55')
.style("stroke-width", "0")
.style("stroke", "ccc")
g.selectAll("path6") //d3 geopath
//svg
//.selectAll('path')
.data(levelone.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(25,117,164)")
.style('fill-opacity','.15')
.style("stroke-width", "0")
.style("stroke", "ccc")
g.selectAll("path7") //d3 geopath
//svg
//.selectAll('path')
.data(levelfour.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(25,117,164)")
.style('fill-opacity','.8')
.style("stroke-width", "0")
.style("stroke", "ccc")
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(river5.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(22, 71, 164)")
.style('fill-opacity','.8')
.style("stroke-width", "1")
.style("stroke", "black")
//insert floodpoints into map
g.selectAll("circle") //d3 geopath
//svg
//.selectAll('path')
.data(floodpoint.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy", function(d) {return path.centroid(d)[1]})
.attr('r',3)
.attr("fill", "white")
.style('fill-opacity','1')
//insert floodgates into map
g.selectAll("circle") //d3 geopath
//svg
//.selectAll('path')
.data(floodgate.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy", function(d) {return path.centroid(d)[1]})
.attr('r',3)
.attr("fill", "orange")
.style('fill-opacity','0.85')
//insert streams into map
g.selectAll("path") //d3 geopath
//svg
//.selectAll('path')
.data(stream.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "blue")
.style('fill-opacity','0')
.style("stroke-width", "0.6")
.style("stroke", "rgb(22, 71, 164)")
.on('mouseover', addBox)
.on('mouseout', removeBox)
//add stream tool tip
var tooltip = svg.append("g");
function addBox(event, d) {
var centroid = path.centroid(d);
tooltip.call(
callout,
`${d.properties.STREAM_}
${d.properties.LENGTH}`
);
tooltip.attr("transform", "translate(" + centroid + ")");
}
function removeBox(event, d) {
tooltip.call(callout,null)
}
return svg.node();
}