chart = {
const width = 960,
height = 960;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100])
.style("background", "#001B2E");
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bbox3);
var path1 = 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 path8 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path4")
.data(borough.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(30,30,30)")
.style("fill-opacity", "0.8")
.style('stroke-opacity','0.8')
.style("stroke-width", '0.8')
.style("stroke", "#e6e6e6")
g.selectAll("path2")
.data(stcenterlineTrimed.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path2)
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '0.8')
.style("stroke", "#383838")
g.selectAll("path3")
.data(parks.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "#a1caae")
.style("fill-opacity", "1")
.style('stroke-opacity','0')
.style("stroke-width", '.5')
.style("stroke", "#729B79")
.on('mouseover', addFill)
.on('mouseleave', removeFill)
g.selectAll("path7")
.data(connections.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path7)
.style('fill-opacity','1')
.style("stroke-width", "0.8")
.style("stroke", "#E76B74")
.style('stroke-opacity','.5')
.on('mouseover', addroute)
.on('mouseleave',removeroute)
g.selectAll("path9")
.data(dronelinebus.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path7)
.style('fill-opacity','0')
.style("stroke-width", "1.7")
.style("stroke", "#E9B872")
.on('mouseover', addroutedrone)
.on('mouseleave',removeroutedrone)
g.selectAll("path10")
.data(dronelinef.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path7)
.style('fill-opacity','0')
.style("stroke-width", "1.7")
.style("stroke", "#007DD0")
.on('mouseover', addroutedronef)
.on('mouseleave',removeroutedronef)
var c = svg.selectAll("circle")
.data(bus.features)
.enter()
.append("circle")
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',1.8)
.attr('fill','rgb(247,86,124)')
.style('fill-opacity','0.8')
.style("stroke", "white")
.style("stroke-width", ".1")
.on('mouseover', addST)
.on('mouseleave',removeST)
c.enter().append('circle')
.data(drinking.features)
.enter()
.append("circle")
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',1.8)
.attr('fill','#007DD0')
.style('fill-opacity','0.8')
.style("stroke", "white")
.style("stroke-width", ".1")
.on('mouseover', addBox)
.on('mouseleave',removeBox)
svg
.append('rect')
.attr('fill', "rgb(255,255,255)")
.attr('x', 0)
.attr('y', 0)
.attr('width', 120)
.attr('height', 960)
svg
.append('rect')
.attr('fill', "rgb(255,255,255)")
.attr('x', 840)
.attr('y', 0)
.attr('width', 120)
.attr('height', 960)
svg
.append('rect')
.attr('fill', "rgb(255,255,255)")
.attr('x', 0)
.attr('y', 840)
.attr('width', 960)
.attr('height', 120)
svg
.append('rect')
.attr('fill', "rgb(255,255,255)")
.attr('x', 0)
.attr('y', 0)
.attr('width', 960)
.attr('height', 120)
svg
.append('circle')
.attr('fill', "rgb(247,86,124)")
.attr('cx', 135)
.attr('cy', 135)
.attr('r',3.5)
svg
.append("text")
.attr('x',146)
.attr('y',137)
.attr('font-family','helvetica')
.attr('font-size','0.45em')
.attr('fill','white')
.text('Bus Shelter')
svg
.append('circle')
.attr('fill', "#007DD0")
.attr('cx', 135)
.attr('cy', 150)
.attr('r',3.5)
svg
.append("text")
.attr('x',146)
.attr('y',152)
.attr('font-family','helvetica')
.attr('font-size','0.45em')
.attr('fill','white')
.text('Drinking Fountain')
svg
.append('line')
.attr('x1',128)
.attr('y1',165)
.attr('x2',143)
.attr('y2',165)
.style("stroke-width", '0.5')
.style("stroke", "#E76B74")
svg
.append("text")
.attr('x',146)
.attr('y',167)
.attr('font-family','helvetica')
.attr('font-size','0.45em')
.attr('fill','white')
.text('Route to Closest Collection Point')
svg
.append('line')
.attr('x1',128)
.attr('y1',180)
.attr('x2',143)
.attr('y2',180)
.style("stroke-width", '2')
.style("stroke", "#E9B872")
svg
.append("text")
.attr('x',146)
.attr('y',182)
.attr('font-family','helvetica')
.attr('font-size','0.45em')
.attr('fill','white')
.text('Delivering Route of Seeds')
svg
.append('line')
.attr('x1',128)
.attr('y1',195)
.attr('x2',143)
.attr('y2',195)
.style("stroke-width", '2')
.style("stroke", "#007DD0")
svg
.append("text")
.attr('x',146)
.attr('y',197)
.attr('font-family','helvetica')
.attr('font-size','0.45em')
.attr('fill','white')
.text('Irrigation Route of Water')
svg
.append("text")
.attr('class','title')
.attr('x',360)
.attr('y','100')
.attr('font-family','helvetica')
.attr('font-size','1.5em')
.attr('font-weight','Bold')
.attr('fill','rgb(0,0,0)')
.text('Green Bus Shelter Project')
var tooltip = svg.append("g");
function addBox(event, d) {
var centroid = path1.centroid(d);
tooltip.call(
callout,
`${d.properties.signname}
${d.properties.fountain_t}
${d.properties.position}`
);
tooltip.attr("transform", "translate(" + centroid + ")");
d3.select(this).style("stroke-width", '2.5')
d3.select(this).style("stroke", 'white')
}
function removeBox(event, d) {
tooltip.call(callout,null)
d3.select(this).style("stroke-width", '.1')
d3.select(this).style("stroke", 'white')
}
function addST(event, d) {
var centroid = path2.centroid(d);
tooltip.call(
callout,
`${d.properties.at_between}
${d.properties.location}`
);
tooltip.attr("transform", "translate(" + centroid + ")");
d3.select(this).style("stroke-width", '2.5')
d3.select(this).style("stroke", 'white')
}
function removeST(event, d) {
tooltip.call(callout,null)
d3.select(this).style("stroke-width", '.1')
d3.select(this).style("stroke", 'white')
}
function addroute(event,d) {
d3.select(this).style("stroke-width", "2.5")
d3.select(this).style("stroke", "#FF4D4D")
d3.select(this).style('fill-opacity','1')
d3.select(this).style('stroke-opacity','1')
}
function removeroute(event,d) {
d3.select(this).style("stroke-width", "0.9")
d3.select(this).style("stroke", "#E76B74")
d3.select(this).style('fill-opacity','1')
d3.select(this).style('stroke-opacity','.5')
}
function addroutefountain(event,d) {
d3.select(this).style("stroke-width", "2.5")
d3.select(this).style("stroke", "#FF4D4D")
d3.select(this).style('fill-opacity','.8')
svg
.append('text')
.attr('x','75')
.attr('y','110')
.attr('class','review')
.attr("font-family", "Helvetica")
.attr('font-size','.6em')
.style("font-weight","bold")
.style("fill",'rgb(255,211,0)')
.text('Green Bus Shelter Project')
}
function removeroutefountain(event,d) {
d3.select(this).style("stroke-width", "0.7")
d3.select(this).style("stroke", "#CC9999")
d3.select(this).style('fill-opacity','1')
d3.selectAll('text.review').remove()
}
function addroutedrone(event,d) {
d3.select(this).style("stroke-width", "2.8")
d3.select(this).style("stroke", "#f8d6a4")
d3.select(this).style('fill-opacity','0')
d3.select(this).attr('stroke-dasharray','0 0')
svg
.append('text')
.attr('x','120')
.attr('y','880')
.attr('class','review')
.attr("font-family", "Helvetica")
.attr('font-size','1.1em')
.style("font-weight","bold")
.style("fill",'black')
.text(d.properties.Text)
}
function removeroutedrone(event,d) {
d3.select(this).style("stroke-width", "1.7")
d3.select(this).style("stroke", "#E9B872")
d3.select(this).style('fill-opacity','0')
d3.selectAll('text.review').remove()
}
function addroutedronef(event,d) {
d3.select(this).style("stroke-width", "2.8")
d3.select(this).style("stroke", "#007DD0")
d3.select(this).attr('stroke-dasharray','0 0')
d3.select(this).style('fill-opacity','0')
svg
.append('text')
.attr('x','120')
.attr('y','880')
.attr('class','review')
.attr("font-family", "Helvetica")
.attr('font-size','1.1em')
.style("font-weight","bold")
.style("fill",'black')
.text(d.properties.Text)
}
function removeroutedronef(event,d) {
d3.select(this).style("stroke-width", "1.7")
d3.select(this).style("stroke", "#007DD0")
d3.select(this).style('fill-opacity','0')
d3.selectAll('text.review').remove()
}
function addFill(event,d) {
d3.select(this).style("fill", "#4EFFC5")
d3.select(this).style("stroke-width", "2")
d3.select(this).style("stroke", "white")
d3.select(this).style('fill-opacity','.8')
svg
.append('text')
.attr("class","labels")
.attr('x','125')
.attr('y','870')
.attr('font-size','.85em')
.attr('fill','black')
.style("font-weight","bold")
.attr("font-family", "Helvetica")
.text(d.properties.park_name);
svg
.append('line')
.attr('x1',path1.centroid(d)[0])
.attr('y1',path1.centroid(d)[1])
.attr('x2',path1.centroid(d)[0])
.attr('y2',850)
.attr('class','pizzaLine')
.style("stroke-width", '.5')
.style("stroke", "white")
.attr('stroke-dasharray','7 7')
svg
.append('line')
.attr('x1',path1.centroid(d)[0])
.attr('y1',840)
.attr('x2',path1.centroid(d)[0])
.attr('y2',851)
.attr('class','pizzaLine')
.style("stroke-width", '.5')
.style("stroke", "black")
.attr('stroke-dasharray','7 7')
svg
.append('line')
.attr('x1',path1.centroid(d)[0])
.attr('y1',851)
.attr('x2',120)
.attr('y2',851)
.attr('class','pizzaLine')
.style("stroke-width", '.5')
.style("stroke", "black")
.attr('stroke-dasharray','7 7')
svg
.append('line')
.attr('x1',120)
.attr('y1',851)
.attr('x2',120)
.attr('y2',890)
.attr('class','pizzaLine')
.style("stroke-width", '.5')
.style("stroke", "black")
svg
.append('line')
.attr('x1',120)
.attr('y1',890)
.attr('x2',250)
.attr('y2',890)
.attr('class','pizzaLine')
.style("stroke-width", '.5')
.style("stroke", "black")
svg
.append('text')
.attr("class","labels")
.attr('x','125')
.attr('y','880')
.attr('font-size','.5em')
.attr('fill','black')
.attr("font-family", "Helvetica")
.text(d.properties.landuse);
}
function removeFill(event,d) {
d3.selectAll("text.labels").remove()
d3.select(this).style("stroke-width", "0")
d3.select(this).style("fill", "#a1caae")
d3.select(this).style('fill-opacity','1')
d3.selectAll('line.pizzaLine').remove()
}
function addFillOOS(event,d) {
d3.select(this).style("fill", "#4EFFC5")
d3.select(this).style("stroke-width", "1.5")
d3.select(this).style("stroke", "white")
d3.select(this).style('fill-opacity','.8')
}
function removeFillOOS(event,d) {
d3.selectAll("text.labels").remove()
d3.select(this).style("stroke-width", "0")
d3.select(this).style("fill", "#86CBC0")
d3.select(this).style('fill-opacity','.8')
}
function addFillOOB(event,d) {
d3.select(this).style("fill", "#4EFFC5")
d3.select(this).style("stroke-width", "1.5")
d3.select(this).style("stroke", "white")
d3.select(this).style('fill-opacity','.8')
}
function removeFillOOB(event,d) {
d3.selectAll("text.labels").remove()
d3.select(this).style("stroke-width", "0")
d3.select(this).style("fill", "#86CBC0")
d3.select(this).style('fill-opacity','1')
}
var t = svg.selectAll("text")
.data(busroutestop1.features)
.enter()
.append("text")
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-8})
.attr('font-family','helvetica')
.style('font-size','.4em')
.attr('text-anchor','middle')
.style("font-weight","bold")
.style("fill","white")
.text(function(d) {return d.properties.at_between})
var t = svg.selectAll("text")
.data(busroutestop3.features)
.enter()
.append("text")
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-8})
.attr('font-family','helvetica')
.style('font-size','.4em')
.attr('text-anchor','middle')
.style("font-weight","bold")
.style("fill","white")
.text(function(d) {return d.properties.at_between})
t.enter().append('text')
.data(busroutestop2.features)
.enter()
.append("text")
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-8})
.attr('font-family','helvetica')
.style('font-size','.4em')
.attr('text-anchor','middle')
.style("font-weight","bold")
.style("fill","white")
.text(function(d) {return d.properties.at_between})
t.enter().append('text')
.data(busroutestop3.features)
.enter()
.append("text")
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-8})
.attr('font-family','helvetica')
.style('font-size','.4em')
.attr('text-anchor','middle')
.style("font-weight","bold")
.style("fill","white")
.text(function(d) {return d.properties.at_between})
scaleBar
.projection(projection)
.size([width, height]);
svg.append("g")
.call(scaleBar);
return svg.node();
}