John
John

Reputation: 181

In Angular app, how do I import d3 and use d3.js scripts?

I'm using d3.js version 3 script in my angular app.

I have installed d3 in angular app using command

npm i d3@3

And imported d3 as

import * as d3 from 'd3';

Even though I imported d3 as above, I'm getting error

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()

when i use d3. any method

Thanks in advance..

Upvotes: 2

Views: 1447

Answers (1)

Sayooj V R
Sayooj V R

Reputation: 2363

first install d3 and type declaration

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

then import d3

import * as d3 from 'd3';

Please let me know if it is not working.

Upvotes: 1

Related Questions