{
const svg = d3.create("svg").attr("width", width).attr("height", height);
const container = svg
.append("g")
.attr("transform", `translate(${width / 2}, ${height / 2})`);
const radiusAxis = container
.selectAll("radius-axis")
.data(radius.reverse())
.enter()
.append("circle")
.attr("cx", 0)
.attr("cy", 0)
.attr("r", (d) => radiusScale(d))
.attr("fill", "rgba(10,10,10,0.01)")
.attr("stroke", "#c3c3c3")
.attr("stroke-width", 0.5);
const angleAxis = container
.selectAll("angle-axis")
.data(attributes)
.enter()
.append("line")
.attr("x1", 0)
.attr("y1", 0)
.attr(
"x2",
(d, i) => radiusScale(100) * Math.cos(angleScale(i) - Math.PI / 2)
)
.attr(
"y2",
(d, i) => radiusScale(100) * Math.sin(angleScale(i) - Math.PI / 2)
)
.attr("stroke", "#ccc")
.attr("stroke-width", 0.5);
const axisLabels = container
.selectAll("axis-labels")
.data(radius)
.enter()
.append("text")
.attr("x", (d, i) => radiusScale(d))
.attr("y", 0 + 4)
.text((d) => d)
.attr("class", "axis-labels");
const path = container
.append("path")
.datum(attributes)
.attr("d", radarLine)
.attr("fill", "none")
.attr("stroke", pointColor)
.attr("stroke-width", 1.32)
.attr("fill", pointColor)
.style("fill-opacity", 0.1);
const points = container
.selectAll("points")
.data(attributes)
.enter()
.append("circle")
.attr(
"cx",
(d, i) => radiusScale(player[d]) * Math.cos(angleScale(i) - Math.PI / 2)
)
.attr(
"cy",
(d, i) => radiusScale(player[d]) * Math.sin(angleScale(i) - Math.PI / 2)
)
.attr("r", 4.3)
.attr("fill", pointColor)
.attr("stroke", "#fff")
.attr("stroke-width", 2.6);
const labels = container
.selectAll("labels")
.data(attributes)
.enter()
.append("text")
.attr(
"x",
(d, i) => radiusScale(116) * Math.cos(angleScale(i) - Math.PI / 2)
)
.attr(
"y",
(d, i) => radiusScale(116) * Math.sin(angleScale(i) - Math.PI / 2) + 10
)
.text((d) => d)
.attr("class", "labels");
const name = container
.append("text")
.attr("x", 0)
.attr("y", -radiusScale(135))
.text(player.long_name)
.attr("class", "name");
return svg.node();
}