score:6

Accepted answer

Seems like you are working with TypeScript.

You might need to provide the generics for d3.scaleThreshold() in order for it to accept strings.

As mentioned on the DefinitelyTyped TypeScript type definitions for D3.js,

  • Constructs a new threshold scale. The domain and range must be set corresponding to the type of the corresponding generic.
    • The first generic corresponds to the data type of domain values.
    • The second generic corresponds to the data type of range values.

Since you are using strings for both domain and range, we can specify both types as string.

d3.scaleThreshold<string, string>().domain().range()

Reference


Related Query

More Query from same tag