chart = {
const width = 1000,
height = 1000;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width-50, height-10]);
var projection = d3
.geoMercator()
.fitSize([width, height], bbox_new);
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 path6 = d3.geoPath().projection(projection);
var path7 = d3.geoPath().projection(projection);
var g = svg.selectAll('g').attr("id", "paths");
var c = svg.selectAll("circle")
var p = svg.selectAll("polyline")
var t = svg.selectAll("text")
var l = svg.selectAll("line")
staticLines(path3, bbox1.features,"rgb(22, 44, 67)",'1','.1',"none")
staticLines(path6, zonning.features,"rgb(76, 29, 75)",'.25','1',"rgb(181,181,181)")
staticLines(path5, streetlines1.features,"none",'1','.5',"rgb(255,255,255)")
staticLines(path4, parks.features,"rgb(62,69,75)",'.25','.1',"rgb(120,114,118)")
staticLines(path7, seaLevel.features,"none",'1','.35',"rgb(171,175,255)")
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)
}
//static points from qgis
staticCircles(privateOwnedPublic.features,'2','yellow','1',"0")
//staticCircles(crimeSpot2.features,'1',"rgb(109,27,41)",'1',"rgb(213,213,213)")
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)
}
//lines from rhino
polyline(title,"white",'.25','none',"white")
polyline(axonIner,"none",'1','0.35',"white")
polyline(axonOutline,"none",'1','0.75',"white")
polyline(dronepath,"none",'1','1',"white")
polyline(connect,"none",'1','0.5',"rgb(193,110,110)")
//polyline(hurricane2,"none",'0.35','1',"white")
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)
}
//display names from spreadsheet - use this format for points from SPREADSHEET
t.enter().append('text')
.data(polices) //get data to define path
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
//.attr('class','spots')
.attr('x',200)
.attr("y",function(d,i){return 600 +(i*16)})
.attr('fill', 'white')
.style('font-family','helvetica')
.style("font-size", "9px")
.style("text-anchor", "end")
.text(function(d){return d.Name})
.on("mouseover",musText)
.on("mouseout",removeMusText)
function removeMusText(event,d){
svg.selectAll("line.museumLine").remove()
//svg.selectAll('polyline.bunny').style('fill','red')
svg.selectAll('polyline.angles').style('fill','red')
}
function musText(event,d){
//svg.selectAll('polyline.bunny').style('fill','yellow')
svg.selectAll('polyline.angles').style('fill','yellow')
//THESE ARE LINES FOR ANNOTATION
l.enter().append('line')
.data(polices) //get data to define path
.enter() //there are more data than elements, this selects them
.append("line") //appends path to data
.attr('class','museumLine')
.attr('x1',200)
.attr("y1",600)
.attr('x2',projection([d.Long,d.Lat])[0])
.attr("y2",projection([d.Long,d.Lat])[1])
.attr('stroke', 'white')
.attr('stroke-width', '1.25')
.style('stroke-dasharray', '3 2')
//THESE ARE LINES FOR ANNOTATION
l.enter().append('line')
.data(polices) //get data to define path
.enter() //there are more data than elements, this selects them
.append("line") //appends path to data
.attr('class','museumLine')
.attr('x1',200)
.attr("y1",function(d,i){return 600 +(i*16)})
.attr('x2',function(d) {return projection([d.Long,d.Lat])[0]-5})
.attr("y2",function(d,i){return 600 +(i*16)})
.attr('stroke', 'white')
.attr('stroke-width', '.55')
.style('stroke-dasharray', '3 2')
l.enter().append('line')
.data(polices) //get data to define path
.enter() //there are more data than elements, this selects them
.append("line") //appends path to data
.attr('class','museumLine')
.attr('x1',function(d) {return projection([d.Long,d.Lat])[0]-5})
.attr("y1",function(d,i){return 600 +(i*16)})
.attr('x2',function(d) {return projection([d.Long,d.Lat])[0]-5})
.attr("y2",function(d) {return projection([d.Long,d.Lat])[1]+10})
.attr('stroke', 'white')
.attr('stroke-width', '.55')
.style('stroke-dasharray', '3 2')
}
t.enter().append('text')//theater names from QGIS - use this format for points from QGIS
.data(subways.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
//.attr('class','spots')
.attr('x',function(d) {return path.centroid(d)[0]})
.attr("y",function(d) {return path.centroid(d)[1]-8})
.attr('fill', 'white')
.style('font-family','helvetica')
.style('text-anchor','middle')
.style("font-size", "6px")
.text(function(d){return d.properties.NAME})
//points from spreadsheet
c.enter().append('circle')
.data(polices) //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]-5})
.attr("cy",function(d) {return projection([d.Long,d.Lat])[1]+10})
.attr('r', 10)
.attr('fill', 'rgb(253,124,110)')
.style('fill-opacity','0.75')
.style("stroke-width", ".5")
.style("stroke", "black")
.on("mouseover", addText)
.on("mouseout", removeText)
function addText(event,d){
svg//draw text
.append("text") //appends path to data
.attr('class','mText')
.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", "10px")
.text(d.Name)
svg//draw text
.append("text") //appends path to data
.attr('class','mText')
.attr('x',50)
.attr("y",600)
.attr('fill', 'white')
.style('font-family','helvetica')
.style("font-size", "10px")
.text(d.Description)
}
function removeText(){
svg.selectAll('text.mText').remove()
}
return svg.node();
}