score:1

Accepted answer

You should define second parameter in fill function:

.style("fill", function(d,i) {

and then

if (i == 1) {
      str = 'gray';

    } ...

or compare d with text value:

if (d == 'Positive') {
      str = 'green';

    } 

Related Query