score:1

Accepted answer

That format("2s") is a function that returns a string, while replace should be called on the string itself.

Therefore, it should be:

.call(axisLeft(y).ticks(10).tickFormat(d => format(".2s")(d).replace("G","B")))

Here, format(".2s")(d) returns the formatted string according to the tick. Finally, your second snippet almost got it right, but you're ignoring the actual scale-generated ticks by using only the ticks' indices to get the data values.


Related Query

More Query from same tag