dashboardgen = function(groupedData, goals) {
const f = d3.format(".0f");
const arcs = d3
.pie().sort(null)
.padAngle(0.01)
.value(d => d[1])(groupedData)
const arcs2 = d3
.pie().sort(null)
.padAngle(0.01)
.value(d => d[1])(goals)
const svg = d3
.create("svg")
.attr("width", 350)
.attr("height", 600)
.attr("style", "background-color: #EDF5FF")
const g = svg.append("g").attr("transform", "translate(175, 300)");
g
.selectAll(".arc")
.data(arcs)
.join("path")
.attr("class", "arc")
.attr("fill", d => color2(d.data[0]))
.attr("d", a => arc(a));
g
.selectAll(".arc2")
.data(arcs2)
.join("path")
.attr("class", "arc2")
.attr("fill", d => color2(d.data[0]))
.attr("d", a => arc2(a));
g
.selectAll(".label")
.data(arcs)
.join("text")
.attr("class", "label")
.attr("fill", "#333")
.attr("transform", a => `translate(${arc.centroid(a)})`)
.style("font-size", "10pt")
.style("text-anchor", "middle")
.style("font-family", "sans-serif")
.call(text =>
text
.append("tspan")
.style("font-weight", "bold")
.attr("x", 0)
.text(a => a.data[1] > 0 ? a.data[0] : "")
)
.call(text =>
text
.append("tspan")
.attr("x", 0)
.attr("y", "1em")
.text(a => a.data[0] == "" || a.data[1] < 1 ? "" : f(a.data[1]) + '%')
);
g
.selectAll(".label2")
.data(arcs2)
.join("text")
.attr("class", "label2")
.attr("fill", "#333")
.attr("transform", a => `translate(${arc2.centroid(a)})`)
.style("font-size", "10pt")
.style("text-anchor", "middle")
.style("font-family", "sans-serif")
.call(text =>
text
.append("tspan")
.attr("x", 0)
.text(a => a.data[0] == "" ? "" : a.data[2])
)
.call(text =>
text
.append("tspan")
.attr("x", 0)
.attr("y", "1em")
.text(a => a.data[0])
);
return svg.node();
}