将d3.js包含在angular2项目中

时间:2016-05-18 18:36:21

标签: d3.js typescript npm angular

我尝试使用angular2在MEAN应用程序中使用d3.js库。

这就是我所做的:

npm install d3
tsd install d3

在mypage.ts中(我想显示d3.js图表​​)

// <reference path="../../../typings/d3/d3.d.ts" />
import * as d3 from "d3/d3";

但是我收到了这个错误:error TS2307: Cannot find module 'd3/d3'.

我的打字文件夹结构:

typings
- d3
    d3.d.ts
- index.d.ts

index.d.ts看起来像:

/// <reference path="modules/d3/d3.d.ts" />

1 个答案:

答案 0 :(得分:3)

我坚持=使用Angular2在D3的其他地方,我在这里搜索解决方案。它对我有用:

import * as d3 from 'd3';

看看它是否也适合你。