score:1

Accepted answer

you could use a conditional return statement within the function which returns d. for example:

  .text(function(d) {
    if (d==="a") {
        return "field1" 
    }else {
        return "field2"
    }
  })

working fiddle.

let me know if this is not the solution you were looking for.


Related Query

More Query from same tag