hi = {
const chartWidth = width;
const chartHeight = 800;
const backgroundColor = "#ADD8E6";
const landColor = "#09A573";
const landStroke = "#FCF5E9";
const markerColor = "#E26F99";
const projection = d3.geoMercator()
.scale([17000])
.center(markers[0].geometry.coordinates)
.translate([chartWidth / 2, chartHeight / 2]);
const pathGenerator = d3.geoPath(projection);
const svg = d3.create('svg')
.attr("title", "Map")
.attr('width', chartWidth)
.attr('height', chartHeight)
.attr("stroke-width", 0);
svg.append("rect")
.attr("width", chartWidth)
.attr("height", chartHeight)
.attr('fill', backgroundColor);
svg.selectAll('path')
.attr("class","unique")
.data(bayArea.features)
.join('path')
.attr('d', pathGenerator)
.attr('fill', landColor)
.attr('stroke', landStroke)
.attr('stroke-width', 1);
// svg.selectAll("circle")
// .attr("id", "restaurantMarker")
// .data(filtered)
// .join("circle")
// .attr("cx", d => projection(d.coordinates)[0])
// .attr("cy", d => projection(d.coordinates)[1])
// .attr("r", 4)
// .attr("fill-opacity", 0.5)
// .attr("fill", "#FFFF00")
// .attr("stroke", markerColor)
// .on("mouseover", function (event, d) { // <-- need to use the regular function definition to have access to "this"
const circles = d3.range(2).map(i => ({
// x: Math.random() * (width - 32 * 2) + 32,
// y: Math.random() * (chartHeight - 32 * 2) + 32,
x: 100,
y: [100,300],
r: [size1,size2]
}));
console.log("in cell",circlesData)
svg.selectAll("circle")
.data(circlesData)
.attr("id","circle1")
.join("circle")
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("r", (d,i) => d.r[i])
.attr('fill-opacity', 0.5)
.attr("fill", (d, i) => d3.schemeCategory10[i % 10])
.call(drag)
.call(contains);
// .call(d3.drag().on("drag", function(d){
// console.log("saywer",d)
// }));
// svg.select("#tooltip-text1")
// .text("Price " + d.name);
// svg.select("#tooltip-text")
// .append("rect").attr('x', 0)
// .attr('y', 0)
// .attr('width', 200)
// .attr('height', 40)
// .attr('stroke', 'black')
// .attr('fill', '#69a3b2');
// svg.select("#tooltip-text1")
// .text("Price " + d.name);
// svg.selectAll("path").enter().append()
// .attr("id", "restaurantMarker")
// .data(filtered)
// .join('path')
// .attr("cx", d => projection(d.coordinates)[0])
// .attr("cy", d => projection(d.coordinates)[1])
// .attr('d', symbolGenerator.type(d3['symbolStar']))
svg.selectAll("circle").enter()
.attr("id", "restaurantMarker")
.data(overlapData)
.join("circle")
.attr("cx", d => projection(d.coordinates)[0])
.attr("cy", d => projection(d.coordinates)[1])
.attr("r", 4)
.attr("fill-opacity", 0.5)
.attr("fill", d => d.selected == 0 ? "#cccccc":"#E26F99")
.attr("stroke", markerColor)
.attr('stroke-width', 1)
.on("mouseover", function (event, d) {
svg.select("#tooltip-text")
.append("text").text(d.name + " (" + d.price + ")");
let positionOffest = 8;
svg.select("#tooltip")
// move the tooltip to where the cursor is
.attr("transform", `translate(${projection(d.coordinates)[0] + positionOffest}, ${projection(d.coordinates)[1] + positionOffest})`)
.style("display", "block"); // make tooltip visible
d3.select(this)
.attr("stroke", "#333333")
.attr("stroke-width", 2);
const path = tooltip.append("path")
.attr("fill", "white")
.attr("stroke", "black");
})
.on("mouseout", function (event, d) {
svg.select("#tooltip").style("display", "none"); // hide tooltip
svg.select("#tooltip-text").text(" ");
d3.select(this).attr("stroke", "none"); // undo the stroke
});
var path = d3.path();
svg.append("path")
.attr("fill", "none")
.attr("stroke", "#FFF")
.attr("d",path)
const tooltip = svg.append("g") // the tooltip needs to be added last so that it stays on top of all circles
.attr("id", "tooltip")
.style("display", "none") // hidden by default
.append("g")
.attr("id", "tooltip-text")
.attr("x", 5)
.attr("y", 15)
.attr("font-size", "14px")
.attr("font-weight", "bold")
.attr("fill", "black")
// tooltipGroup.append("text")
// .attr("id", "tooltip-text1")
// .attr("x", 5)
// .attr("y", 30)
// .attr("font-size", "14px")
// .attr("font-weight", "bold")
// .attr("fill", "black")
tooltip.append("text")
.attr("id", "tooltip-text1")
.attr("x", 5)
.attr("y", 30)
.attr("font-size", "14px")
.attr("font-weight", "bold")
.attr("fill", "black")
return svg.node()
}