chart = {
const width = 1000,
height = 1000;
const svg = d3.create("svg")
.attr("viewBox", [25, 0, width-30, height]);
var projection = d3
.geoMercator()
.fitSize([width, height], bbox8Qgis);
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 path8 = d3.geoPath().projection(projection);
var path9 = 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")
staticLines(path6, community8.features,"rgb(250,250,250)",'1','1',"gray")
staticLines(path, park8.features,"rgb(204,204,204)",'.25','1',"white")
staticLines(path2, peddemand8.features,"none",'1','.5',"rgb(153,153,153)")
staticLines(path3, publicplazas8.features,"none",'1','1',"black")
staticLines(path4, openspacesOther8.features,"rgb(153,204,153)",'1','1',"rgb(51,102,51)")
staticLines(path5, railroad8.features,"none",'1','.1',"black")
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(network,'none','1','.25','rgb(0,102,153)')
polyline(vortex,'none','.1','3','rgb(255,159,42)')
//polyline(connectingroute,'none','1','1','rgb(204,102,102)')
function polyline(data, sfill, sOpac, sW, stroke){
p.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)
}
//static points from QGIS
//staticCircles(library8.features,'5','rgb(255,102,0)','5',"1")
staticCircles(pops8.features,'3','rgb(0,153,204)','5',"1")
//staticCircles(streetseats8.features,'4','red','5',"1")
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)
}
////////////////////////////-------PART 2-------
//// Display OTHER PARKS names from QGIS
t.enter().append('text')
.data(streetseats8.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr('class','sText')
.attr('x',function(d) {return path.centroid(d)[0]-10})
.attr("y",function(d) {return path.centroid(d)[1]+25})
.attr('fill', 'red')
.style('font-family','bahnschrift')
.style('text-anchor','start')
.style("font-size", "10px")
.text(function(d){return d.properties.ifo_busine})
t.enter().append('text')
.data(streetseats8.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr('class','sText')
.attr('x',function(d) {return path.centroid(d)[0]-10})
.attr("y",function(d) {return path.centroid(d)[1]+35})
.attr('fill', 'red')
.style('font-family','bahnschrift')
.style('text-anchor','start')
.style("font-size", "8px")
.text(function(d){return d.properties.location})
var wrap = svg.selectAll("text.sText")
.each(function(d, i) { wrap_text(d3.select(this), 150) })
//// Adding interactive POP ZONE
p.enter().append("polyline")
.data(zone9Pop) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr("points", function(d) {return d})
.style("fill", 'white')
.style('fill-opacity','0')
.style("stroke-width", '2')
.style("stroke", 'black')
.style('stroke-dasharray','5 5')
.on("mouseover",activatePOPzone)
.on("mouseout",removePOPzone)
function activatePOPzone(event,d){
svg
p.enter().append("polyline")
.data(textobj9Pop)
.enter()
.append('polyline')
.attr('class','popzone')
.attr("points", function(d) {return d})
.style("fill", 'none')
.style("stroke-width",'2')
.style("stroke", 'rgb(0,102,153)')
p.enter().append("polyline")
.data(network)
.enter()
.append('polyline')
.attr('class','popzone')
.attr("points", function (d){return d})
.style("fill",'none')
.style('stroke-opacity','1')
.style("stroke-width",'.25')
.style("stroke", 'rgb(0,102,153)')
}
function removePOPzone(event,d){
svg.selectAll('polyline.popzone').remove()
}
//// Adding ICON (starshape) from spreadsheet locations
//----draw STAR
/*
p.enter().append("polyline")
.data(library8.features) //get data to define path
.enter()
.append('polyline')
.attr("points", icon9Lib)
.attr('transform',function(d) {return 'translate('+path.centroid(d)[0]+','+path.centroid(d)[1]+')'})
.style("fill",'orange')
.style("stroke-width",'.5')
.style("stroke",'none')
//----draw invisble mouse-hover circle
c.enter().append('circle')
.data(library9)
.enter()
.append("circle")
.attr('cx','0')
.attr("cy",'0')
.attr('transform',function(d) {return 'translate('+projection([d.Long,d.Lat])[0]+','+projection([d.Long,d.Lat])[1]+')'})
.attr('r','15')
.attr('fill','white')
.style('fill-opacity','0')
.style("stroke-width",'none')
.on("mouseover",addText)
.on("mouseout",removeText)
*/
p.enter().append("polyline")
.data(library9)
.enter()
.append('polyline')
.attr("points", icon9Lib)
.attr('transform',function(d) {return 'translate('+projection([d.Long,d.Lat])[0]+','+projection([d.Long,d.Lat])[1]+')'})
.style("fill",'orange')
.style("stroke-width",'1')
.style("stroke",'orange')
.on("mouseover",addText)
.on("mouseout",removeText)
function addText(event,d){
d3.select(this).style('fill','brown')
//---Text at points
svg
.append("text")
.attr('class','lText')
.attr('x',projection([d.Long,d.Lat])[0]+20)
.attr("y",projection([d.Long,d.Lat])[1]+20)
.attr('fill','brown')
.style('font-family','bahnschrift')
.style("font-size", "15px") //https://developer.mozilla.org/en-US/docs/Web/CSS
.text(d.Name)
//---Text at fixed location
svg
.append("text")
.attr('class','lText')
.attr('x',30)
.attr("y",25)
.attr('fill', 'black')
.style('font-family','bahnschrift')
.style("font-size", "15px") //https://developer.mozilla.org/en-US/docs/Web/CSS
.text('Address: '+d.Address)
var wrap = svg.selectAll("text.lText")
.each(function(d, i) { wrap_text(d3.select(this), 100) })
}
//adding ICON (seat shape) from RHINO
p.enter().append("polyline")
.data(icon9Ss1)
.enter()
.append('polyline')
.attr('class','seat')
.attr("points", function(d) {return d})
.style("fill", 'red')
.style("stroke-width", '1')
.style("stroke", 'red')
.on("mouseover",activateRoute)
.on("mouseout",removeRoute)
function activateRoute(event,d){
svg
p.enter().append("polyline")
.data(connectingroute)
.enter()
.append('polyline')
.attr('class','seatflash')
.attr("points", function(d) {return d})
.style("fill", 'none')
.style("stroke-width",'2')
.style("stroke", 'rgb(204,102,102)')
p.enter().append("polyline")
.data(icon9Ss1)
.enter()
.append('polyline')
.attr('class','seatflash')
.attr("points", function(d) {return d})
.style("fill", 'white')
.style("stroke-width", '1.5')
.style("stroke", 'white')
p.enter().append("polyline")
.data(icon9Ss2)
.enter()
.append('polyline')
.attr('class','seatflash')
.attr("points", function(d) {return d})
.style("fill", 'red')
.style("stroke-width", '.2')
.style("stroke", 'white')
p.enter().append("polyline")
.data(textobj9Ss)
.enter()
.append('polyline')
.attr('class','seatflash')
.attr("points", function(d) {return d})
.style("fill", 'none')
.style("stroke-width",'.75')
.style("stroke", 'rgb(204,102,102)')
}
function removeRoute(event,d){
svg.selectAll('polyline.seatflash').remove()
}
function removeText(){
svg.selectAll('text.lText').remove()
d3.select(this).style('fill','orange')
}
return svg.node();
}