badgeKit = () => {
function badgeKit(selection) {
let g = selection
.selectAll("g")
.data((d) => d)
.join("g")
.attr("class", "badgecomp")
.each(function (d, i) {
const ig = d3.select(this);
if (d.type === "circle") {
ig.append("circle")
.attr("cx", 0)
.attr("cy", 0)
.attr("r", d.radius)
.attr("stroke", d.stroke ? d.stroke : "black")
.attr("stroke-width", d.strokeWidth ? d.strokeWidth : 1)
.attr("fill", d.fill ? d.fill : "none");
} else if (d.type === "ring") {
let c = d3.curveLinearClosed;
if (d.curve === "linear") c = d3.curveLinearClosed;
if (d.curve === "basis") c = d3.curveBasisClosed;
if (d.curve === "catmull") c = d3.curveCatmullRomClosed;
if (d.curve === "natural") c = d3.curveNatural;
const shape = d3
.radialLine()
.curve(c);
let el = d3
.range(0, d.no)
.map((de) => [
(de * Math.PI * 2) / d.no,
de % 2 === 0 ? d.inner : d.outer
]);
console.log("EL", el);
const path = shape(el);
ig.append("path")
.attr("d", path)
.attr("stroke", d.stroke ? d.stroke : "none")
.attr("stroke-width", d.strokeWidth ? d.strokeWidth : 1)
.attr("fill", d.fill ? d.fill : "none");
}
});
}
return badgeKit;
}