chart = {
const width = 700,
height = 700;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], site_bounding2);
var path1 = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path2")
.data(streets.features)
.enter()
.append("path")
.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", '.75')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path3") //d3 geopath
.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", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(200,200,200)")
.style("fill-opacity", ".5")
.style('stroke-opacity','.4')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
var c = svg.selectAll("circle") //d3 geopath
.data(places)
.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',placesRadius)
.attr('fill',colorType)
.style('fill-opacity','1')
.on('mouseover',placesText)
.on('mouseout',removeText)
function colorType(d,i) {
var color = 'cyan'
if(d.Type=='food'){color='rgb(255,255,'+y+')'}
if(d.Type=='grocery'){color='rgb(64,57,47)'}
return color
}
if(totalValues[0]>400)
svg.append('text')
.attr('class','spots')
.attr('x','480')
.attr('y','400')
.attr('font-family','Helvetica')
.attr('font-size','3.5em')
.attr('text-anchor','middle')
.attr('font-weight','bold')
.text('A LITTLE CRAZY THERE')
if(totalValues[0]>150 && totalValues[1]>100)
svg.append('text')
.attr('class','spots')
.attr('x','480')
.attr('y','450')
.attr('font-family','Helvetica')
.attr('font-size','3.5em')
.attr('text-anchor','middle')
.attr('font-weight','bold')
.text('GOOD BALANCE')
svg.append("text")
//.attr('class','placesInfo')
.attr('x','570')
.attr('y','215')
.attr('font-family','Helvetica')
.attr('font-size','.6em')
.attr('font-weight','lighter')
.attr('font-anchor','start')
//.text(totalValues[0])
svg.append("text")
//.attr('class','placesInfo')
.attr('x','520')
.attr('y','215')
.attr('font-family','Helvetica')
.attr('font-size','.6em')
.attr('font-weight','normal')
.attr('font-anchor','start')
//.text('Ambiance:')
svg.append("text")
//.attr('class','placesInfo')
.attr('x','570')
.attr('y','200')
.attr('font-family','Helvetica')
.attr('font-size','.6em')
.attr('font-weight','lighter')
.attr('font-anchor','start')
//.text(totalValues[1])
svg.append("text")
//.attr('class','placesInfo')
.attr('x','520')
.attr('y','200')
.attr('font-family','Helvetica')
.attr('font-size','.6em')
.attr('font-weight','normal')
.attr('font-anchor','start')
//.text('Happiness')
function placesText(i,d){
svg.append("text")
.attr('class','placesInfo')
.attr('x','500')
.attr('y','240')
.attr('font-family','Helvetica')
.attr('font-size','.6em')
.attr('font-weight','normal')
.attr('font-anchor','start')
.text(d.Name)
svg.append("text")
.attr('class','placesInfo')
.attr('x','500')
.attr('y','250')
.attr('font-family','Helvetica')
.attr('font-size','.6em')
.attr('font-weight','lighter')
.attr('font-anchor','start')
.text(d.Description)
svg.append('line')
.attr('class','placesLine')
.attr('x1','600')
.attr('y1','265')
.attr('x2','600')
.attr('y2',projection([d.Longitude,d.Latitude])[1])
.attr('stroke-width','.5')
.attr('stroke','black')
.attr('stroke-dasharray','3 3')
svg.append('line')
.attr('class','placesLine')
.attr('x1',projection([d.Longitude,d.Latitude])[0])
.attr('y1',projection([d.Longitude,d.Latitude])[1])
.attr('x2','600')
.attr('y2',projection([d.Longitude,d.Latitude])[1])
.attr('stroke-width','.5')
.attr('stroke','black')
.attr('stroke-dasharray','3 3')
}
function removeText(i,d){
d3.selectAll('text.placesInfo').remove()
d3.selectAll('line.placesLine').remove()
}
return svg.node();
}