我正在使用Angular CLI和D3.js v4,但不断收到TypeScript错误:Property 'forEach' does not exist on type '{}'。forEach当我尝试引入数据时,该函数发生错误。
我正在遵循D3技巧和窍门,这似乎非常广泛,并且对图形库很有帮助,但不幸的是,它对我当前的问题没有帮助。
我知道我的json文件的路径是正确的,因为console.log如果我的forEach函数在我的代码中被注释掉,我可以得到数据。
我还尝试data在forEach函数之前定义,以使Typescript知道这data是一个数组。
任何帮助表示赞赏!谢谢!
import { Component, OnInit } from '@angular/core';
import * as d3 from 'd3';
@Component({
selector: 'pl-lukaku-graphs',
templateUrl: './lukaku-graphs.component.html',
styleUrls: ['./lukaku-graphs.component.scss']
})
export class LukakuGraphsComponent implements OnInit {
constructor() { }
total_min() {
// create var for graph wrap
let wrap = document.getElementById("wrapMinPlayed");
// set up graph area
let margin = …Run Code Online (Sandbox Code Playgroud)