在Angular应用程序中,如何导入d3并使用d3.js脚本



我在我的angular应用程序中使用d3.js版本3的脚本。

我已经使用命令在angular应用程序中安装了d3

npm i d3@3

并进口d3作为

import * as d3 from 'd3';

尽管我如上所述导入了d3,我收到错误

Property 'layout' does not exist on type 'typeof import("C:/Users/srikar.vodeti/Downloads/imp/dashboardVisual/networkDiagram/node_modules/@types/d3/index")'. 106 var tree = d3.layout.tree()

当我使用d3时。任何方法

提前谢谢。。

首先安装d3并类型声明

npm install d3 --save
npm install --save @types/d3

然后导入d3

import * as d3 from 'd3';

如果它不起作用,请告诉我。

最新更新