chart = {
const width = 960,
height = 800;
const svg = d3.create("svg")
.attr("viewBox", [-30, 60, width, height]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], map2);
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 g = svg.append("g").attr("id", "paths");
var displayedTypes ='All'
g.selectAll("path")
.data(map2.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "none")
.style('stroke-opacity','.2')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
var cir = svg.selectAll("circle")
.data(tLink)
.enter()
.append("circle")
.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', radiusType)
.attr('fill', fillColor)
.style('fill-opacity','1')
.style("stroke-width", "1")
.on('mouseover', spotText)
.on('mouseleave', spotErase)
function radiusType(d,i){
var radius = 4
if(d.type == 'plant'){radius= 6}
if(d.type == 'contractor') {radius = 4 }
return radius
}
function fillColor(d,i){
var fill = 'purple'
if(d.type == 'City'){fill ='orange'}
return fill
}
function spotSize(d,i){
var r = 3
if(d.type=='City'){r=2}
return r
}
if(totalvalue[0]>23){
svg.append('text')
.attr('class','spots')
.attr('x','480')
.attr('y','250')
.attr('font-family','Helvetica')
.attr('font-size','5.8em')
.attr('text-anchor','middle')
.attr('font-weight','bold')
.text('MUM IS TIRED')
}
if(totalvalue[1]>40){
svg.append('text')
.attr('class','spots')
.attr('x','480')
.attr('y','350')
.attr('font-family','Helvetica')
.attr('font-size','5.8em')
.attr('text-anchor','middle')
.attr('font-weight','bold')
.text('DAD GET BORED')
}if(totalvalue[2]>30){
svg.append('text')
.attr('class','spots')
.attr('x','480')
.attr('y','450')
.attr('font-family','Helvetica')
.attr('font-size','5.8em')
.attr('text-anchor','middle')
.attr('font-weight','bold')
.text('YOU ARE BROKE')
}
function spotText(event,d){
svg.append('text')
.attr('class','spots')
.attr('x','140')
.attr('y','280')
.attr("font-family", "Helvetica")
.attr('font-size','.75em')
.attr('fill','rgb(0,0,0)')
.attr('text-anchor','start')
.text(d.who)
svg.append('text')
.attr('class','spots')
.attr('x','140')
.attr('y','295')
.attr("font-family", "Helvetica")
.attr('font-size','.75em')
.attr('fill','rgb(0,0,0)')
.attr('text-anchor','start')
.text(d.describtion)
svg.append('line')
.attr('x1','140')
.attr('y1','300')
.attr('x2', projection([d.long,d.lat])[0])
.attr('y2','300')
.attr('stroke-width','1')
.attr('stroke-dasharray','4,4')
.attr('stroke','rgb(100,100,100)')
svg.append('line')
.attr('x1',projection([d.long,d.lat])[0])
.attr('y1','300')
.attr('x2',projection([d.long,d.lat])[0])
.attr('y2',projection([d.long,d.lat])[1])
.attr('stroke-width','1')
.attr('stroke-dasharray','4,4')
.attr('stroke','rgb(100,100,100)')
}
function spotErase(event,d){
d3.selectAll('circle.spots').style('fill',fillColor)
d3.selectAll('text.spots').remove()
d3.selectAll('line').remove()
}
var wrap = svg.selectAll("text.spotText")
.each(function(d, i) { wrap_text(d3.select(this), 100) });
function typeHighLight(event,d){
displayedTypes = d
d3.selectAll('circle.spots').attr('fill', eventType)
}
function eventType(d,i) {
var color='black'
if(d.type==displayedTypes){color='red'}
return color
}
function unHighLight(event,d) {
d3.selectAll('circle.spots').attr('fill', fillColor)
d3.selectAll('path.supplychainstep').remove()
}
return svg.node();
}