Angular 2 typescript d3 type issue: Property 'x' does not exist on type '[number, number]'

前端 未结 6 1161
小鲜肉
小鲜肉 2021-01-11 15:15

I am generating a line chart with d3. It works, but typescript code complain about a property not exists in vs.

Property \'x\' does not exist on type

6条回答
  •  离开以前
    2021-01-11 15:49

    its a typescript error.

    i think there is no x property right now in your d. can you try this

     return this.xScale(d?.x);
     return this.xScale(d?.y);
    

    or may be your d have data like this ["x_value","y_value"] in number format.

    in this case you should try

    return this.xScale(d[0]);
    return this.yScale(d[1]);
    

    i hope this will help

提交回复
热议问题