apexcharts.js: Loading using Require.js (AMD) broken

Codepen

Just open this codepen and check the dev-console (F12):

image

Explanation

I think that SVG is not defined because there is something wrong on module bundler. Do i need to include SVG.js as external library?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (9 by maintainers)

Most upvoted comments

I stumbled across the same issue, here’s my workaround:

require.config({
  baseUrl: ".",
  paths: {
    "ApexCharts": "https://cdn.jsdelivr.net/npm/apexcharts@3.10.1/dist/apexcharts",
    "svg": "https://cdn.jsdelivr.net/npm/svgjs@2.6.2/dist/svg.min"
  }
});

require(['svg', 'ApexCharts'], function (svg, ApexCharts) {
  var myChartOpts = {...};
  var myChart = new ApexCharts(document.querySelector("#myChart"), myChartOpts);
  myChart.render();
});

Hope this helps!