mayur ingole
mayur ingole

Reputation: 21

Module not found error can't resolve angular 7

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;
  }
}

Upvotes: 2

Views: 4298

Answers (1)

Vladyslav Didenko
Vladyslav Didenko

Reputation: 1631

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

Upvotes: 3

Related Questions