chart = {
const width = 1200,
height = 960;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bbox1);
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 g = svg.append("g").attr("id", "paths");
g.selectAll("trails")
.data(trails.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path2)
.style("fill", "none")
.style('stroke-opacity','0.6')
.style("stroke-width", '0.4')
.style("stroke", "rgb(0,0,0)")
g.selectAll("boundaries")
.data(boundaries.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(153,255,153)")
.style("fill-opacity", ".05")
.style('stroke-opacity','1')
.style("stroke-width", '.25')
.style("stroke", "rgb(0,0,0)")
g.selectAll("waterBoundaries") //d3 geopath
.data(waterBoundaries.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(102,102,255)")
.style("fill-opacity", ".1")
.style('stroke-opacity','.4')
.style("stroke-width", '0.5')
.style("stroke", "rgb(68,85,200)")
//Title and Text......................................................................................................................................
svg
.append('text')
.attr('x','65')
.attr('y','120')
.attr("font-family", "arial")
.attr('font-size','35')
//.attr('text-anchor','end')
.style("font-weight","bold")
.style("fill","rgb(0,0,0)")
.text("Wyoming's")
svg
.append('text')
.attr('x','65')
.attr('y','160')
.attr("font-family", "arial")
.attr('font-size','35')
//.attr('text-anchor','end')
.style("font-weight","bold")
.style("fill","rgb(0,0,0)")
.text("Natural")
svg
.append('text')
.attr('class','station')
.attr('x','65')
.attr('y','200')
.attr("font-family", "arial")
.attr('font-size','35')
//.attr('text-anchor','end')
.style("font-weight","bold")
.style("fill","rgb(0,0,0)")
.text("Wonders")
svg
.append('line')
.attr('class','sbLn')
.attr('x1',50)
.attr('y1',210)
.attr('x2',250)
.attr('y2',210)
.attr('stroke-width','2')
.attr('stroke-opacity','0.75')
.style('stroke','rgb(0,0,0)')
//Start of park interactive info..................................................................................................................
var p = svg.selectAll("polyline")
.data(treeicon1)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points', function(d){return d})
.attr('transform', 'translate(80,250)')
.style('fill', 'grey')
.style('stroke','black')
.style('stroke-width','0.9')
.style('stroke-fill', '4,4,8,8')
p.enter().append("polyline")
.data(icon_list)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('class','icon2')
.attr('points', function(d){return d.pts})
.attr('transform',function(d){return 'translate('+projection([d.data.Long,d.data.Lat])[0]+','+projection([d.data.Long,d.data.Lat])[1]+')'})
.style('fill', fillcolor)
.style('stroke','black')
.style('stroke-width','0.9')
.style('stroke-fill', '4,4,8,8')
.on('mouseover',parkInfo)//listens for a mousover, and calls function
.on('mouseout', parkInfoOut)
function fillcolor(d,i){
var color = 'rgb(0,255,0)'
if(d.data.Rating==5){color='rgb(0,255,0)'}
if(d.data.Rating==4){color='rgb(102,204,0)'}
if(d.data.Rating==3){color='rgb(153,255,153)'}
if(d.data.Rating==2){color='rgb(204,255,204)'}
if(d.data.Rating==1){color='rgb(255,255,255)'}
return color
}
function parkInfo(event,d){
d3.select(this).style('fill','white')
svg
.append('text')
.attr('class','parkText')
.attr('x','75')
.attr('y','845')
.style("font-family", "Helvetica")
.style('font-size','1em')
.style('font-weight','10')
.style('fill','rgb(0,0,0)')
.style('text-anchor','start')
.text(d.data.Name)
svg
.append('text')
.attr('class','parkText')
.attr('x','75')
.attr('y','860')
.style("font-family", "Helvetica")
.style('font-size','.60em')
.style('fill','rgb(0,0,0)')
.style('text-anchor','start')
.text(d.data.Description)
svg
.append('text')
.attr('class','parkText')
.attr('x','75')
.attr('y','875')
.style("font-family", "Helvetica")
.style('font-size','.60em')
.style('fill','rgb(0,0,0)')
.style('text-anchor','start')
.text(d.data.Rating)
svg
.append('line')
.attr('class','parkLine')
.attr('x1','75')
.attr('y1','880')
.attr('x2','800')
.attr('y2','880')
.style('stroke','black')
.style('stroke-width','1')
var ratingList= []
if(d.data.Rating==1){ratingList = [treeicon1]}
if(d.data.Rating==2){ratingList = [treeicon1,treeicon1]}
if(d.data.Rating==3){ratingList = [treeicon1,treeicon1,treeicon1]}
if(d.data.Rating==4){ratingList = [treeicon1,treeicon1,treeicon1,treeicon1]}
if(d.data.Rating==5){ratingList = [treeicon1,treeicon1,treeicon1,treeicon1,treeicon1]}
p.enter().append("polyline")
.data(ratingList)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('class','icon_rating2')
.attr('points', function(d){return d})
.attr('transform',function(d,i){return 'translate('+(75+(i*25))+',805)'})
.style('fill', 'white')
.style('stroke','black')
.style('stroke-width','0.25')
.style('stroke-fill', '4')
}
function parkInfoOut(event, d){
d3.selectAll('text.parkText').remove()
d3.selectAll('line.parkLine').remove()
d3.selectAll('polyline.icon_rating2').remove()
d3.selectAll('polyline.icon2').style('fill',fillcolor)
}
//mountain data................................................................................................................................
var p = svg.selectAll("polyline")
.data(mountainicon)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points', function(d){return d})
.attr('transform', 'translate(75,300)')
.style('fill', 'grey')
.style('stroke','black')
.style('stroke-width','0.9')
.style('stroke-fill', '4,4,8,8')
p.enter().append("polyline")
.data(icon_list2)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('class','icon1')
.attr('points', function(d){return d.pts})
.attr('transform',function(d){return 'translate('+projection([d.data.Long,d.data.Lat])[0]+','+projection([d.data.Long,d.data.Lat])[1]+')'})
.style('fill', fillcolor1)
.style('stroke','black')
.style('stroke-width','0.9')
.style('stroke-fill', '4,4,8,8')
.on('mouseover',mountainsInfo)//listens for a mousover, and calls function
.on('mouseout', mountainsInfoOut)
function fillcolor1(d,i){
var color = 'rgb(0,255,0)'
if(d.data.Rating==5){color='rgb(0,255,0)'}
if(d.data.Rating==4){color='rgb(102,204,0)'}
if(d.data.Rating==3){color='rgb(153,255,153)'}
if(d.data.Rating==2){color='rgb(204,255,204)'}
if(d.data.Rating==1){color='rgb(235,255,235)'}
return color
}
function mountainsInfo(event,d){
d3.select(this).style('fill','white')
svg
.append('text')
.attr('class','mountainsText')
.attr('x','75')
.attr('y','845')
.style("font-family", "Helvetica")
.style('font-size','1em')
.style('font-weight','10')
.style('fill','rgb(0,0,0)')
.style('text-anchor','start')
.text(d.data.Name)
svg
.append('text')
.attr('class','mountainsText')
.attr('x','75')
.attr('y','860')
.style("font-family", "Helvetica")
.style('font-size','.60em')
.style('fill','rgb(0,0,0)')
.style('text-anchor','start')
.text(d.data.Description)
svg
.append('text')
.attr('class','mountainsText')
.attr('x','75')
.attr('y','875')
.style("font-family", "Helvetica")
.style('font-size','.60em')
.style('fill','rgb(0,0,0)')
.style('text-anchor','start')
.text(d.data.Rating)
svg
.append('line')
.attr('class','mountainsLine')
.attr('x1','75')
.attr('y1','880')
.attr('x2','800')
.attr('y2','880')
.style('stroke','black')
.style('stroke-width','1')
var ratingList= []
if(d.data.Rating==1){ratingList = [mountainicon]}
if(d.data.Rating==2){ratingList = [mountainicon,mountainicon]}
if(d.data.Rating==3){ratingList = [mountainicon,mountainicon,mountainicon]}
if(d.data.Rating==4){ratingList = [mountainicon,mountainicon,mountainicon,mountainicon]}
if(d.data.Rating==5){ratingList = [mountainicon,mountainicon,mountainicon,mountainicon,mountainicon]}
p.enter().append("polyline")
.data(ratingList)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('class','icon_rating1')
.attr('points', function(d){return d})
.attr('transform',function(d,i){return 'translate('+(90+(i*50))+',805)'})
.style('fill', 'white')
.style('stroke','black')
.style('stroke-width','0.25')
.style('stroke-fill', '4')
}
function mountainsInfoOut(event, d){
d3.selectAll('text.mountainsText').remove()
d3.selectAll('line.mountainsLine').remove()
d3.selectAll('polyline.icon_rating1').remove()
d3.selectAll('polyline.icon1').style('fill',fillcolor1)
}
return svg.node();
}