chart = {
const width = 900,
height = 600;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width-50, height-10]);
var projection = d3
.geoMercator()
.fitSize([width, height], bbox_usa);
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")
var t = svg.selectAll("text")
var l = svg.selectAll("line")
staticLines(path4, usaState.features,"rgb(100,200,200)",'.25','.1',"rgb(1,255,255)")
staticLines(path5, redline_usa.features,"none",'1','.25',"rgb(200,0,0)")
function staticLines(path, data, sfill, sOpac, sW, stroke){
g.enter().append("path")
.data(data)
.enter()
.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(cityPoint.features,'5','black','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]-8})
.attr("cy",function(d) {return path.centroid(d)[1]-5})
.attr('r', r)
.attr('fill', sfill)
.style('fill-opacity',sOpac)
.style("stroke-width", sWidth)
.on("mouseover", addText)
}
function addText(event,d){
svg//draw text
.append("text") //appends path to data
.attr("class", "dText")
.attr('x', path.centroid(d)[0])
.attr("y", path.centroid(d)[1])
.attr("fill", "black")
.style("font-family", "helvetica")
.style("font-size", "15px")
.text(d.properties.City)
}
//lines from rhino
polyline(rec,"rgb(200,0,0)",'1','0','none')
polyline(pointCity,'black','1','2','black')
function polyline(data, sfill, sOpac, sW, stroke,classVar){
g.enter().append("polyline")
.data(data) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class',classVar)
.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',1)
.style("stroke-width", sW)
.style("stroke", stroke)
}
svg//draw text
.append("text") //appends path to data
.attr('class','mText')
.attr('x',80)
.attr("y",500)
.attr('fill', 'black')
.style('font-family','helvetica')
.style("font-size", "11px")
.text("Areas with redlining distribution")
svg//draw text
.append("text") //appends path to data
.attr('class','mText')
.attr('x',80)
.attr("y",520)
.attr('fill', 'black')
.style('font-family','helvetica')
.style("font-size", "11px")
.text("City under study")
return svg.node();
}