{
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", "#eee");
const x = d3
.scaleLinear()
.domain([0, d3.max(data, (d) => d.firstNameLength)])
.range([0, iwidth])
.nice();
const y = d3
.scaleLinear()
.domain([0, d3.max(data, (d) => d.lastNameLength)])
.range([iheight, 0])
.nice();
const color = d3.scaleOrdinal(d3.schemePastel2);
gDrawing
.selectAll("text")
.data(data)
.join("text")
.attr("x", (d) => x(d.firstNameLength))
.attr("y", (d) => y(d.lastNameLength) + 15)
.attr("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("fill", "black")
.text((d) => d.firstName);
const circles = gDrawing
.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", (d) => x(d.firstNameLength))
.attr("cy", (d) => y(d.lastNameLength))
.attr("r", 5)
.attr("fill", (d) => color(d.profession));
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));
return target;
}