showMap = (input) => {
const xextent = d3.extent(input.points, (d) => d[0]);
const yextent = d3.extent(input.points, (d) => d[1]);
const xyratio = (xextent[1] - xextent[0]) / (yextent[1] - yextent[0]);
const margin = { top: 20, right: 30, bottom: 30, left: 40 };
const w = d3.min([input.height || 900, width]);
const h = w / xyratio;
const r = input.r || 3;
const color = d3.scaleOrdinal().range(d3.schemeCategory10);
const x = d3
.scaleUtc()
.domain(xextent)
.range([margin.left, w - margin.right]);
const y = d3
.scaleLinear()
.domain(yextent)
.range([h - margin.bottom, margin.top]);
const svg = d3.create("svg").attr("width", w).attr("height", h);
svg
.selectAll("circle")
.data(input.points)
.join("circle")
.attr("cx", (d) => x(d[0]))
.attr("cy", (d) => y(d[1]))
.attr("r", r)
.attr("fill", "steelblue");
if (input.xgrid) {
svg
.selectAll("line.gridx")
.data(input.xgrid)
.join("line")
.attr("class", "gridx")
.attr("x1", (d) => x(d))
.attr("y1", margin.top)
.attr("x2", (d) => x(d))
.attr("y2", h - margin.bottom)
.attr("stroke", "black")
.attr("stroke-width", 0.2);
}
if (input.ygrid) {
svg
.selectAll("line.gridy")
.data(input.ygrid)
.join("line")
.attr("class", "gridy")
.attr("x1", margin.left)
.attr("y1", (d) => y(d))
.attr("x2", w - margin.right)
.attr("y2", (d) => y(d))
.attr("stroke", "black")
.attr("stroke-width", 0.2);
}
if (input.points2) {
svg
.selectAll("circlec")
.data(input.points2)
.join("circle")
.attr("class", "c")
.attr("cx", (d) => x(d[0]))
.attr("cy", (d) => y(d[1]))
.attr("r", 1)
.attr("fill", "#ffaaaa");
}
return svg.node();
}