chart = {
const width = 900,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [25, 0, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bbox1);
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','25')
.attr('y','25')
.style('font-family','garamond')
.style('font-size','24px')
.style('font-weight','bold')
.text('London')
svg
.append("text")
.attr('x','25')
.attr('y','50')
.style('font-family','garamond')
.style('font-size','18px')
.style('font-weight','bold')
.text('Places To Visit:')
svg
.append("line")
.attr('x1','25')
.attr('y1','33')
.attr('x2','142')
.attr('y2','33')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path2") //d3 geopath
.data(underground.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", "black")
g.selectAll("path3")
.data(base1.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(245,245,245)")
.style("fill-opacity", ".25")
.style('stroke-opacity','.1')
.style("stroke-width", '.5')
.style("stroke", "black")
g.selectAll("path3")
.data(brownfields.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(255,255,255)")
.style("fill-opacity", "1")
.style('stroke-opacity','.5')
.style("stroke-width", '.25')
.style("stroke", "black")
g.selectAll("path3")
.data(thames.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(0,0,0)")
.style("fill-opacity", ".65")
.style('stroke-opacity','1')
.style("stroke-width", '.1')
.style("stroke", "white")
// var c = svg.selectAll("circle") //d3 geopath
// .data(Points)
// .enter() //there are more data than elements, this selects them
//.append("circle") //appends path to data
//.attr('class','points')
// .attr("cx", function(d) {return projection([d.Long,d.Lat])[0]})
//.attr("cy", function(d) {return projection([d.Long,d.Lat])[1]})
// .attr('r',3)
// .attr('fill','none')
// .style('fill-opacity','0')
var p = svg.selectAll("polyline")
.data(irons5)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points',function(d){return d})
.attr('transform','translate(125,20)')
.style('fill','black')
.style('stroke','none')
.style('stroke-width','.25')
//.style('stroke-dasharray', '4,4,8,8')
p.enter().append("polyline")
.data(icon_list)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('class','icon')
.attr('points',function(d){return d.pts})
.attr('transform',function(d){return 'translate('+projection([d.data.Long,d.data.Lat])[0]+','+projection([d.data.Long,d.data.Lat])[1]+')'})
.style('fill','fillColor')
.style('stroke','none')
.style('stroke-width','.25')
.on('mouseover',pointsinfo)//listens for a mousover, and calls function
.on('mouseout',pointsinfoout)
function fillColor(d,i){
var color = 'rgb(0,0,0)'
if(d.data.Rank==5){color = 'red'
console.log("match")}
if(d.data.Rank==4){color = 'red'}
if(d.data.Rank==3){color = 'red'}
if(d.data.Rank==2){color = 'red'}
if(d.data.Rank==1){color = 'red'}
return color
}
function pointsinfo(event,d){
d3.select(this).style('fill','black')
svg.append('text')
.attr('class','PointsText')
.attr('x','25')
.attr('y','75')
.attr("font-family","Garamond")
.style('font-weight','bold')
.style('font-weight','bold')
.attr("font-size","16px")
.style('fill','black')
.attr('text-anchor','left')
.text(d.data.Name)
svg.append('text')
.attr('class','PointsText')
.attr('x','25')
.attr('y','100')
.attr("font-family","Garamond")
.style('font-weight','bold')
.style('font-weight','bold')
.attr("font-size","12px")
.attr('fill','black')
.attr('text-anchor','left')
.text(d.data.Description)
svg.append('line')
.attr('class','PointLine')
.attr('x1','30')
.attr('y1','100')
.attr('x2',projection([d.data.Long,d.data.Lat])[0])
.attr('y2',projection([d.data.Long,d.data.Lat])[1])
.style("stroke-width", '.5')
.style("stroke", "black")
.style('stroke-dasharray', '6 4')
var ratingList = []
if(d.data.Rank==1){ratingList = [irons5]}
if(d.data.Rank==2){ratingList = [irons5,irons5]}
if(d.data.Rank==3){ratingList = [irons5,irons5,irons5]}
if(d.data.Rank==4){ratingList = [irons5,irons5,irons5,irons5]}
if(d.data.Rank==5){ratingList = [irons5,irons5,irons5,irons5,irons5]}
p.enter().append("polyline")
.data(ratingList)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('class','icon_rating')
.attr('points',function(d){return d})
.attr('transform',function(d,i){return 'translate('+(35+(i*35))+',125)'})
.style('fill','black')
.style('stroke','none')
.style('stroke-width','.25')
}
function pointsinfoout(event,d){
d3.selectAll('polyline.icon').style('fill',fillColor)
d3.selectAll('text.PointsText').remove()
d3.selectAll('line.PointLine').remove()
d3.selectAll('polyline.icon_rating').remove()
}
return svg.node();
}