Humble Dolt
Humble Dolt

Reputation: 970

Argument of type 'string[]' is not assignable to parameter of type 'ReadonlyArray<number>'

I am trying to learn d3.js from this tutorial I draw figures using d3.js in angular but I am getting stuck here. can anyone please tell me how can I solve this error. I am having only one method drawSvg() and I am getting an error which is Argument of type 'string[]' is not assignable to parameter of type 'ReadonlyArray<number>'

How can I fix this error?

enter image description here

Upvotes: 1

Views: 3445

Answers (1)

Saravana
Saravana

Reputation: 40642

You can specify the type of range when you call d3.scaleLinear<TRange, TOutput>(). Since you are using strings, you can specify the type of your range as string:

let color = d3.scaleLinear<string, number>()
            .domain([0, 60])
            .range(["red", "blue"]);

Upvotes: 11

Related Questions