chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], BoundBox);
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 g = svg.append("g").attr("id", "paths");
g.selectAll("path5")
.data(parks.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path5)
.style("fill", "rgb(170,226,173)")
.style("fill-opacity", ".5")
.style('stroke-opacity','.4')
.style("stroke-width", '.5')
.style("stroke", "none")
g.selectAll("path5")
.data(pParcels.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path5)
.style("fill", "red")
.style("fill-opacity", ".2")
.style('stroke-opacity','.7')
.style("stroke-width", '.5')
.style("stroke", "red")
g.selectAll("path5")
.data(parcels.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path5)
.style("fill", "rgb(220,220,220)")
.style("fill-opacity", ".2")
.style('stroke-opacity','.4')
.style("stroke-width", '.5')
.style("stroke", "rgb(140,140,140)")
g.selectAll("path2") //d3 geopath
.data(streets.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", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '2')
.style("stroke", "rgb(250,250,250)")
g.selectAll("path3")
.data(rensBldg.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "white")
.style("fill-opacity", "1")
.style('stroke-opacity','.4')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path3")
.data(Solid.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", ".25")
.style('stroke-opacity','.2')
.style("stroke-width", '.25')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path2") //d3 geopath
.data(contour.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", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','.5')
.style("stroke-width", '.5')
.style("stroke", "rgb(200,200,200)")
g.selectAll("path5")
.data(river.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path5)
.style("fill", "rgb(100,100,100)")
.style("fill-opacity", ".1")
.style('stroke-opacity','.6')
.style("stroke-width", '.5')
.style("stroke", "none")
var c = svg.selectAll("circle") //d3 geopath
.data(spots)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return projection([d.long,d.lat])[0]})
.attr("cy", function(d) {return projection([d.long,d.lat])[1]})
.attr('r',spotSize)
.attr('fill',colorType)
.style('fill-opacity','1')
.on('mouseover', spotText)
.on('mouseout', removespotText)
function colorType(d,i){
var color = 'red'
if(d.type=='food'){color = 'rgb(255,255,'+y+')'}
if(d.type=='apartment'){color = 'cyan'}
if(d.type=='education'){color = 'blue'}
if(d.type=='care'){color = 'black'}
if(d.type=='park'){color = 'green'}
return color
}
svg.append('text')
// .attr('class', 'spots')
.attr('x', '150')
.attr('y', '220')
.attr('font-family','Helvetica')
.attr('font-size', '1em')
.attr('text-anchor', 'start')
.attr('font-weight','bold')
.text(totalValues[0])
svg.append('text')
// .attr('class', 'spots')
.attr('x', '90')
.attr('y', '220')
.attr('font-family','Helvetica')
.attr('font-size', '1em')
.attr('text-anchor', 'start')
.attr('font-weight','light')
.text("cost:")
svg.append('text')
// .attr('class', 'spots')
.attr('x', '150')
.attr('y', '190')
.attr('font-family','Helvetica')
.attr('font-size', '1em')
.attr('text-anchor', 'start')
.attr('font-weight','bold')
.text(totalValues[1])
svg.append('text')
// .attr('class', 'spots')
.attr('x', '50')
.attr('y', '190')
.attr('font-family','Helvetica')
.attr('font-size', '1em')
.attr('text-anchor', 'start')
.attr('font-weight','light')
.text("Happiness:")
function spotText(event,d){
d3.select(this).attr('fill','magenta')
svg.append('text')
.attr('class', 'spots')
.attr('x', '150')
.attr('y', '150')
.attr('font-family','Helvetica')
.attr('font-size', '1em')
.attr('text-anchor', 'start')
.attr('font-weight','bold')
.text(d.name)
svg.append('text')
.attr('class', 'spots')
.attr('x', '150')
.attr('y', '165')
.attr('font-family','Helvetica')
.attr('font-size', '.7em')
.attr('text-anchor', 'start')
.attr('font-weight','normal')
.text(d.description)
svg.append('line')
.attr('class','spotLine')
.attr('x1','150')
.attr('y1','150')
.attr('x2','350')
.attr('y2','150')
.style('stroke-width', '1')
.style('stroke', 'black')
}
function removespotText(event,d){
d3.select(this).attr('fill',colorType)
d3.selectAll('text.spots').remove()
d3.selectAll('line.spotLine').remove()
}
return svg.node();
}