chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], boundingboxplswork);
var path1 = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var path4 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path3")
.data(statev21.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", ".5")
.style('stroke-opacity','.4')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
var cir = svg.selectAll("circle")
.data(nySpots)
.enter()
.append("circle")
.attr("r", "3")
.attr("cx", function(d) {return projection([d.long,d.lat])[0]})
.attr("cy", function(d) {return projection([d.long,d.lat])[1]})
.attr("class",nySpots)
.style("fill", fillcolor)
.style("fill-opacity", ".5")
.style('stroke-opacity','.4')
.style("stroke-width", '2')
.style("stroke", "rgb(0,0,0)")
function fillcolor(d,i){
var color = "rgb(200,0,200)"
if(d.Type== "food"){color = "rgb(255,0,0)"}
if(d.Type== "game"){color = "rgb(0,0,255)"}
return color
}
cir.enter().append("circle") //d3 geopath
.data(scSteps) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
//.attr('class','outlines')
.attr("r", "4") //The d attribute defines a path to be drawn, only applies to appended elements
.attr("cx", "150")
.attr("cy", function(d,i) {return 150+(i*20)})
.style("fill", "red")
.style("fill-opacity", "0")
.style('stroke-opacity','.4')
.style("stroke-width", '2')
.style("stroke", "rgb(0,0,0)")
.on("mouseover",animateMap)
.on("mouseout",stopAnimateMap)
function animateMap(event,d){
var tColor = "cyan"
if(d == "Raw Extraction"){
tColor = "yellow"
p.enter().append("polyline")//use this for all polylines after the first polyline
.data(faclines2) //get data to define path
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr('points', function(d){return d})
.attr("class", "mouseIcon")
.attr("transform", "translate(200,200)")
.style("fill", "magenta")
.style('stroke-opacity','1')
.style("stroke-width", '0')
.style("stroke", "rgb(0,0,0)")
p.enter().append("polyline")//use this for all polylines after the first polyline
.data(teststep2) //get data to define path
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr('points', function(d){return d})
.attr("class","mouseIcon")
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '2')
.style("stroke", "rgb(0,0,0)")
.style("stroke-dasharray","4 4")
}
svg
.append("text") //appends path to data
//.attr('class','outlines')
.attr("x", "300")
.attr("y", "700")
.attr("class","mouseText")
.style("font-family", "Helvetica")
.style("font-weight", "bold")
.style("font-size", "10px")
.style("text-anchor", "start")
.style("fill", tColor)
.style("fill-opacity", "1")
.text(d)
var wrap = svg.selectAll("text.description")
.each(function(d, i) { wrap_text(d3.select(this), 150) });//control how long the text lines are
}
function stopAnimateMap(event,d){
svg.selectAll("text.mouseText").remove()
svg.selectAll("polyline.mouseIcon").remove()
}
var tx = svg.selectAll("text") //d3 geopath
.data(scSteps) //get data to define path
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
//.attr('class','outlines')
.attr("x", "160")
.attr("y", function(d,i) {return 155+(i*20)})
.style("font-family", "Helvetica")
.style("font-weight", "bold")
.style("font-size", "10px")
.style("text-anchor", "start")
.style("fill", "black")
.style("fill-opacity", "1")
.text(function(d) {return d})
var p = svg.selectAll("polyline")
.data(lineTextFile) //get data to define path
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr('points', function(d){return d})
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '2')
.style("stroke", "rgb(0,0,0)")
.style("stroke-dasharray","4 4")
var p = svg.selectAll("polyline")
.data(teststep2) //get data to define path
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr('points', function(d){return d})
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '2')
.style("stroke", "rgb(0,0,0)")
.style("stroke-dasharray","4 4")
p.enter().append("polyline")//use this for all polylines after the first polyline
.data(faclines2) //get data to define path
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr('points', function(d){return d})
.style("fill", "black")
.style('stroke-opacity','1')
.style("stroke-width", '0')
.style("stroke", "rgb(0,0,0)")
//.style("stroke-dasharray","4 4")
//.attr("cx", function(d) {return projection([d.long,d.lat])[0]})
return svg.node();
}