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 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("path3")
.data(river2.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "rgb(0, 0, 212)")
.style('fill-opacity','.2')
.style("stroke-width", "1")
.style("stroke", "black")
g.selectAll("circle")
.data(wasteC.features)
.enter()
.append("circle")
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy", function(d) {return path.centroid(d)[1]})
.attr('r',5)
.attr("fill", "rgb(46, 219, 112)")
.style('fill-opacity','1')
g.selectAll("circle")
.data(waterQ.features)
.enter()
.append("circle")
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy", function(d) {return path.centroid(d)[1]})
.attr('r',5)
.attr("fill", "rgb(102, 0, 204)")
.style('fill-opacity','1')
g.selectAll("path4")
.data(wasteQ.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "rgb(251, 250, 212)")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "#ccc")
.on('mouseover', addfill)
.on('mouseleave', removefill)
var tooltip = svg.append("g");
function addBox2(d) {
var centroid = path.centroid(d);
tooltip.call(
callout,
`${d.properties[2554]}
${d.properties.waste_id}`
);
tooltip.attr("transform", "translate(" + centroid + ")");
}
function addBox(event, d) {
var centroid = path.centroid(d);
tooltip.call(
callout,
`${d.properties.STREAM_}
${d.properties.LENGTH}, ${d.properties.LENGTH}`
);
tooltip.attr("transform", "translate(" + centroid + ")");
}
function removeBox(event, d) {
tooltip.call(callout,null)
}
function addfill(event,d) {
d3.select(this).style("fill", "rgb(111,143,123)")
d3.select(this).style('fill-opacity', '0.75')
svg
.append('text')
.attr("class","labels")
.attr('x','100')
.attr('y','100')
.attr('font-size','.85em')
.text(d.properties.dname_e)
addBox2(d)
}
function removefill(event,d) {
d3.selectAll('text.labels')
d3.select(this).style("fill", "white")
d3.select(this).style('fill-opacity', '.25')
removeBox2(d)
}
function removeBox2(event, d) {
tooltip.call(callout,null)
}
return svg.node();
}