chart = {
const width = 900,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width-50, height-10]);
var projection = d3
.geoMercator()
.fitSize([width, height],cityLinesWeb, boxlines, );
var path = 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.selectAll('g').attr("id", "paths");
var c = svg.selectAll("circle")
var p = svg.selectAll("polyline")
staticLines(path3, boxBlack.features,"black",'1','1',"none")
polyline(background,'none','1','0.25','grey')
staticLines(path4, parksWeb2.features,"rgb(111,193,67)",'.25','.1',"rgb(0,255,0)")
staticLines(path4, cityLinesWeb.features,"none",'1','0.8',"rgb(241,165,77)")
staticLines(path3, subwayLineWeb.features,"none",'1','4',"yellow")
function staticLines(path, data, sfill, sOpac, sW, stroke){
g.enter().append("path")
.data(data) //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", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", sfill)
.style('stroke-opacity',sOpac)
.style("stroke-width", sW)
.style("stroke", stroke)
}
//lines from rhino
polyline(droneOutline,'none','1','1.9','orange')
polyline(lines,'rgb(240,31,36)','1.2','1.2','rgb(240,31,36)')
polyline(thepartymaker,'orange','4','0.5','none')
polyline(drone,'none','4','0.5','orange')
polyline(boxlines,'none','4','0.8','orange')
polyline(partyInsides,'black','1','0.5','none')
//static points from qgis
staticCircles(subwayWeb.features,'5','rgb(235,220,40)','1',"0")
function staticCircles(data,r,sfill, sOpac, sWidth){
c.enter().append('circle')
.data(data) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy",function(d) {return path.centroid(d)[1]})
.attr('r', r)
.attr('fill', sfill)
.style('fill-opacity',sOpac)
.style("stroke-width", sWidth)
}
function polyline(data, sfill, sOpac, sW, stroke){
g.enter().append("polyline")
.data(data) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr("points", function (d){return d})//The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", sfill)
.style('stroke-opacity',sOpac)
.style("stroke-width", sW)
.style("stroke", stroke)
}
//points from spreadsheet
c.enter().append('circle')
.data(green) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('class','spots')
.attr('cx',function(d) {return projection([d.Long,d.Lat])[0]})
.attr("cy",function(d) {return projection([d.Long,d.Lat])[1]})
.attr('r', 6)
.attr('fill', 'cyan')
.style('fill-opacity','1')
.style("stroke-width", ".5")
.style("stroke", "cyan")
.on("mouseover", addText)
.on("mouseout", removeText)
//points from spreadsheet
c.enter().append('text')
.data(green) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('class','spots')
.attr('cx',function(d) {return projection([d.Long,d.Lat])[0]})
.attr("cy",function(d) {return projection([d.Long,d.Lat])[1]})
.attr('r', 6)
.attr('fill', 'cyan')
.style('fill-opacity','1')
.style("stroke-width", ".5")
.style("stroke", "cyan")
.on("mouseover", addText)
.on("mouseout", removeText)
function addText(event,d){
svg
svg//draw text
.append("text") //appends path to data
.attr('class','spots')
.attr('x',projection([d.Long,d.Lat])[0])
.attr("y",projection([d.Long,d.Lat])[1])
.attr('fill', 'white')
.style('font-family','helvetica')
.style("font-size", "15px")
.text(d.Name)
svg
svg//draw text
.append("text") //appends path to data
.attr('class','spots')
.attr('x',50)
.attr("y",300)
.attr('fill', 'white')
.style('font-family','helvetica')
.style("font-size", "11px")
.text(d.Description)
var wrap = svg.selectAll("text.spots")
.each(function(d, i) { wrap_text(d3.select(this), 100) });
}
function removeText(){
svg.selectAll('text.spots').remove()
}
return svg.node();
}