{
const height = 400;
const width = 800;
const target = html`<svg id="target" viewBox="0 0 ${width} ${height}">
</svg>`;
const margin = { left: 50, right: 20, top: 20, bottom: 50 },
iwidth = width - margin.left - margin.right,
iheight = height - margin.top - margin.bottom;
const svg = d3.select(target);
const gDrawing = svg
.append("g")
.attr("transform", `translate(${margin.left}, ${margin.top})`);
gDrawing
.append("rect")
.attr("width", iwidth)
.attr("height", iheight)
.attr("fill", "#fff");
const x = d3
.scaleLinear()
.domain([minAge - 2, maxAge])
.range([0, iwidth])
.nice();
const y = d3
.scaleLinear()
.domain([0, d3.max(counted_avg, (d) => d.count)])
.range([iheight, 0])
.nice();
const color = d3.scaleOrdinal(d3.schemeBlues);
const c = d3
.scaleSequential(d3.interpolatePlasma)
.domain(d3.extent(counted_avg, (d) => d.log_count));
gDrawing
.append("g")
.attr("class", "x--axis")
.attr("transform", `translate(0, ${iheight})`)
.call(d3.axisBottom(x));
gDrawing.append("g").attr("class", "y--axis").call(d3.axisLeft(y));
const circles = gDrawing
.selectAll("circle")
.data(counted_avg)
.join("circle")
.attr("cx", (d) => x(d.avgAge))
.attr("cy", (d) => y(d.count))
.attr("r", (d) => d.log_count * 1.7)
.attr("opacity", (d) => (10 - d.log_count) / 7)
.style("stroke", "gray")
.attr("fill", (d) => c(d.log_count));
return target;
}