0

In d3 I was able to specify the fill style of an element using a function. For example

color = d3.scale.category10().domain(d3.range(0,10));
...
.style( "fill", function(d) { return color(d); } ) 

Is there a way to do the same thing in dagre-d3?

I have tried

g.setNode( 0, { style: "fill: green; stroke: yellow" } ) (**works fine**)

g.setNode( 0, { style: "fill: function() { return color(2); }" } ) (**Does NOT work**)

g.setNode( 0, { style: "fill: color(2)" } ) (**Does NOT work**)
gaitat
  • 12,449
  • 4
  • 52
  • 76

1 Answers1

1

Just concat the result. Calling a function in a string has no effect here at all.

g.setNode(0, { style: "fill: " + color(2) }); // **I suppose it works**
Amit Joki
  • 58,320
  • 7
  • 77
  • 95