chart = {
const width = 1300,
height = 700;
const svg = d3.create("svg")
.attr("viewBox", [25, 25, width-100, height-90]);
var projection = d3
.geoMercator()
.fitSize([width - 10, height - 40], DCbb);
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 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 path10 = d3.geoPath().projection(projection);
var path11 = d3.geoPath().projection(projection);
var path12 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path9")
.data(DMV_stateboundaries.features)
.enter()
.append("path")
.attr('class','static')
.attr("d", path6)
.style("fill", "none")
.style("stroke", "rgb(0,0,0)")
.style('stroke-opacity','.05')
.style("stroke-width", '3')
function fillHideDot(d,i){
var color = 'none'
if(d.YEAR_ADDED <= Selectyear) {color = 'white'}
return color
}
function fillHideStroke(d,i){
var color = 'none'
if(d.YEAR_ADDED <= Selectyear) {color = 'black'}
return color
}
function fillHideTrain(d,i){
var color = 'none'
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='silver'){color = 'silver'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='blue'){color = 'dodgerblue'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='yellow'){color = 'gold'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='green'){color = 'olivedrab'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='red'){color = 'crimson'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='orange'){color = 'peru'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='purple'){color = 'rebeccapurple'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='pink'){color = 'orchid'}
if(d.properties.LINE_ADDED <= Selectyear && d.properties.NAME=='teal'){color = 'mediumturquoise'}
return color
}
g.selectAll("path6")
.data(DClines.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path6)
.style("fill", "none")
.attr('stroke', fillHideTrain)
.style('stroke-opacity','1')
.style("stroke-width", '3')
function lineType(d,i) {
var color = 'black'
if(d.properties.NAME=='silver'){color = 'silver'}
if(d.properties.NAME=='blue'){color = 'dodgerblue'}
if(d.properties.NAME=='yellow'){color = 'gold'}
if(d.properties.NAME=='green'){color = 'olivedrab'}
if(d.properties.NAME=='red'){color = 'crimson'}
if(d.properties.NAME=='orange'){color = 'peru'}
if(d.properties.NAME=='purple'){color = 'rebeccapurple'}
if(d.properties.NAME=='pink'){color = 'orchid'}
if(d.properties.NAME=='teal'){color = 'mediumturquoise'}
return color
}
var c = svg.selectAll("circle")
.data(DCstationsGROWTH)
.enter()
.append("circle")
.attr("cx", function(d) {return projection([d.LONG,d.LAT])[0]})
.attr("cy", function(d) {return projection([d.LONG,d.LAT])[1]})
.attr('r',3)
.attr('class','stationDots')
.attr('fill',fillHideDot)
.style('fill-opacity','3')
.attr('stroke-opacity','1')
.attr("stroke-width", "1.25")
.attr("stroke", fillHideStroke)
.on('mouseover', spotText)
.on('mouseout', removeSpotText)
function spotText(event,d){
d3.select(this)
.attr('fill','hotpink')
.attr('r',8)
.style("stroke", "lightpink")
.style("stroke-opacity",'.75')
.style("stroke-width", '8')
svg.append('text')
.attr('class','spots')
.attr('x','1029')
.attr('y','69')
.attr('font-family','Tahoma')
.attr('font-size','0.9em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text(d.NAME)
svg.append('text')
.attr('class','spots')
.attr('x','1029')
.attr('y','89')
.attr('font-family','Tahoma')
.attr('font-size','0.7em')
.attr('fill', 'black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text(d.LINE)
svg.append('text')
.attr('class','spots')
.attr('x','1029')
.attr('y','109')
.attr('font-family','Tahoma')
.attr('font-size','0.7em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text(d.YEAR_ADDED)
svg.append('line')
.attr('class','spotLine')
.attr('x1','1011')
.attr('y1','69')
.attr('x2',projection([d.LONG,d.LAT])[0])
.attr('y2','69')
.style('stroke-width','1')
.style('stroke','black')
.style('stroke-dasharray','4 2')
svg.append('line')
.attr('class','spotLine')
.attr('x1',projection([d.LONG,d.LAT])[0])
.attr('y1','69')
.attr('x2',projection([d.LONG,d.LAT])[0])
.attr('y2',projection([d.LONG,d.LAT])[1])
.style('stroke-width','1')
.style('stroke','black')
.style('stroke-dasharray','4 2')
}
function removeSpotText(event,d) {
d3.select(this).attr('fill','white')
d3.select(this).style('fill-opacity','3')
d3.select(this).style("stroke", "rgb(0,0,0)")
d3.select(this).style('stroke-opacity','.6')
d3.select(this).style("stroke-width", "1.25")
d3.select(this).attr('r',3)
d3.selectAll('text.spots').remove()
d3.selectAll('line.spotLine').remove()
}
return svg.node();
}