I have a D3 selection:
let container = d3.select("div#container")
I want to append an object to it's styling - this object is dynamic that is why I cannot just hardcode it.
Example object:
let obj = {'style':'background-color:red;'}
Eample changes to object
if(x > 1) {
obj = {'style':'background-color:green;'}
} else if (x < 0) {
obj = {'style':'background-color:yellow;'}
}
I want to do something similar to
container.attr(obj); // Unsure if it should be attr or not
However, I am unsure how to obtain this. Any suggestions?