Knowledge Base

Using RequireJS with amCharts

This demo shows you how to use RequireJS with amCharts files, including complex dependency structure of the Export plugin.

The fine points to keep in mind while working with RequireJS and amCharts are as follows:

  • Define paths to all amCharts includes, including plugins you are using, not just the amcharts.js
  • Define dependency structure: plugins require main amcharts.js to be loaded before they can be loaded
  • Export plugin relies on a number of external libraries, that need to be pathed and set as its dependencies
  • pdfmake library (used for Export plugin) relies on its own dependency (pdffonts), hence special rule for it
  • Finally, Export plugin’s auto-load feature needs to be disabled

For further in-depth description of this can be found in our tutorial: amCharts meets RequireJS.