chart = {
const width = 960,
height = 960;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], 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");
g.selectAll("path2")
.data(busline.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(building1.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", "1")
.style('stroke-opacity','.1')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path4") //d4 geopath
.data(strets.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", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", ".1")
.style('stroke-opacity','0.5')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,255)")
var c = svg.selectAll("circle") //use this line the first time we create a circle
.data(bustStopTest.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('fill','black')
.style('fill-opacity','1')
function fountainText(event,d){//this is everything that happens when we hover over a fountain
//console.log(d)
var miraclegrow = d.description.length/7.5 * 7.5
svg
.append("rect")
.attr("width", 100)
.attr("height", miraclegrow)
.attr('class', 'erect')
.attr('x', projection([d.long,d.lat])[0]-185-12.5)
.attr('y', projection([d.long,d.lat])[1]-100 - miraclegrow)
.style('fill','rgb(255,255,255)')
.style('stroke-opacity','1')
.style("stroke-width", '1')
.style('stroke', 'rbg(0,0,0)')
svg
.append("text")
.attr('x', projection([d.long,d.lat])[0]-185)
.attr('y', projection([d.long,d.lat])[1]-100 - miraclegrow+12.5)
.attr('class','bustStopTest_position')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','light')//use 'fill' to change color
.text(d.description)
var wrap = svg.selectAll("text.bustStopTest_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',projection([d.long,d.lat])[0])
.attr('y1',projection([d.long,d.lat])[1])
.attr('x2', projection([d.long,d.lat])[0]-100)
.attr('y2', projection([d.long,d.lat])[1]-100)
.attr('class','fLine')
.style('stroke-width', '1')
.style("stroke", "rgb(0,0,0)")
.style('stroke-dasharray', '6 4')
p.enter().append("polyline") //use this line the first time we create a polyline
.data(testx21)
.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','p2')
.style('fill','none')
.style('stroke','black')
.style('stroke-width','0.5')
}//this is where fountainText function ends
function removeFountainText(){
d3.selectAll('text.bustStopTest_position').remove()//geometry type, then class name
d3.selectAll('line.fLine').remove()
d3.selectAll('polyline.bustStopTest_postition').remove()
d3.selectAll('rect.erect').remove()
d3.selectAll('polyline.p2').remove()
}
c.enter().append("circle") // use this line everytime after the first time we create a circle
.data(bustStopTest.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')
.style('fill','red')
.style('fill-opacity','1')
c.enter().append("circle") // use this line everytime after the first time we create a circle
.data(persoanl_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]})//projection([d.long,d.lat])[0]
.attr("cy", function(d) {return projection([d.long,d.lat])[1]})
.attr('r',3)
.style('stroke','black')
.style('stroke-width','1')
.style('fill','cyan')
.style('fill-opacity','1')
.on('mouseover',fountainText)
.on('mouseout',removeFountainText)
var z = svg.selectAll("text") //use this line the first time we create a circle
.data(persoanl_spots)
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr("x", function(d) {return projection([d.long,d.lat])[0]})
.attr("y", function(d) {return projection([d.long,d.lat])[1]-7})
.style('font-family','helvetica')
.style('font-size','8px')
.style('text-anchor','middle')
.style('font-weight','bold')//use 'fill' to change color
.text(function(d){return d.name})
svg
.append("text")
.attr('x','350')
.attr('y','120')
.style('font-family','helvetica')
.style('font-size','30px')
.style('font-weight','bold')//use 'fill' to change color
.text("Damon's")
svg
.append("text")
.attr('x','350')
.attr('y','150')
.style('font-family','helvetica')
.style('font-size','30px')
.style('font-weight','bold')//use 'fill' to change color
.text("Personal Map")
svg
.append("text")
.attr('x','350')
.attr('y','200')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','light')//use 'fill' to change color
.text('Bus stop locations')
svg
.append("circle")
.attr('cx','460')
.attr('cy','196')
.attr('r',5)
.style('stroke','black')
.style('stroke-width','1')
.style('fill','red')
.style('fill-opacity','1')
svg
.append("text")
.attr('x','350')
.attr('y','175')
.style('font-family','helvetica')
.style('font-size','15px')
.style('font-weight','normal')//use 'fill' to change color
.text('Key')
svg
.append("text")
.attr('x','350')
.attr('y','200')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','light')//use 'fill' to change color
.text('Bus stop locations')
svg
.append("text")
.attr('x','350')
.attr('y','225')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','light')//use 'fill' to change color
.text('Bus Line')
svg
.append("line")
.attr('x1','410')
.attr('y1','222')
.attr('x2','460')
.attr('y2','222')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
svg
.append("text")
.attr('x','350')
.attr('y','250')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','light')//use 'fill' to change color
.text('Places I been to')
svg
.append("circle")
.attr('cx','460')
.attr('cy','245')
.attr('r',5)
.style('stroke','black')
.style('stroke-width','1')
.style('fill','cyan')
.style('fill-opacity','1')
var p = svg.selectAll("polyline") //use this line the first time we create a polyline
.data(testx1)
.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','cyan')
.style('stroke','black')
.style('stroke-width','2')
return svg.node();
}