我正在尝试将交互式d3气泡图与angular 7集成在一起,但是在构建示例应用程序时我总是得到
module not found error can't resolve 'd3' in '.../Angular_Example/angular-d3-graph-example-master/src/app/d3'
请帮助我,谢谢
import { Node, Link, ForceDirectedGraph } from './models';
import * as d3 from 'd3';
@Injectable()
export class D3Service {
constructor() { }
applyZoomableBehaviour(svgElement, containerElement) {
let svg, container, zoomed, zoom;
svg = d3.select(svgElement);
container = d3.select(containerElement);
zoomed = () => {
}
applyDraggableBehaviour(element, node: Node, graph: ForceDirectedGraph) {
}
}
getForceDirectedGraph(nodes: Node[], links: Link[], options: { width, height }) {
const sg = new ForceDirectedGraph(nodes, links, options);
return sg;
}
}
答案 0 :(得分:0)
考虑到@mayuringole的反馈,请执行以下步骤:
npm install d3 --save
npm install @types/d3 --save
这为我解决了这个问题。就我而言,我尝试通过<script>
标签使用d3库,但并非所有组件都被识别
通过npm + import * as d3 from "d3";
安装模块就可以了