chart = {
const svg = d3.select(DOM.svg(width, height));
var radialGradient = svg
.append("defs")
.append("radialGradient")
.attr("id", "radial-gradient");
var blur = svg
.append("defs")
.append("filter")
.attr("id", "blur")
.append("feGaussianBlur")
.attr("stdDeviation", 2);
let sharpen = svg
.append("defs")
.append("filter")
.attr("id", "sharpen")
.append("feColorMatrix")
.attr("in", "blur")
.attr("mode", "matrix")
.attr("values", "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9");
radialGradient
.append("stop")
.attr("offset", "0%")
.attr("stop-color", "#DBD2E0");
radialGradient
.append("stop")
.attr("offset", "75%")
.attr("stop-color", "rgb(254,134,74)");
radialGradient
.append("stop")
.attr("offset", "100%")
.attr("stop-color", "#e91e03");
var groups = _(nodes)
.map('cluster')
.uniq()
.sort()
.value();
_.each(nodes, (n, i) => {
n.group = nodes[i].cluster;
});
const nodeGroups = _.groupBy(nodes, 'group');
console.log(nodeGroups);
const hulls = svg
.append("g")
.selectAll('path')
.data(groups)
.enter()
.append('path')
.style('stroke', "rgba(0,0,0,0.5)")
.style('fill', d => background(d))
.style('stroke-width', 3)
.style('stroke-opacity', 1)
.style('fill-opacity', 1)
.attr('stroke-linejoin', 'round');
const node = svg
.append("g")
.selectAll("circle")
.data(nodes)
.join("circle")
.attr("cx", width / 2)
.attr("cy", height / 2)
.attr("r", 2)
.attr("fill", d => color(d.affiliation))
.attr("fill-opacity", 1);
simulation.on("tick", () => {
node.attr("cx", d => d.x).attr("cy", d => d.y);
hulls.attr('d', g => {
let hullPoints = nodeGroups[g].map(n => {
return [n.x, n.y];
});
const hullData = d3.polygonHull(hullPoints);
if (hullData === null) {
return;
}
hullData.push(hullData[0]);
return d3.line()(hullData);
});
});
invalidation.then(() => simulation.stop());
return svg.node();
}