I'm also not sure what you think. This does not seem to work for me.
I have two suggestions to continue.
Best answer
The first is the addition to Arlo's answer. When I originally wrote this comment, I could not get Arlo to respond to work. Now I understand why. I tried to use the d3-hierarchy package. Therefore, the installation:
npm install d3 --save npm install @types/d3 --save-dev npm install @types/d3-hierarchy --save-dev
And then using the modules as follows:
import * as d3 from "d3"; d3.hierarchy(blah);
And then he will complain that he did not know about the d3.hierarchy member. Now I understand that I must use this object (I do not know why it has not been registered before). So updated:
import * as d3 from "d3"; import * as d3Hierarchy from "d3-hierarchy"; d3Hierarchy.hierarchy(blah);
Original answer
It seems that the only answer I have found so far is the d3-ng2-service module, located by reference. This is not a great option, but it allows you to use d3v4 in your angular 2 project.
The following is an excerpt from readme on how to use it in an angular 2 component:
import { Component, OnInit, ElementRef } from '@angular/core'; import { D3Service, D3, Selection } from 'd3-ng2-service';
AMB0027
source share