chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [50, 50, width-100, height-100]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bb_test);
svg
.append('rect')
.attr('fill', "rgb(150,150,150)")
.attr('stroke',"rgb(0,0,0)")
.attr('stroke-width',"3px")
.attr('x', 0)
.attr('y', 0)
.attr('width', 1000)
.attr('height', 1000)
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("path1")
.data(boundary.features)
.enter()
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path1) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '.5')
.style("stroke", "rgb(100,100,100)")
g.selectAll("path2") //d3 geopath
.data(sub_test.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','.6')
.style("stroke-width", '.75')
.style("stroke", "rgb(0,0,0)")
g.selectAll("path4") //d3 geopath
.data(class_parks.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(220,0,0)")
.style("fill-opacity", ".2")
.style('stroke-opacity','.4')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
var c = svg.selectAll("circle") //d3 geopath
.data(class_subs.features)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',2)
.attr('fill','black')
.style('fill-opacity','1')
svg
.append('rect')
.attr('fill', "rgb(100,0,0)")
.attr('stroke',"rgb(0,0,0)")
.attr('stroke-width',"3px")
.attr('x', 67)
.attr('y', 62)
.attr('width', 220)
.attr('height', 120)
c.enter().append('circle') //d3 geopath
.data(pizza)
.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',4)
.attr('fill','rgb(255,211,0)')
.style('fill-opacity','1')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
.on('mouseover',pizzaMouse)
.on('mouseout',pizzaMouseOut)//use 'mouseleave' for polygons
function pizzaMouse(event,d){
d3.select(this).style("stroke-width", '3.5')
//create a line from pizza shop location, to the review
svg
.append('line')
.attr('x1','67')
.attr('y1',projection([d.long,d.lat])[1])
.attr('x2','67')
.attr('y2','182')
.attr('class','pizzaLine')
.attr('stroke','rgb(0,0,0)')
.attr('stroke-width','2')
svg
.append('line')
.attr('x1','67')
.attr('y1',projection([d.long,d.lat])[1])
.attr('x2',projection([d.long,d.lat])[0])
.attr('y2',projection([d.long,d.lat])[1])
.attr('class','pizzaLine')
.attr('stroke','rgb(0,0,0)')
.attr('stroke-width','2')
svg
.append('text')
.attr('x','75')
.attr('y','130')
.attr('class','review')
.attr("font-family", "Helvetica")
.attr('font-size','.6em')
//.style("font-weight","bold")
//.style("font-style","italic")
.style("fill",'rgb(255,211,0)')
.text(d.description)
var wrap = svg.selectAll('text.review')
.each(function(d, i) { wrap_text(d3.select(this), 180) });
}
function pizzaMouseOut(event,d){
d3.select(this).style("stroke-width", '.5')
d3.selectAll('text.review').remove()
d3.selectAll('line.pizzaLine').remove()
}
var t = svg.selectAll("text") //d3 geopath
.data(class_subs.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]+8})
.attr('font-family','helvetica')
.style('font-size','.3em')
.attr('text-anchor','middle')
.style("font-weight","bold")
.style("fill","rgb(0,0,0)")
.text(function(d) {return d.properties.name})
t.enter().append("text") //everytime after the first use of the variable
.data(pizza)
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr("x", '600')
.attr("y", function(d, i) {return 100+(i*25);})
.attr('font-family','helvetica')
.style('font-size','.5em')
//.attr('text-anchor','middle')
.style("font-weight","bold")
.style("fill","rgb(0,0,0)")
.text(function(d) {return d.name})
svg
.append('text')
.attr('x','75')
.attr('y','85')
.attr("font-family", "Helvetica")
.attr('font-size','1.25em')
.style("font-weight","bold")
//.style("font-style","italic")
.style("fill",'rgb(255,211,0)')
.text('FiDi Pizza Hot Spots')
return svg.node();
}