2

I am trying to integrate interactive d3 bubble chart with angular 7 but when building my sample application I always get

module not found error can't resolve 'd3' in '.../Angular_Example/angular-d3-graph-example-master/src/app/d3'

Please help me, Thanks


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;
  }
}
3
  • Have you installed the module with npm install -d d3 ? Commented Mar 27, 2019 at 9:35
  • 1
    yes, Install d3 library using command npm install d3 --save and then Install d3 library types using command npm install @types/d3 --save Commented Mar 27, 2019 at 9:40
  • @mayuringole for me this fixed the issue :) Thanks! Commented Oct 1, 2019 at 14:52

1 Answer 1

3

Taking into account feedback of @mayuringole here are the steps:

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

This fixed the issue for me. In my case I tried to use the d3 lib via the <script> tag and not all components were recognized

By installing the modules via npm + import * as d3 from "d3"; it went ok

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.