mirror of
https://github.com/MISP/misp-galaxy.git
synced 2024-11-30 02:37:17 +00:00
Fix [simulation] update graph
This commit is contained in:
parent
5899d5d5c8
commit
a921d1b192
1 changed files with 25 additions and 2 deletions
|
@ -158,14 +158,37 @@ document$.subscribe(function () {
|
||||||
node = node.data(nodes, d => d.id)
|
node = node.data(nodes, d => d.id)
|
||||||
.join(
|
.join(
|
||||||
enter => enter.append("circle")
|
enter => enter.append("circle")
|
||||||
.attr("r", NODE_RADIUS)
|
.attr("r", function (d, i) {
|
||||||
.attr("fill", NODE_COLOR),
|
return i === 0 ? NODE_RADIUS + 5 : NODE_RADIUS;
|
||||||
|
})
|
||||||
|
.attr("fill", function (d, i) {
|
||||||
|
return i === 0 ? Parent_Node_COLOR : NODE_COLOR;
|
||||||
|
}),
|
||||||
update => update,
|
update => update,
|
||||||
exit => exit.remove()
|
exit => exit.remove()
|
||||||
);
|
);
|
||||||
|
|
||||||
node.call(drag);
|
node.call(drag);
|
||||||
|
|
||||||
|
// Apply tooltip on nodes
|
||||||
|
node.on("mouseover", function (event, d) {
|
||||||
|
tooltip.transition()
|
||||||
|
.duration(200)
|
||||||
|
.style("opacity", .9);
|
||||||
|
tooltip.html(d.id)
|
||||||
|
.style("left", (event.pageX) + "px")
|
||||||
|
.style("top", (event.pageY - 28) + "px");
|
||||||
|
})
|
||||||
|
.on("mousemove", function (event) {
|
||||||
|
tooltip.style("left", (event.pageX) + "px")
|
||||||
|
.style("top", (event.pageY - 28) + "px");
|
||||||
|
})
|
||||||
|
.on("mouseout", function (d) {
|
||||||
|
tooltip.transition()
|
||||||
|
.duration(500)
|
||||||
|
.style("opacity", 0);
|
||||||
|
});
|
||||||
|
|
||||||
// Process new links
|
// Process new links
|
||||||
const oldLinksMap = new Map(link.data().map(d => [`${d.source.id},${d.target.id}`, d]));
|
const oldLinksMap = new Map(link.data().map(d => [`${d.source.id},${d.target.id}`, d]));
|
||||||
links = newLinks.map(d => Object.assign(oldLinksMap.get(`${d.source.id},${d.target.id}`) || {}, d));
|
links = newLinks.map(d => Object.assign(oldLinksMap.get(`${d.source.id},${d.target.id}`) || {}, d));
|
||||||
|
|
Loading…
Reference in a new issue