chart = {
const width = 600,
height = 725;
const svg = d3.create("svg")
.attr("viewBox", [-20, 10, width, height]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 5], inglewood);
var path = d3.geoPath().projection(projection);
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 c = svg.selectAll("circle");
var g = svg.append("g").attr("id", "paths");
g.selectAll("path")
.data(zips.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "rgb(225,225,225)")
.style('fill-opacity','.75')
.style("stroke-width", "0")
.style("stroke", "#ccc")
// Parks
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(parks3.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "green")
.style('fill-opacity','0.15')
.style("stroke-width", "0.2")
.style("stroke", "black")
// Cemetary
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(Cemetary.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "green")
.style('fill-opacity','0.15')
.style("stroke-width", "0.2")
.style("stroke", "black")
// Highways
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(LAHighways.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "green")
.style('fill-opacity','0')
.style("stroke-width", "2")
.style("stroke", "rgb(225,165,0)")
.style('stroke-opacity','0.5')
// Main Roads
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(LAMainRoads.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "green")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "white")
.style('stroke-opacity','0.9')
// Streets
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(streets.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "green")
.style('fill-opacity','0')
.style("stroke-width", "0.5")
.style("stroke", "white")
.style('stroke-opacity','0.9')
// Rivers
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(rivers.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
// .style("fill", "blue")
.style('fill-opacity','0')
.style("stroke-width", "3")
.style("stroke", "rgb(135,206,250)")
.style('stroke-opacity','0.9')
// FootPrints
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(Buildings.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(200,200,200)")
.style('fill-opacity','0.75')
.style("stroke-width", "0.15")
.style("stroke", "black")
// SoFi FootPrint
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(SoFi.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(200,200,200)")
.style('fill-opacity','0.55')
.style("stroke-width", "0.15")
.style("stroke", "black")
// Station text
var t = svg.selectAll("text")//creating a variable t and adding all text objects to it
.data(stations.features)
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-5})
.attr('font-family','helvetica')
.attr('font-size','.45em')
.attr('font-weight','550')
.style("fill", "rgb(50,50,50)")
.attr('text-anchor','left')
.text(function(d) {return d.properties.Name})
// Metro C
g.selectAll("path3") //d3 geopath
//svg
//.selectAll('path')
.data(MetroC.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "green")
.style('fill-opacity','0')
.style("stroke-width", ".5")
.style("stroke", "rgb(50,205,50)")
.style('stroke-opacity','0.75')
// Rail Stations
//g.selectAll("circle") //d3 geopath
var c = svg.selectAll('circle')
c.enter().append('circle')
//svg
//.selectAll('path')
.data(stations.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy", function(d) {return path.centroid(d)[1]})
.attr('r',2.5)
.attr("fill", "rgb(128,128,128)")
.style('fill-opacity','1')
//Bus Stops
//g.selectAll("circle2") //d3 geopath
c.enter().append('circle')
//svg
//.selectAll('path')
.data(BusStops.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('cx',function(d) {return path.centroid(d)[0]})
.attr("cy", function(d) {return path.centroid(d)[1]})
.attr('r',1.5)
.attr("fill", "rgb(255,255,255)")
.style('fill-opacity','1')
.style("stroke-width", ".25")
.style("stroke", "rgb(0,0,0)")
.on('mouseover', addBus)
.on('mouseout', removeBus)
// add Bus tool tip
var tooltip = svg.append("g");
function addBus(event, d) {
var centroid = path.centroid(d);
tooltip.call(
callout,
`Bus Stop: ${d.properties.STOPNAME} `
);
tooltip.attr("transform", "translate(" + centroid + ")");
}
// // remove Bus tool tip
function removeBus(event, d)
{tooltip.call(callout,null)
}
//Olympic text
var t = svg.selectAll("text")
.data(olympics.features)
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr("x", function(d) {return path1.centroid(d)[0]})
.attr("y", function(d) {return path1.centroid(d)[1]-5})
.attr('font-family','helvetica')
.attr('font-size','.4em')
.attr('font-weight','450')
.style("fill", "rgb(0,0,0)")
.attr('text-anchor','middle')
.text(function(d) {return d.properties.name})
// Light Traffic
g.selectAll("path4") //d3 geopath
//svg
//.selectAll('path')
.data(T11.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "green")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "rgb(96,224,76)")
.style('stroke-opacity','0.7')
// Medium Traffic
g.selectAll("path5") //d3 geopath
//svg
//.selectAll('path')
.data(T12.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "yellow")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "rgb(237,135,33)")
.style('stroke-opacity','0.7')
// Heavy Traffic
g.selectAll("path6") //d3 geopath
//svg
//.selectAll('path')
.data(T13.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "yellow")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "rgb(222,44,31)")
.style('stroke-opacity','0.7')
// Very Heavy Traffic
g.selectAll("path7") //d3 geopath
//svg
//.selectAll('path')
.data(T14.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "yellow")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "rgb(120,27,8)")
.style('stroke-opacity','0.7')
// Heavy Traffic
g.selectAll("path6") //d3 geopath
//svg
//.selectAll('path')
.data(T132.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", path) //The d attribute defines a path to be drawn, only applies to appended elements
//.style("fill", "yellow")
.style('fill-opacity','0')
.style("stroke-width", "1")
.style("stroke", "rgb(222,44,31)")
.style('stroke-opacity','0.7')
svg.append("g")
.call(legend);
scaleBar
.projection(projection)
.size([width, height]);
svg.append("g")
.call(scaleBar);
return svg.node();
}