chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [-60, 0, width, height]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], zips);
var path = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
svg.selectAll('line')
.data(RHY.features)
.enter()
.append('line')
.attr('x1',function(d) {return path.centroid(d)[0]})
.attr('y1',function(d) {return path.centroid(d)[1]})
.attr('x2',52)
.attr('y2',function(d,i){return i*6+20})
.attr('stroke-width','.3')
.attr('stroke-opacity','0.8')
.style('stroke','rgb(255,165,0)')
svg.selectAll('line')
.data(MIH.features)
.enter()
.append('line')
.attr('x1',function(d) {return path.centroid(d)[0]})
.attr('y1',function(d) {return path.centroid(d)[1]})
.attr('x2',52)
.attr('y2',function(d,i){return i*6+70})
.attr('stroke-width','0.3')
.attr('stroke-opacity','.2')
.style('stroke','rgb(21,27,84)')
var g = svg.append("g").attr("id", "paths");
g.selectAll("path")
.data(zips.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.attr("fill", d => color(d.properties.POPULATION))
.style('fill-opacity','0.3')
.style("stroke", "rgb(255,250,240)")
.attr('stroke-width','0.3')
g.selectAll("circle")
.data(zips.features)
.enter()
.append("circle")
.attr('cx',function(d){return path.centroid(d)[0]})
.attr('cy',function(d){return path.centroid(d)[1]})
.attr('r',function(d){return d.properties.POPULATION/10000})
.style("fill", "none")
.style('fill-opacity','.3')
.attr('stroke-opacity','.6')
.style("stroke", "rgb(255,250,240)")
g.selectAll("path2")
.data(IHDA.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "rgb(21,27,84)")
.style('fill-opacity','.25')
.style("stroke-width", ".2")
.style("stroke", "rgb(21,27,84)")
.on("mouseover", addFill)
.on("mouseleave", removeFill);
g.selectAll("path2")
.data(RHY.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style('fill-opacity','5')
.style("stroke-width", ".15")
.style("stroke", "rgb(255,165,0)")
.style("fill", "rgb(255,165,0)")
g.selectAll("path2")
.data(MIH.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "rgb(21,27,84)")
.style('fill-opacity','0.8')
.style("stroke-width", ".2")
.style("stroke", "rgb(21,27,84)")
svg.selectAll('text')
.data(RHY.features)
.enter()
.append('text')
.attr('x','50')
.attr('y',function(d,i){return i*6+20})
.attr('font-size','.25em')
.attr('text-anchor','end')
.text(function(d){return d.properties.divisionna})
svg.append('text')
.attr('x','550')
.attr('y','850')
.attr('font-size','1.75em')
.style('font-family', 'verdana')
.attr('fill', 'rgb(0,0,0)')
.attr('font-weight', 'bold')
.text('THE CITY EMBRACE')
svg.append('text')
.attr('x','270')
.attr('y','870')
.attr('font-size','0.75em')
.style('font-family', 'verdana')
.attr('fill', 'rgb(100,100,100)')
.attr('font-weight', 'light')
.text('A Guide to Settle Runaway Homeless Youth from Crisis Centers to Nearby Inclusionary Housings')
svg.append('text')
.attr('x','0')
.attr('y','10')
.attr('font-size','0.55em')
.style('font-family', 'verdana')
.attr('fill', 'rgb(255,165,0)')
.attr('font-weight', 'bold')
.text('Runaway Homeless Youth Centers')
svg.append('text')
.attr('x','0')
.attr('y','150')
.attr('font-size','0.55em')
.style('font-family', 'verdana')
.attr('fill', 'rgb(21,27,84)')
.attr('font-weight', 'bold')
.text('Mandatory Inclusionary Housing Sites')
svg.selectAll('text')
.data(MIH.features)
.enter()
.append('text')
.attr('x','50')
.attr('y',function(d,i){return i*6+70})
.attr('font-size','.25em')
.attr('text-anchor','end')
.text(function(d){return d.properties.project_nam})
function addFill(event,d) {
d3.select(this).style("fill", "rgb(195,88,23)")
d3.select(this).style('fill-opacity','.8')
svg.append('text')
.attr('x','700')
.attr('y','30')
.attr('font-size','0.65em')
.attr('fill', 'rgb(0,0,0)')
.attr('font-weight', 'bold')
.text('Inclusionary Housing Designated Area')
svg
.append('text')
.attr("class","labels")
.attr('x','700')
.attr('y','50')
.attr('font-size','.65em')
.text(d.properties.project_nam)
svg.append('text')
.attr('x','700')
.attr('y','70')
.attr('font-size','0.65em')
.attr('fill', 'rgb(0,0,0)')
.attr('font-weight', 'bold')
.text('Project Adopted Date')
svg
.append('text')
.attr("class","labels")
.attr('x','700')
.attr('y','90')
.attr('font-size','.65em')
.text(d.properties.date_adopte)
}
function removeFill(event,d) {
d3.selectAll("text.labels").remove()
d3.select(this).style("fill", "rgb(88,127,167)")
d3.select(this).style('fill-opacity','.25')
}
return svg.node();
}