chart = {
const width = 1225,
height = 700;
const svg = d3.create("svg")
.attr("viewBox", [50, 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");
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
*/
/*
g.selectAll("path2") //d3 geopath
.data(aslnywalk.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path3") //d3 geopath
.data(sbpwalk.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path4") //d3 geopath
.data(midtownBL.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(242,234,233)")
.style("fill-opacity", ".6")
.style('stroke-opacity','.4')
.style("stroke-width", '.25')
.style("stroke", "rgb(99,48,64)")
*/
/*
g.selectAll("path4") //d3 geopath
.data(DCchesapeake.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path4) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(242,234,233)")
.style("fill-opacity", ".5")
.style('stroke-opacity','.8')
.style("stroke-width", '.25')
.style("stroke", "rgb(99,48,64)")
g.selectAll("path7") //d3 geopath
.data(DCpotomac.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path7) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(242,234,233)")
.style("fill-opacity", ".5")
.style('stroke-opacity','.8')
.style("stroke-width", '.25')
.style("stroke", "rgb(99,48,64)")
/*
/*
g.selectAll("path5") //d3 geopath
.data(DCroads.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path5) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','.8')
.style("stroke-width", '.2')
.style("stroke", "rgb(white)")
*/
g.selectAll("path9") //d3 geopath
.data(DMV_stateboundaries.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','static')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style("stroke", "rgb(0,0,0)")
.style('stroke-opacity','.05')
.style("stroke-width", '3')
var Global = 56
function fillHideDot(d,i){
// console.log(Global) //
var color = 'none'
if(d.YEAR_ADDED <= Global) {color = 'white'}
return color
}
function fillHideStroke(d,i){
// console.log(Global) //
var color = 'none'
if(d.YEAR_ADDED <= Global) {color = 'black'}
return color
}
function filterClick(event,d){
var s = d
console.log(d)
Global = d
if(d=='Current'){
d3.selectAll('path.outlines').remove()
d3.selectAll('text.lineInfo').remove()
g.selectAll("path8") //d3 geopath
.data(newtracts2010_DC.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", d => color(d.properties.DENSITY))
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.4')
.style("stroke-width", '.1')
g.selectAll("path8") //d3 geopath
.data(newtracts2010_MD.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", d => color(d.properties.PSQM))
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.4')
.style("stroke-width", '.1')
g.selectAll("path8") //d3 geopath
.data(newtracts2010_VA.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", d => color(d.properties.POP10_SQMI))
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.4')
.style("stroke-width", '.1')
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','80')
.attr('font-family','Tahoma')
.attr('font-size','.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text('Present-day Washington Metro map')
g.selectAll("path6") //d3 geopath
.data(DClines.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
}
if(d=='1976'){
d3.selectAll('path.outlines').remove()
d3.selectAll('text.lineInfo').remove()
d3.selectAll('path.tractshift').remove()
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','80')
.attr('font-family','Tahoma')
.attr('font-size','.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text('The opening day of Metrorail')
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','100')
.attr('font-family','Tahoma')
.attr('font-size','.5em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text('By the end of 1976, Metrorail had opened its first six stations on the Red Line between Farragut North and Rhode Island Ave.')
g.selectAll("path8") //d3 geopath
.data(DCtracts1970.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", tractPop70)
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.7')
.style("stroke-width", '.1')
function tractPop70(d,i) {
var color = 'black'
if(d.properties.CY7001 >= 8000){color = 'rgb(55, 175, 255)'}
if(d.properties.CY7001 >= 7000 && d.properties.CY7001 <= 8000){color = 'rgb(82, 184, 255)'}
if(d.properties.CY7001 >= 6000 && d.properties.CY7001 <= 7000){color = 'rgb(105, 193, 255)'}
if(d.properties.CY7001 >= 5000 && d.properties.CY7001 <= 6000){color = 'rgb(125, 202, 254)'}
if(d.properties.CY7001 >= 4000 && d.properties.CY7001 <= 5000){color = 'rgb(145, 211, 254)'}
if(d.properties.CY7001 >= 3000 && d.properties.CY7001 <= 4000){color = 'rgb(164, 219, 254)'}
if(d.properties.CY7001 >= 2000 && d.properties.CY7001 <= 3000){color = 'rgb(182, 227, 254)'}
if(d.properties.CY7001 >= 1000 && d.properties.CY7001 <= 2000){color = 'rgb(201, 235, 254)'}
if(d.properties.CY7001 <= 1000){color = 'rgb(220, 243, 255)'}
return color
}
g.selectAll("path6") //d3 geopath
.data(lines1976.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tracts')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
}
if(d=='1978'){
d3.selectAll('path.outlines').remove()
d3.selectAll('text.lineInfo').remove()
d3.selectAll('path.tractshift').remove()
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','80')
.attr('font-family','Tahoma')
.attr('font-size','.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text('Red Line expands, Blue Line opens')
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','100')
.attr('font-family','Tahoma')
.attr('font-size','.5em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text('The next two years saw an extension of the Red Line northward to the Maryland suburb of Silver Spring, as well as the launch of the Blue Line linking the Capitol Hill region with Arlington, Virginia and Reagan National Airport. Metro Center was established as the primary interchange.')
g.selectAll("path8") //d3 geopath
.data(DCtracts1970.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", tractPop70)
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.7')
.style("stroke-width", '.1')
function tractPop70(d,i) {
var color = 'black'
if(d.properties.CY7001 >= 8000){color = 'rgb(55, 175, 255)'}
if(d.properties.CY7001 >= 7000 && d.properties.CY7001 <= 8000){color = 'rgb(82, 184, 255)'}
if(d.properties.CY7001 >= 6000 && d.properties.CY7001 <= 7000){color = 'rgb(105, 193, 255)'}
if(d.properties.CY7001 >= 5000 && d.properties.CY7001 <= 6000){color = 'rgb(125, 202, 254)'}
if(d.properties.CY7001 >= 4000 && d.properties.CY7001 <= 5000){color = 'rgb(145, 211, 254)'}
if(d.properties.CY7001 >= 3000 && d.properties.CY7001 <= 4000){color = 'rgb(164, 219, 254)'}
if(d.properties.CY7001 >= 2000 && d.properties.CY7001 <= 3000){color = 'rgb(182, 227, 254)'}
if(d.properties.CY7001 >= 1000 && d.properties.CY7001 <= 2000){color = 'rgb(201, 235, 254)'}
if(d.properties.CY7001 <= 1000){color = 'rgb(220, 243, 255)'}
return color
}
g.selectAll("path6") //d3 geopath
.data(lines1978.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
/*
var c = svg.selectAll("circle") //d3 geopath
.data(DCstationsNEW)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return projection([d.X,d.Y])[0]})
.attr("cy", function(d) {return projection([d.X,d.Y])[1]})
.attr('r',3)
.attr('class','stationDots')
.attr('fill','white')
.style('fill-opacity','3')
.attr('stroke-opacity','1')
.attr("stroke-width", "1.25")
.attr("stroke", "black")
*/
}
if(d=='1983'){
d3.selectAll('path.outlines').remove()
d3.selectAll('text.lineInfo').remove()
d3.selectAll('path.tractshift').remove()
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','80')
.attr('font-family','Tahoma')
.attr('font-size','.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text('Orange and Yellow lines open')
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','100')
.attr('font-family','Tahoma')
.attr('font-size','.5em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text('The Orange Line, which initially opened in late 1978 as a complement to the Blue Line, eventually detached and formed a second east-west linkage. The Red Line saw modest expansions to the northwest, and the launch of the Yellow Line in 1983 offered a direct line between the National Mall and Reagan National Airport.')
g.selectAll("path8") //d3 geopath
.data(DCtracts1980.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", tractPop80)
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.7')
.style("stroke-width", '.1')
function tractPop80(d,i) {
var color = 'black'
if(d.properties.C7L001 >= 8000){color = 'rgb(55, 175, 255)'}
if(d.properties.C7L001 >= 7000 && d.properties.C7L001 <= 8000){color = 'rgb(82, 184, 255)'}
if(d.properties.C7L001 >= 6000 && d.properties.C7L001 <= 7000){color = 'rgb(105, 193, 255)'}
if(d.properties.C7L001 >= 5000 && d.properties.C7L001 <= 6000){color = 'rgb(125, 202, 254)'}
if(d.properties.C7L001 >= 4000 && d.properties.C7L001 <= 5000){color = 'rgb(145, 211, 254)'}
if(d.properties.C7L001 >= 3000 && d.properties.C7L001 <= 4000){color = 'rgb(164, 219, 254)'}
if(d.properties.C7L001 >= 2000 && d.properties.C7L001 <= 3000){color = 'rgb(182, 227, 254)'}
if(d.properties.C7L001 >= 1000 && d.properties.C7L001 <= 2000){color = 'rgb(201, 235, 254)'}
if(d.properties.C7L001 <= 1000){color = 'rgb(220, 243, 255)'}
return color
}
g.selectAll("path6") //d3 geopath
.data(lines1983.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
}
if(s=='1991'){
d3.selectAll('path.outlines').remove()
d3.selectAll('text.lineInfo').remove()
d3.selectAll('path.tractshift').remove()
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','80')
.attr('font-family','Tahoma')
.attr('font-size','.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text('Expansions and opening of the Green Line')
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','100')
.attr('font-family','Tahoma')
.attr('font-size','.5em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text('Between 1983 and 1991, the Red Line saw major expansions into the Maryland suburbs at both ends of the line. The Orange Line also saw substantial expansion on its western end into the Virginia suburbs, while the Blue and Yellow lines had smaller growth. The opening of the Green Line marked the first Metro extension into Anacostia.')
g.selectAll("path8") //d3 geopath
.data(DCtracts1990.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", tractPop90)
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.7')
.style("stroke-width", '.1')
function tractPop90(d,i) {
var color = 'black'
if(d.properties.FULLTOTAL >= 8000){color = 'rgb(55, 175, 255)'}
if(d.properties.FULLTOTAL >= 7000 && d.properties.FULLTOTAL <= 8000){color = 'rgb(82, 184, 255)'}
if(d.properties.FULLTOTAL >= 6000 && d.properties.FULLTOTAL <= 7000){color = 'rgb(105, 193, 255)'}
if(d.properties.FULLTOTAL >= 5000 && d.properties.FULLTOTAL <= 6000){color = 'rgb(125, 202, 254)'}
if(d.properties.FULLTOTAL >= 4000 && d.properties.FULLTOTAL <= 5000){color = 'rgb(145, 211, 254)'}
if(d.properties.FULLTOTAL >= 3000 && d.properties.FULLTOTAL <= 4000){color = 'rgb(164, 219, 254)'}
if(d.properties.FULLTOTAL >= 2000 && d.properties.FULLTOTAL <= 3000){color = 'rgb(182, 227, 254)'}
if(d.properties.FULLTOTAL >= 1000 && d.properties.FULLTOTAL <= 2000){color = 'rgb(201, 235, 254)'}
if(d.properties.FULLTOTAL <= 1000){color = 'rgb(220, 243, 255)'}
return color
}
g.selectAll("path6") //d3 geopath
.data(lines1991.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
}
if(d=='2004'){
d3.selectAll('path.outlines').remove()
d3.selectAll('text.lineInfo').remove()
d3.selectAll('path.tractshift').remove()
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','80')
.attr('font-family','Tahoma')
.attr('font-size','.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text('Growth of the Green Line')
svg.append('text')
.attr('class','lineInfo')
.attr('x','520')
.attr('y','100')
.attr('font-family','Tahoma')
.attr('font-size','.5em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text('The Green Line saw the most substantial expansion of any Metro line between 1991 and 2004, and now included a station at the University of Maryland campus in College Park.')
g.selectAll("path8") //d3 geopath
.data(DCtracts2000.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','tractshift')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", tractPop00)
.style('fill-opacity','.6')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.7')
.style("stroke-width", '.1')
function tractPop00(d,i) {
var color = 'black'
if(d.properties.TOTAL >= 8000){color = 'rgb(55, 175, 255)'}
if(d.properties.TOTAL >= 7000 && d.properties.TOTAL <= 8000){color = 'rgb(82, 184, 255)'}
if(d.properties.TOTAL >= 6000 && d.properties.TOTAL <= 7000){color = 'rgb(105, 193, 255)'}
if(d.properties.TOTAL >= 5000 && d.properties.TOTAL <= 6000){color = 'rgb(125, 202, 254)'}
if(d.properties.TOTAL >= 4000 && d.properties.TOTAL <= 5000){color = 'rgb(145, 211, 254)'}
if(d.properties.TOTAL >= 3000 && d.properties.TOTAL <= 4000){color = 'rgb(164, 219, 254)'}
if(d.properties.TOTAL >= 2000 && d.properties.TOTAL <= 3000){color = 'rgb(182, 227, 254)'}
if(d.properties.TOTAL >= 1000 && d.properties.TOTAL <= 2000){color = 'rgb(201, 235, 254)'}
if(d.properties.TOTAL <= 1000){color = 'rgb(220, 243, 255)'}
return color
}
g.selectAll("path6") //d3 geopath
.data(lines2004.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
}
var wrap = svg.selectAll("text.lineInfo")
.each(function(d,i) { wrap_text(d3.select(this), 350) });
if(100<1000){
d3.selectAll('circle.stationDots').remove()
c.enter().append("circle") //d3 geopath
.data(DCstationsGROWTH)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.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','710')
.attr('y','508')
.attr('font-family','Tahoma')
.attr('font-size','0.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text(d.NAME)
svg.append('text')
.attr('class','spots')
.attr('x','710')
.attr('y','530')
.attr('font-family','Tahoma')
.attr('font-size','0.6em')
.attr('fill', 'black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text(d.LINE)
svg.append('text')
.attr('class','spots')
.attr('x','725')
.attr('y','545')
.attr('font-family','Tahoma')
.attr('font-size','0.6em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text(d.YEAR_ADDED)
/*
svg.append('text')
.attr('class','spots')
.attr('x','720')
.attr('y','515')
.attr('font-family','Helvetica')
.attr('font-size','.5em')
.attr('text-anchor','start')
.attr('font-weight','normal')
.attr('font-style','italic')
.text(d.type)
*/
svg.append('line')
.attr('class','spotLine')
.attr('x1','700')
.attr('y1','505')
.attr('x2',projection([d.LONG,d.LAT])[0])
.attr('y2','505')
.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','505')
.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()
}
}
}
var t = svg.selectAll("text")
.data(chronology)
.enter()
.append('text')
.attr('x',1071)
.attr('y',function(d,i) {return 284+35*i})
.attr('font-family','Tahoma')
.attr('font-size','0.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','300')
.text(function(d) {return d})
g.selectAll("path6") //d3 geopath
.data(DClines.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
function lineType(d,i) {
var color = 'black'
if(d.properties.NAME=='silver'){color = 'silver'}
if(d.properties.NAME=='blue'){color = 'blue'}
if(d.properties.NAME=='yellow'){color = 'yellow'}
if(d.properties.NAME=='green'){color = 'green'}
if(d.properties.NAME=='red'){color = 'red'}
if(d.properties.NAME=='orange'){color = 'orange'}
return color
}
g.selectAll("path6") //d3 geopath
.data(lines1976.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
g.selectAll("path6") //d3 geopath
.data(lines1978.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
g.selectAll("path6") //d3 geopath
.data(lines1983.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
g.selectAll("path6") //d3 geopath
.data(lines1991.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
g.selectAll("path6") //d3 geopath
.data(lines2004.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.attr('stroke',lineType91) // add function to control color by 'type'
.style('stroke-opacity','1')
.style("stroke-width", '2')
function lineType91(d,i) {
var color = 'black'
if(d.properties.Text=='silver'){color = 'silver'}
if(d.properties.Text=='blue'){color = 'blue'}
if(d.properties.Text=='yellow'){color = 'yellow'}
if(d.properties.Text=='green'){color = 'green'}
if(d.properties.Text=='red'){color = 'red'}
if(d.properties.Text=='orange'){color = 'orange'}
return color
}
var c = svg.selectAll("circle") //d3 geopath
.data(DCstationsGROWTH)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.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','white')
.style('fill-opacity','3')
.attr('stroke-opacity','1')
.attr("stroke-width", "1.25")
.attr("stroke", "black")
.on('mouseover', spotText)
.on('mouseout', removeSpotText)
/*
c.enter().append("circle") //d3 geopath
.data(DCdeserts)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.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','red')
.style('fill-opacity','3')
.attr('stroke-opacity','1')
.attr("stroke-width", "1.25")
.attr("stroke", "black")
.on('mouseover', NewSpotText)
.on('mouseout', removeNewSpotText)
*/
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','929')
.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','929')
.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','929')
.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('text')
.attr('class','spots')
.attr('x','720')
.attr('y','515')
.attr('font-family','Helvetica')
.attr('font-size','.5em')
.attr('text-anchor','start')
.attr('font-weight','normal')
.attr('font-style','italic')
.text(d.type)
*/
svg.append('line')
.attr('class','spotLine')
.attr('x1','911')
.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-width", "1.25")
d3.select(this).attr('r',3)
d3.selectAll('text.spots').remove()
d3.selectAll('line.spotLine').remove()
}
/*
function NewSpotText(event,d){
d3.select(this)
.attr('fill','deepskyblue')
.attr('r',8)
.style("stroke", "lightskyblue")
.style("stroke-opacity",'.75')
.style("stroke-width", '8')
svg.append('text')
.attr('class','spots')
.attr('x','710')
.attr('y','508')
.attr('font-family','Tahoma')
.attr('font-size','0.8em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text(d.name)
svg.append('text')
.attr('class','spots')
.attr('x','710')
.attr('y','530')
.attr('font-family','Tahoma')
.attr('font-size','0.6em')
.attr('fill', 'black')
.attr('text-anchor','start')
.attr('font-weight','600')
.text(d.LINE)
svg.append('text')
.attr('class','spots')
.attr('x','710')
.attr('y','545')
.attr('font-family','Tahoma')
.attr('font-size','0.6em')
.attr('fill','black')
.attr('text-anchor','start')
.attr('font-weight','400')
.text(d.YEAR_ADDED)
svg.append('line')
.attr('class','spotLine')
.attr('x1','700')
.attr('y1','505')
.attr('x2',projection([d.long,d.lat])[0])
.attr('y2','505')
.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','505')
.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 removeNewSpotText(event,d) {
d3.select(this).attr('fill','red')
d3.select(this).style('fill-opacity','3')
d3.select(this).style("stroke", "rgb(0,0,0)")
d3.select(this).style("stroke-width", "1.25")
d3.select(this).attr('r',3)
d3.selectAll('text.spots').remove()
d3.selectAll('line.spotLine').remove()
}
*/
c.enter().append('circle') //d3 geopath
.data(chronology)
.enter()
.append('circle')
.attr('cx',1051)
.attr('cy',function(d,i) {return 280+35*i})
.attr('r',6)
.attr('fill','black')
.on('click',filterClick)
/*
var c = svg.selectAll("path8") //d3 geopath
.data(DCdata1970) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.attr('fill','blue')
.attr('stroke-opacity','.1')
.attr("stroke-width", ".25")
.attr("stroke", "rgb(86,86,86)")
.style('fill-opacity','.1')
*/
/*
g.selectAll("path8") //d3 geopath
.data(DCtracts2010.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','city')
.attr("d", path8) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", tractPop70)
.style('fill-opacity','.3')
.attr('stroke','black') // add function to control color by 'type'
.style('stroke-opacity','.7')
.style("stroke-width", '.1')
function tractPop70(d,i) {
var color = 'black'
if(d.properties.CY7001 >= 8000){color = 'rgb(55, 175, 255)'}
if(d.properties.CY7001 >= 7000 && d.properties.CY7001 <= 8000){color = 'rgb(82, 184, 255)'}
if(d.properties.CY7001 >= 6000 && d.properties.CY7001 <= 7000){color = 'rgb(105, 193, 255)'}
if(d.properties.CY7001 >= 5000 && d.properties.CY7001 <= 6000){color = 'rgb(125, 202, 254)'}
if(d.properties.CY7001 >= 4000 && d.properties.CY7001 <= 5000){color = 'rgb(145, 211, 254)'}
if(d.properties.CY7001 >= 3000 && d.properties.CY7001 <= 4000){color = 'rgb(164, 219, 254)'}
if(d.properties.CY7001 >= 2000 && d.properties.CY7001 <= 3000){color = 'rgb(182, 227, 254)'}
if(d.properties.CY7001 >= 1000 && d.properties.CY7001 <= 2000){color = 'rgb(201, 235, 254)'}
if(d.properties.CY7001 <= 1000){color = 'rgb(220, 243, 255)'}
return color
}
*/
/*
svg.append('text')
.attr('class','spots')
.attr('x','720')
.attr('y','515')
.attr('font-family','Helvetica')
.attr('font-size','.5em')
.attr('text-anchor','start')
.attr('font-weight','normal')
.attr('font-style','italic')
.text(d.type)
*/
/*
c.enter.append('circle')// format to add additional circles
.data(spots)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return projection([d.longitude,d.latitude])[0]})
.attr("cy", function(d) {return projection([d.longitude,d.latitude])[1]})
.attr('r',3)
.attr('fill','black')
.style('fill-opacity','1')
*/
return svg.node();
}