Reputation: 4489
I cannot wrap my head around how i can import d3js library in a ionic typescript projet. I installed the library using :
npm install d3 --save-dev
The library is in node_modules/d3. In my page modules, I try to import using every possible path, for example :
import * as d3 from 'd3/d3'
import * as d3 from '../../../node_modules/d3/d3'
I always get the error:
Error TS2307: Cannot find module 'd3/d3'.
or
Error TS2307: Cannot find module '../../../node_modules/d3/d3'`.
Any hint to help me ?
Angular version 2.0.0-rc.1
Ionic : 2.0.0-beta.9
Thanks
Upvotes: 0
Views: 1416
Reputation: 4878
Try this:
npm install @types/d3 --save
I just tried it and it works. More info here.
Upvotes: 0
Reputation: 4489
I used a workaround the issue.
What I did :
Link d3js in the index.html (at the end of the file, bellow app.bundle.js):
<script src="https://d3js.org/d3.v3.min.js"></script>
Then in my page.ts (before @Component) :
declare var d3: any;
And then you can use it like :
d3.select("#graph svg").remove();
So I am not using import (you should delete the import if you want to use this solution)
Upvotes: 1