class ShotTypeLegend extends GeneralChart {
constructor(data, selector, config) {
super(data, selector, config);
this.setAxes();
}
setAxes() {
this.sx = d3
.scaleBand()
.domain(d3.map(this.data, (d) => d.type))
.range([this.margin.left, this.width - this.margin.right]);
this.sy = d3
.scaleLinear()
.domain([0, 1])
.range([this.height - this.margin.bottom, this.margin.top]);
}
draw() {
this.svg.call(this.paintBackground.bind(this), "#fff1ff");
this.svg
.append("g")
.selectAll("circle")
.data(this.data)
.join("circle")
.attr("cx", (d) => this.sx(d.type) + 10)
.attr("cy", this.sy(0.5))
.attr("r", 5)
.attr("stroke", (d) => d.color)
.attr("fill", "none")
.attr("stroke-width", 2)
.attr("stroke-dasharray", (d) => (d.type === "Goal" ? "" : "3 3"));
this.svg
.append("g")
.selectAll("text")
.data(this.data)
.join("text")
.attr("x", (d) => this.sx(d.type))
.attr("dx", 20)
.attr("y", this.sy(0.5))
.attr("dy", 5)
.attr("font-size", 14)
.text((d) => d.type);
}
}