I'm trying to update my force directed graph, but only the nodes are updating (not the links). I'm basically trying to update the color of the links using a css class, but it doesn't get set. The update function is called whenever something gets updated.
My code is kind of complex, so I just pasted the gist of it:
let update = () => {
// [...]
// Update nodes and their css classes works perfectly
// But updating link css class is not updating at all
link = link
.data(links)
.join(enter => {
return enter
.append("path")
.attr("class", d => {
return "someclass"; // <-- This is not constant!
});
},
update => {
return update
}
);
this._simulation.nodes(nodes);
this._simulation.force("link").links(links);
this._simulation.alpha(1).restart();
};
Take particular note of the return "someclass";
line. The returned string may change, but the class does not get applied.
Is there some obvious reason for this not working?
Using the following versions:
d3: 6.7.0, d3-force: 2.1.1