scatterplot = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const exerciseColorMap = new Map([["Bike", "#8242a8"], ["Run", "#ff1493"], ["Walk", "#FFCE1E"]]);
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
svg.append("g")
.call(grid);
svg.append("g")
.attr("stroke-width", "3")
.attr("fill", "#ffffff")
.selectAll("circle")
.data(data.filter(d => d.y > 1))
.join("circle")
.attr("stroke", d => exerciseColorMap.get(d['typeOfExercise']))
.attr("cx", d => x(d.x))
.attr("cy", d => y(d.y))
.attr("r", 3);
svg.append("g")
.attr("font-family", "'Work Sans', sans-serif")
.attr("font-size", 10)
.selectAll("text")
.data(data.filter(d => d.y > 1))
.join("text")
.attr("dy", "0.35em")
.attr("x", d => x(d.x) + 7)
.attr("y", d => y(d.y))
.text(d => d.name);
const scale = d3.scaleOrdinal()
.domain(["Bike", "Run", "Walk"])
.range(["#8242a8", "#ff1493", "#FFCE1E"]);
const legend = d3Legend
.legendColor()
.shape("path", d3.symbol().type(d3.symbolCircle).size(25)())
.shapePadding(15)
.labelOffset(5)
.scale(scale)
.labels(["Bike", "Run", "Walk"]);
svg.append("g")
.attr("class", "legend_auto")
.style('font-size', 12)
.style('font-family', 'sans-serif')
.attr("transform", `translate(${width - margin.right + 5}, ${margin.top})`)
.call(legend)
return svg.node();
}