Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing document #969

Closed
trungvose opened this issue Mar 20, 2018 · 3 comments
Closed

Confusing document #969

trungvose opened this issue Mar 20, 2018 · 3 comments

Comments

@trungvose
Copy link

trungvose commented Mar 20, 2018

I am using ng2-charts in our Angular application. It is working well so far. But run through the document, there is one line that you guys mention that Important

Embedding Chart.js in application is mandatory!

confusing-statement

I checked the source of the file "node_modules/chart.js/src/chart.js". So basically it will contain all the CommonJS module, and it doesn't work on browser for sure.

/**
 * @namespace Chart
 */
var Chart = require('./core/core')();

Chart.helpers = require('./helpers/index');

// @todo dispatch these helpers into appropriated helpers/helpers.* file and write unit tests!
require('./core/core.helpers')(Chart);

Chart.defaults = require('./core/core.defaults');
........

So my question is: Is this step required? If not, please remove it from the documentation. Otherwise people will be confused.

@angelmartinez-wz
Copy link

angelmartinez-wz commented Jul 27, 2018

It's important due to the fact that ng2-charts are based in Chart.js if you following installation guide, step two refers that.
captura de pantalla 2018-07-27 a la s 12 26 03

If you don't want to install chart.js via npm, you can do it via CDN.

Install npm install ng2-charts --save
Import Chart.js CDN in your index.html <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
Import { ChartsModule } from 'ng2-charts' in your component
Create your graphic in your component.

@ralyodio
Copy link

so do i put this line in my index.html? <script src="node_modules/chart.js/src/chart.js"></script>

It works locally but what happens when I build for production? Won't that break?

@arrow-dev
Copy link

arrow-dev commented Oct 29, 2018

I'm also confused about this, my app seems to work just fine if I only include ng2-charts and don't install chart.js at all? "Embedding Chart.js in application is mandatory!" - is this no longer the case?

Looks like chart.js is listed as a dependency of ng2-charts package.json, so npm installs it, and it seems to work fine without needing to add the script in angular.cli.json/index.html, docs need to be updated or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants