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

How do I transfer the scripts from the index.html in component where i use chart? #81

Open
Egorro opened this issue Jul 12, 2018 · 2 comments

Comments

@Egorro
Copy link

Egorro commented Jul 12, 2018

<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>

I don't want to load these scripts on initial page load.

thank you.

@darlesson
Copy link
Contributor

When and how are you planning to load the scripts? Are you trying to load them when loading the chart? Are you using something like RequireJS?

I recommend you to check https://www.amcharts.com/kbase/amcharts-meets-requirejs/ if you can use RequireJS and only want to load these files when needed.

@Egorro
Copy link
Author

Egorro commented Feb 21, 2019

I found a solution: https://medium.com/@zainzafar/angular-load-external-javascript-file-dynamically-3d14dde815cb
Load order is important:

this.dynamicScriptLoader
      .load('amcharts') // amcharts should be first
      .then(() => {
        this.dynamicScriptLoader
          .load('amchartsSerial', 'themeLight')
          .then(() => chartMaker());
      })
      .catch(error => console.error(error));

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

2 participants