chart = {
const width = 500,
height = 500;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
var g = svg.append("g").attr("id", "paths");
var p = svg.selectAll("polyline")
.data(outlines)
.enter()
.append("polyline")
.attr("points", function(d) {return d.pts})
.style("stroke","black")
.style("stroke-width","0.1px")
.style("fill",fillColor)
.on("mouseover",polyHover)
.on("mouseout",polyHoverOut)
function fillColor(d,i){
var color = "rgb(255,165,0)"
if(d.Transportation=="4, 5"){color="rgb(0,102,51)"}
if(d.Transportation=="2, 3"){color="blue"}
if(d.Transportation=="1"){color="rgb(180,0,0)"}
if(d.Transportation=="J, Z"){color="rgb(139,69,19)"}
if(d.Transportation=="FERRY"){color="pink"}
if(d.Transportation=="R, W"){color="rgb(255,255,0)"}
return color
}
//p.enter().append("polyline") //use this line after the first polyline is added
//.data(detail)
// .enter() //there are more data than elements, this selects them
//.append("polyline") //appends path to data
//.attr("points", function(d) {return d})//required attributes
//.style("stroke","grey")//style
//.style("stroke-width","1px")
// .style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(baselines)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","black")//style
.style("stroke-width","0.1px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(red1)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","red")//style
.style("stroke-width","1.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(blue)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","blue")//style
.style("stroke-width","1.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(darkgreen)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","rgb(0,102,51)")//style
.style("stroke-width","1.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(yellow)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","yellow")//style
.style("stroke-width","1.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(darkred)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","rgb(180,0,0)")//style
.style("stroke-width","1.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(brown)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","rgb(139,69,19)")//style
.style("stroke-width","1.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(buscyan)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","rgb(128,255,255)")//style
.style("stroke-width","0.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(busgreen)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","rgb(153,255,102)")//style
.style("stroke-width","0.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(buspink)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","rgb(255,204,204)")//style
.style("stroke-width","0.5px")
.style("fill","none")
p.enter().append("polyline") //use this line after the first polyline is added
.data(outlined)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","white")//style
.style("stroke-width","1px")
.style("fill","none")
function polyHover(event,d){
d3.select(this).style("fill","red")
svg
.append("text")
.attr("x","350")
.attr("y","350")
.attr("class","hoverText")
.text(d.Address)
.style ("font-size", "5px")
svg
.append("text")
.attr("x","350")
.attr("y","355")
.attr("class","hoverText")
.text(d.BuildingType)
.style ("font-size", "5px")
svg
.append("text")
.attr("x","350")
.attr("y","360")
.attr("class","hoverText")
.text(d.Workersnumber)
.style ("font-size", "5px")
svg
.append("text")
.attr("x","350")
.attr("y","365")
.attr("class","hoverText")
.text(d.Transportation)
.style ("font-size", "5px")
svg
.append("text")
.attr("x","350")
.attr("y","370")
.attr("class","hoverText")
.text(d.Availability)
.style ("font-size", "5px")
svg
.append("text")
.attr("x","350")
.attr("y","375")
.attr("class","hoverText")
.text(d.TotalYearlyRidership2021)
.style ("font-size", "5px")
svg
.append("text")
.attr("x","350")
.attr("y","380")
.attr("class","hoverText")
.text(d.AvgWeekdayRidership2021)
.style ("font-size", "5px")
}
function polyHoverOut(){
d3.select(this).style("fill",fillColor)
svg.selectAll("text.hoverText").remove()
}
return svg.node();
}