chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-150, height-150]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], b);
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");
g.selectAll("path2")
.data(subwayline.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path2)
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '.75')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path3")
.data(buildingoutline.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", ".5")
.style('stroke-opacity','.4')
.style("stroke-width", '.15')
.style("stroke", "rgb(0,0,0)")
var c = svg.selectAll("circle") //use this line the first time we create a circle
.data(library.features)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return path1.centroid(d)[0]})//we use a function in order to draw ALL of the fountains - loop through the fountains
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',3)
.style('stroke','black')
.style('stroke-width','1')
.attr('fill','cyan')
.style('fill-opacity','1')
.on('mouseover',LibraryText)
.on('mouseout',removeLibraryText)
function LibraryText(event,d){
//console.log(d)
svg
.append("text")
.attr('x','100')
.attr('y','220')
.attr('class','library_position')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','light')//use 'fill' to change color
.text(d.properties.Position)
var wrap = svg.selectAll("text.library_position")
.each(function(d, i) { wrap_text(d3.select(this), 75) });//control how many pixels wide our text block can be
svg
.append("line")
.attr('x1','120')
.attr('y1','180')
.attr('x2', path1.centroid(d)[0])
.attr('y2', path1.centroid(d)[1])
.attr('class','fLine')
.style('stroke-width', '1')
.style("stroke", "rgb(0,0,0)")
.style('stroke-dasharray', '4')
p.enter().append("polyline") //use this line the first time we create a polyline
.data(text)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
.attr("class", 'book')
.style('fill','black')
.style('stroke','black')
.style('stroke-width','.5')
}//this is where LibraryText function ends
function removeLibraryText(){
d3.selectAll('text.library_position').remove()//geometry type, then class name
d3.selectAll('line.fLine').remove()
d3.selectAll('polyline.book').remove()
}
c.enter().append("circle") // use this line everytime after the first time we create a circle
.data(gallery.features)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',3)
.style('stroke','black')
.style('stroke-width','1')
.attr('fill','pink')
.style('fill-opacity','1')
.on('mouseover',galleryText)
.on('mouseout',removeGalleryText)
function galleryText(event,d){
//console.log(d)
svg
.append("text")
.attr('x','120')
.attr('y','200')
.attr('class','Gallery_position')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','light')//use 'fill' to change color
.text(d.properties.Position)
var wrap = svg.selectAll("text.Gallery_position")
.each(function(d, i) { wrap_text(d3.select(this), 75) });//control how many pixels wide our text block can be
svg
.append("line")
.attr('x1','120')
.attr('y1','190')
.attr('x2', path1.centroid(d)[0])
.attr('y2', path1.centroid(d)[1])
.attr('class','fLine')
.style('stroke-width', '1')
.style("stroke", "rgb(0,0,0)")
.style('stroke-dasharray', '4')
p.enter().append("polyline") //use this line the first time we create a polyline
.data(text2)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
.attr("class", 'artwork')
.style('fill','none')
.style('stroke','black')
.style('stroke-width','.5')
}//this is where GalleryText function ends
function removeGalleryText(){
d3.selectAll('text.Gallery_position').remove()//geometry type, then class name
d3.selectAll('line.fLine').remove()
d3.selectAll('polyline.artwork').remove()
}
c.enter().append("circle") //d3 geopath
.data(substop.features)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',3)
.attr('fill','black')
.style('fill-opacity','1')
svg
.append("text")
.attr('x','100')
.attr('y','95')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Lu_Zexuan_Manhattan_NY_Personal Map')
svg
.append("text")
.attr('x','100')
.attr('y','120')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','light')//use 'fill' to change color
.text('Fall_2023_Urban Data')
svg
.append("text")
.attr('x','310')
.attr('y','380')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Harbs')
svg
.append("text")
.attr('x','730')
.attr('y','295')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('CheLi')
svg
.append("text")
.attr('x','740')
.attr('y','270')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Mountain House')
svg
.append("text")
.attr('x','420')
.attr('y','240')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('New York University')
svg
.append("text")
.attr('x','460')
.attr('y','380')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Soho')
svg
.append("text")
.attr('x','670')
.attr('y','280')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Gong Cha')
svg
.append("line")
.attr('x1','100')
.attr('y1','104')
.attr('x2','200')
.attr('y2','104')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
svg
.append("text")
.attr('x','100')
.attr('y','180')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Library')
svg
.append("text")
.attr('x','100')
.attr('y','200')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Gallery')
svg
.append("text")
.attr('x','100')
.attr('y','220')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('The meaningful Place')
var p = svg.selectAll("polyline") //use this line the first time we create a polyline
.data(text1)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
.style('fill','grey')
.style('stroke','black')
.style('stroke-width','2')
return svg.node();
}