chart = {
const width = 1000,
height = 1000;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width-1, height-1]);
var projection = d3
.geoMercator()
.fitSize([width, height], box);
var path = 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 g = svg.selectAll('g').attr("id", "paths");
var c = svg.selectAll("circle")
var p = svg.selectAll("polyline")
var t = svg.selectAll("text")
staticLines(path5, surfacestuff.features,"rgb(30, 30, 30)",'1','1',"Gray")
staticLines(path3, roads.features,"none",'1','.5',"Gray")
function staticLines(path, data, sfill, sOpac, sW, stroke){
g.enter().append("path")
.data(data) //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", sfill)
.style('stroke-opacity',sOpac)
.style("stroke-width", sW)
.style("stroke", stroke)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// BORDER LINES
//polyline(chunkyborder,'black','1','2','black')
//polyline(chunkyextra,'none','1','1','White')
//polyline(chunckypanel,'rgb(40, 40, 40)','1','1','White')
polyline(xfillborder,'black','1','2','black')
polyline(xinnerborder,'none','1','2','White')
polyline(xpanels,'rgb(40, 40, 40)','1','1','White')
polyline(lakes,'rgb(25, 25, 25)','1','2','white')
function polyline(data, sfill, sOpac, sW, stroke){
g.enter().append("polyline")
.data(data) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr("points", function(d){return d}) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", sfill)
.style('stroke-opacity',sOpac)
.style("stroke-width", sW)
.style("stroke", stroke)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ZONE BOX
g.enter().append("polyline")
.data(data) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','zone')
.attr("points", rangebox) //The d attribute defines a path to be drawn, only applies to appended elements
.attr('transform',function(d) {return'translate('+480+','+420+')'})
//.attr('x', 800)
//.attr("y", 100)
.style("fill", 'white')
.style('fill-opacity','.01')
.style("stroke-width", '1')
.style('stroke-dasharray','5 5')
.style("stroke", "White")
.on("mouseover", addZoneIcon)
.on("mouseout", removeZoneIcon)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// LONGBOARD ICON
p.enter().append("polyline")
.data(Spots) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','spotsName')
.attr("points", theicon) //The d attribute defines a path to be drawn, only applies to appended elements
.attr('transform',function(d) {return'translate('+projection([d.Longitude,d.Latitude])[0]+','+projection([d.Longitude,d.Latitude])[1]+')'})
.style("fill", 'Gray')
.style("stroke-width", '1')
.style("stroke", "white")
.on("mouseover", addText)
.on("mouseout", removeText)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ORIGINAL SPOTS
//points from spreadsheet
/*
c.enter().append('circle')
.data(Spots) //get data to define path
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr('class','spotsName')
.attr('cx',function(d) {return projection([d.Longitude,d.Latitude])[0]})
.attr("cy",function(d) {return projection([d.Longitude,d.Latitude])[1]})
.attr('r', '8')
.attr('fill', 'DarkSlateGray')
.style('fill-opacity','1')
.style("stroke-width", "1")
.on("mouseover", addText)
.on("mouseout", removeText)
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// PLACE + TYPE : TEXT EVENT
function addText(event,d){
svg
.append("text") //appends path to data
.attr('class','spotsName')
.attr('x', 790)
.attr("y", 200)
.attr('fill', 'white')
.style('font-family', 'Helvetica')
.style("font-size","25px")
.text(d.Place)
var wrap = svg.selectAll("text.spotsName")
.each(function(d, i) { wrap_text(d3.select(this), 80) });
//svg
//.append("text") //appends path to data
//.attr('class','spotsName')
//.attr('x', 790)
//.attr("y", 100)
//.attr('fill', 'white')
//.style('font-family', 'Helvetica')
//.style("font-size","20px")
//.text(d.Type)
//svg
//.append("text") //appends path to data
//.attr('class','spotsName')
//.attr('x', 790)
//.attr("y", 130)
//.attr('fill', 'white')
//.style('font-family', 'Helvetica')
//.style("font-size","20px")
//.text(d.Rating)
////////////////////////////////////////////////////////////////////
if (d.Type=="Hill"){
svg
p.enter().append("polyline")
.data(hillicon) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'white')
.style('fill-opacity','.01')
.style("stroke-width", '2')
.style("stroke", "White")
}
if (d.Type=="Flat"){
svg
p.enter().append("polyline")
.data(flaticon) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'white')
.style('fill-opacity','0')
.style("stroke-width", '2')
.style("stroke", "White")
}
/////////////////////////////////////////////////////////////////////////
if (d.Rating=="1"){
svg
p.enter().append("polyline")
.data(ratingbox1) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'FireBrick')
.style('fill-opacity','1')
.style("stroke-width", '2')
.style("stroke", "none")
}
if (d.Rating=="2"){
svg
p.enter().append("polyline")
.data(ratingbox2) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'DarkOrange')
.style('fill-opacity','1')
.style("stroke-width", '2')
.style("stroke", "none")
}
if (d.Rating=="3"){
svg
p.enter().append("polyline")
.data(ratingbox3) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'Gold')
.style('fill-opacity','1')
.style("stroke-width", '2')
.style("stroke", "none")
}
if (d.Rating=="4"){
svg
p.enter().append("polyline")
.data(ratingbox4) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'LightGreen')
.style('fill-opacity','1')
.style("stroke-width", '2')
.style("stroke", "none")
}
if (d.Rating=="5"){
svg
p.enter().append("polyline")
.data(ratingbox5) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','GroundType')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return d})
.style("fill", 'ForestGreen')
.style('fill-opacity','1')
.style("stroke-width", '2')
.style("stroke", "none")
}
}
function removeText(){
svg.selectAll('text.spotsName').remove()
svg.selectAll('polyline.GroundType').remove()
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// HOUSE ICON : ZONE EVENT
function addZoneIcon(event,d){
svg
p.enter().append("polyline")
.data(houseicon) //get data to define path
.enter() //there are more data than elements, this selects them
.append('polyline')
.attr('class','zone2')
.attr("points", function(d) {return d})
.attr('transform',function(d) {return'translate('+890+','+900+')'})
.style("fill", 'white')
.style('fill-opacity','.01')
.style("stroke-width", '2')
.style("stroke", "White")
}
function removeZoneIcon(){
svg.selectAll('polyline.zone2').remove()
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// STATIONARY TEXT
svg
//t.enter().append("text")
.append("text") //appends path to data
.attr('x', 790)
.attr("y", 50)
.attr('fill', 'white')
.style('font-family', 'Helvetica')
.style("font-size","20px")
.text("LONGBOARDING IN")
svg
//t.enter().append("text")
.append("text") //appends path to data
.attr('x', 840)
.attr("y", 80)
.attr('fill', 'white')
.style('font-family', 'Helvetica')
.style("font-size","20px")
.text("SENECA")
svg
//t.enter().append("text")
.append("text") //appends path to data
.attr('x', 790)
.attr("y", 150)
.attr('fill', 'white')
.style('font-family', 'Helvetica')
.style("font-size","20px")
.text("PLACE:")
svg
//t.enter().append("text")
.append("text") //appends path to data
.attr('x', 790)
.attr("y", 590)
.attr('fill', 'white')
.style('font-family', 'Helvetica')
.style("font-size","20px")
.text("RATING:")
svg
//t.enter().append("text")
.append("text") //appends path to data
.attr('x', 790)
.attr("y", 810)
.attr('fill', 'white')
.style('font-family', 'Helvetica')
.style("font-size","20px")
.text("TYPE:")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// EXTRA
// function addDetail(event,d){
// svg
// .append("text") //appends path to data
// .attr('class','spotsName')
// .attr('x', projection([d.Longitude,d.Latitude])[0]-10)
// .attr("y", projection([d.Longitude,d.Latitude])[1]+10)
// .attr('fill', 'DarkSlateGray')
// .style('font-family', 'Helvetica')
// .style("font-size","25px")
// .text(d.Type)
// }
// function removeDetail(){
// svg.selectAll('text.spotsName').remove()
// }
//static points from qgis
//staticCircles(restrooms.features,'2','black','1',"0")
//staticCircles(skatespots.features,'8','DarkOliveGreen','1',"0")
/*
function staticCircles(data,r,sfill, sOpac, sWidth){
c.enter().append('circle')
.data(data) //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', r)
.attr('fill', sfill)
.style('fill-opacity',sOpac)
.style("stroke-width", sWidth)
}
*/
return svg.node();
}