Reputation: 399
I am importing D3 in my component. Then I need to assign a layout to the D3.layout
-property. The problem is, that my D3-Object knows the layout
-property when I output it in the console, but the function is unknown when I try to call it.
what could that be?
import { adjacencyMatrixLayout } from './lib/d3-adjacency-matrix-layout';
import * as d3Lib from 'd3';
export class AdjacencyComponent implements OnInit {
public adjacencyData: any;
private _d3 = d3Lib;
constructor(private _dataService: DataService) {
console.log(this._d3); // <--- layout is there, I can see it in the console
this._d3.layout; // <---- Property 'layout' does not exist on type 'typeof ?? WHY?
}
}
Upvotes: 0
Views: 44
Reputation: 399
If someone has the same problem, the solution was to assign d3Lib
inside the constructor.
Upvotes: 0
Reputation: 8183
You need the type definitions for D3.
You can install the NPM Package here: https://www.npmjs.com/package/@types/d3
Upvotes: 1