krispo / ng2-nvd3

Angular2 component for nvd3
http://krispo.github.io/ng2-nvd3/
MIT License
328 stars 104 forks source link

nv is not defined :Ionic 2 #69

Open anoopsinghbayes opened 7 years ago

anoopsinghbayes commented 7 years ago

Ionic 2 has a different way of adding external dependency,as it uses ionic-cli. ionic-faq

i have added import statements on the page as follows import as d3 from 'd3'; import as nvd3 from 'nvd3'; import { nvD3 } from 'ng2-nvd3';

Am i missing some thing?

nicoabie commented 7 years ago

Check https://github.com/krispo/ng2-nvd3/issues/43#issuecomment-267629352

armarton commented 7 years ago

the #43 is not working for me :(

nicoabie commented 7 years ago

Ok, this is the thing.

If you guys copied ng2-nvd3 and pasted it into your src folder put the imports of d3 and nvd3 there.

What happens is that the module system is "smart", that means if I import something I'm not using the import will not be effectively done.

So what happens is that nvd3 cannot be registered cause d3 was never used ergo imported.

Another solution is to:

console.log(d3.version); and something defined in nvd3 to trick the system and make the imports really happen.