krispo / ng2-nvd3

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

Including Dependencies for offline usage #89

Closed matthias-herrmann closed 7 years ago

matthias-herrmann commented 7 years ago

I'm failing to include ng2-nvd3 in my angular 4 project. I don't want to include online resources, it should work offline as well.

I installed the following packages: npm install ng2-nvd3 npm install nvd3 npm install d3@v3.5.17

And copied the code from app.module.ts, app.component.ts and replaced <app-root></app-root> by <main></main> from the plunker example here: http://plnkr.co/edit/T4i7Zh?p=preview example

Now when I'm running it it is compiling fine but in the browser console I get this error:

ERROR ReferenceError: nv is not defined at NvD3Component.clearElement (ng2-nvd3.component.js:211) at NvD3Component.initChart (ng2-nvd3.component.js:32) at NvD3Component.ngOnChanges (ng2-nvd3.component.js:20) at checkAndUpdateDirectiveInline (core.es5.js:10891) at checkAndUpdateNodeInline (core.es5.js:12382) at checkAndUpdateNode (core.es5.js:12321) at debugCheckAndUpdateNode (core.es5.js:13182) at debugCheckDirectivesFn (core.es5.js:13123) at Object.eval [as updateDirectives] (AppComponent.html:3) at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13108)

How can I get this working? I don't want to include online resources like this:

krispo commented 7 years ago

You should import d3 and nvd3 somewhere, for example in main.ts:

import d3;
import nvd3;
matthias-herrmann commented 7 years ago

@krispo thanks, that solved it