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

前端 未结 6 1195
小鲜肉
小鲜肉 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:52

    As said, it's a TypeScript interpretation issue. I simply fixed it using brackets notation to access the property. Just like this:

    let line = d3.line()
      .x(function (d) {
        return x(d['date']);
      })
      .y(function (d) {
        return y(d['temp']);
      });
    

提交回复
热议问题