chart = {
const width=800, height=800;
const svg = d3.select(DOM.svg(width, height))
var projection = d3.geoMercator()
.fitExtent([[10, 10], [width, height]], bayAreaMap);
var path = d3.geoPath()
.projection(projection);
svg.append('g').selectAll('path')
.data(bayAreaMap.features)
.enter().append('path')
.attr('d', path)
.style('fill', 'white')
.style('stroke', '#ccc')
svg.selectAll('circle')
.data(dataset)
.join('circle')
.attr('cx', d => {
console.log(d)
return projection([d.latitude, d.longitude])[0]
})
.attr('cy', d => projection([d.latitude, d.longitude])[1])
.attr('fill', "purple")
.attr('r', 3);
svg.selectAll("circle")
.on("mouseover", function (event, d) {
let x = projection([d.longitude, d.latitude])[0];
let y = projection([d.longitude, d.latitude])[1];
svg.select("#tooltip-text")
.text(d.name);
let positionOffest = 8;
svg.select("#tooltip")
.attr("transform", `translate(${x + positionOffest}, ${y + positionOffest})`)
.style("display", "block");
d3.select(this)
.attr("stroke", "#333333")
.attr("stroke-width", 2);
})
.on("mouseout", function (event, d) {
svg.select("#tooltip").style("display", "none");
d3.select(this)
.attr("stroke", "purple")
.attr("stroke-width", 1);
});
const tooltipGroup = svg.append("g")
.attr("id", "tooltip")
.style("display", "none")
.append("text")
.attr("id", "tooltip-text")
.attr("x", 5)
.attr("y", 15)
.attr("font-size", "14px")
.attr("font-weight", "bold")
.attr("fill", "black");
svg.append("circle")
.attr("id", "circleOne")
.attr("cx", d => projection([-122.3642615, 37.5863038])[0])
.attr("cy", d => projection([-122.3642615, 37.5863038])[1])
.attr("r", 100)
.attr("fill-opacity", 0.25)
.attr("fill", "steelblue")
.attr("stroke", "steelblue")
svg.append("circle")
.attr("id", "circleTwo")
.attr("cx", d => projection([-122.3642615, 37.5863038])[0] + 100)
.attr("cy", d => projection([-122.3642615, 37.5863038])[1] + 100)
.attr("r", 100)
.attr("fill-opacity", 0.25)
.attr("fill", "steelblue")
.attr("stroke", "steelblue")
return svg.node()
}