chart = {
const width = 960,
height = 660;
const svg = d3.create("svg")
.attr("viewBox", [50, 25, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 100, height - 100], boundingBox);
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 g = svg.append("g").attr("id", "paths");
svg
.append("text")
.attr('x','75')
.attr('y','70')
.style('font-family','courier new')
.style('font-size','32px')
.style('font-weight','bold')
.text('PERSONAL MAP')
svg
.append("text")
.attr('x','75')
.attr('y','90')
.style('font-family','courier new')
.style('font-size','12px')
.style('font-weight','light')
.text('NYC in a weekend')
g.selectAll("path2")
.data(subwayLines.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path2)
.style("fill", "none")
.style('stroke-opacity','.3')
.style("stroke-width", '1.5')
.style("stroke", "rgb(222,118,16)")
g.selectAll("path3")
.data(buildings.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", ".1")
.style('stroke-opacity','.2')
.style("stroke-width", '.1')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path3")
.data(parks.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "green")
.style("fill-opacity", ".15")
.style('stroke-opacity','.1')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
var c = svg.selectAll("circle")
.data(artgalleries.features)
.enter()
.append("circle")
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',2)
.attr('fill','grey')
.style('stroke-opacity','.2')
.style('stroke','black')
.style('stroke-width','0.25')
.style('fill-opacity','.2')
.on('mouseover',galleryText)
.on('mouseout',removeGalText)
function galleryText(event,d){
console.log(d)
svg
.append("text")
.attr('x','750')
.attr('y','500')
.attr('class','gallery_position')
.style('font-family','courier new')
.style('font-size','16px')
.style('font-weight','bold')
.style('fill-opacity','.5')
.text(d.properties.name)
p.enter().append("polyline")
.data(GalIcon)
.enter()
.append("polyline")
.attr("points", function(d) {return d})
.attr('class','Artline')
.attr('fill','none')
.style('stroke-opacity','.5')
.style('stroke','black')
.style('stroke-width','.5')
p.enter().append("polyline")
.data(frameRollover)
.enter()
.append("polyline")
.attr("points", function(d) {return d})
.attr('class','Frameline')
.attr('fill','none')
.style('stroke-opacity','.5')
.style('stroke','black')
.style('stroke-width','2')
p.enter().append("polyline")
.data(peopleFill)
.enter()
.append("polyline")
.attr("points", function(d) {return d})
.attr('class','PFill')
.attr('fill','grey')
.style('fill-opacity','.5')
.style('stroke','none')
.style('stroke-width','2')
p.enter().append("polyline")
.data(artFill)
.enter()
.append("polyline")
.attr("points", function(d) {return d})
.attr('class','ArtFill')
.attr('fill','grey')
.style('fill-opacity','.5')
.style('stroke','none')
.style('stroke-width','2')
var wrap = svg.selectAll('text.gallery_position')
.each(function(d,i) {wrap_text(d3.select(this),75)})
}
function removeGalText(){
d3.selectAll('text.gallery_position').remove()
d3.selectAll('polyline.Artline').remove()
d3.selectAll('polyline.Frameline').remove()
d3.selectAll('polyline.PFill').remove()
d3.selectAll('polyline.ArtFill').remove()
}
c.enter().append("circle")
.data(substations.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.5)
.attr('fill','rgb(222,118,16)')
.style('fill-opacity','1')
c.enter().append("circle")
.data(personal_spots)
.enter()
.append("circle")
.attr("cx", function(d) {return projection([d.long,d.lat])[0]})
.attr("cy", function(d) {return projection([d.long,d.lat])[1]})
.attr('r',4)
.attr('fill','purple')
.style('stroke','black')
.style('stroke-width','0.25')
.style('fill-opacity','1')
.on('mouseover',SpotsText)
.on('mouseout',removeSpotsText)
function SpotsText(event,d){
console.log(d)
p.enter().append("polyline")
.data(spotsHighlight)
.enter()
.append("polyline")
.attr("points", function(d) {return d})
.attr('class','SHiLite')
.attr('fill','purple')
.style('fill-opacity','0.1')
.style('stroke-opacity','0.5')
.style('stroke','purple')
.style('stroke-width','4')
svg
.append("text")
.attr('x', projection([d.long,d.lat])[0]+12)
.attr('y', projection([d.long,d.lat])[1]-7)
.attr('class','Spots_position')
.style('font-family','courier new')
.style('font-size','16px')
.style('font-weight','bold')
.text(d.name)
svg
.append("text")
.attr('x','75')
.attr('y','70')
.attr('class','T_Txt')
.style('font-family','courier new')
.style('font-size','32px')
.style('font-weight','bold')
.text('PERSONAL MAP')
svg
.append("text")
.attr('x','75')
.attr('y','90')
.attr('class','ST_Txt')
.style('font-family','courier new')
.style('font-size','12px')
.style('font-weight','light')
.text('NYC in a weekend')
svg
.append("text")
.attr('x', 760)
.attr('y', 70)
.attr('class','Des_position')
.style('font-family','courier new')
.style('font-size','12px')
.style('font-weight','light')
.text(d.description)
var wrap = svg.selectAll('text.Spots_position')
.each(function(d,i) {wrap_text(d3.select(this),75)})
var wrap = svg.selectAll('text.Des_position')
.each(function(d,i) {wrap_text(d3.select(this),75)})
}
function removeSpotsText(){
d3.selectAll('text.Spots_position').remove()
d3.selectAll('line.Sline').remove()
d3.selectAll('polyline.SHiLite').remove()
d3.selectAll('text.T_Txt').remove()
d3.selectAll('text.ST_Txt').remove()
d3.selectAll('text.Des_position').remove()
}
var c = svg.selectAll("text")
.data(substations.features)
.enter()
.append("text")
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-5})
.style('font-family','courier new')
.style('font-size','4px')
.style('text-anchor','middle')
.style('font-weight','light')
.text(function(d){return d.properties.name})
var p = svg.selectAll("polyline")
return svg.node();
}