{
const width = 600
const height = 400
const margin = {top: 20, bottom: 20, left: 50, right: 50}
const svg = d3
.create("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.style("border", "1px dotted #000")
const g = svg
.append("g")
.attr("transform", `translate(${margin.left}, ${margin.top})`)
const x = d3
.scaleLinear()
.domain(d3.extent(iris, d => d["sepalLength"]))
.range([0, width])
const y = d3
.scaleLinear()
.domain(d3.extent(iris, d => d["sepalWidth"]))
.range([height, 0])
const colorScale = d3
.scaleOrdinal()
.domain(Array.from(new Set(iris.map(d => d.species))))
.range(["red", "orange", "yellow"])
g.append("g")
.selectAll("circle")
.data(iris)
.join("circle")
.attr("r", 3)
.attr("cx", d => x(d.sepalLength))
.attr("cy", d => y(d.sepalWidth))
.style("fill", d => colorScale(d.species))
return svg.node()
}