amcharts / export

Apache License 2.0
56 stars 33 forks source link

amCharts Export loading error on libraries #67

Closed andreuccia closed 6 years ago

andreuccia commented 7 years ago

I am working on a project using amcharts, and I'm trying to use the Export features. I linked to my project export.js and export.css according the userguide, in this way i can finally see the download button/export button in the top right of my charts so the libs are correctly loaded. Unfortunately i can't get any image or xslx from that, opening a console it comes 4 errors related to loading error on the 4 libraries useful to work with export:

if I try to attach manually pdfmake library, I can solve the dependency issue, but if I try to do the same with the others, the console still reports problems about loading error libs.

How I could solve this?

maertz commented 7 years ago

Looks like you've changed the libs settings because the export plugin loads the minified version of its dependencies by default. Please make sure all resources of the plugin has been are available through the network amcharts/plugins/export/libs/ (default path).

andreuccia commented 7 years ago

hello maertz, thanks for the quick reply, how i could check this? I downloaded the entire package with Npm, and with file explorer I can see all those files

maertz commented 7 years ago

Sounds like you are not using a server to serve the website. Please create a new folder and add following files into it to test the setup - if it works compare it with your project.

package.json

{
  "name": "app",
  "version": "1.0.1",
  "description": "basic app example",
  "scripts": {
    "start": "node index.js"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "tiny-cdn": "latest",
    "amcharts3": "latest"
  }
}

index.js

// simple server example
require('http')
  .createServer(require('tiny-cdn').create({}))
  .listen(8080, '0.0.0.0');

index.html

<!DOCTYPE html>
<html>

<head>
  <meta charset='utf-8'>
  <meta name="viewport" content="width=device-width,initial-scale=1">

  <script src="/node_modules/amcharts3/amcharts/amcharts.js" type="text/javascript"></script>
  <script src="/node_modules/amcharts3/amcharts/serial.js" type="text/javascript"></script>
  <script src="/node_modules/amcharts3/amcharts/plugins/export/export.js" type="text/javascript"></script>
  <link rel="stylesheet" href="/node_modules/amcharts3/amcharts/plugins/export/export.css" />
</head>

<body>
  <div id="chartdiv" style="height: 400px; width: 600px;"></div>
  <script type="text/javascript">
    // XLXS.js WORKAROUND IN NODE ENV
    cptable = true;
    AmCharts.makeChart("chartdiv", {
      type: "serial",

      dataProvider: [{
        "year": 2005,
        "income": 23.5,
        "expenses": 18.1
      }, {
        "year": 2006,
        "income": 26.2,
        "expenses": 22.8
      }],
      categoryField: "year",
      graphs: [{
        type: "column",
        valueField: "income",
        fillAlphas: 1
      }],

      export: {
        enabled: true
      }

    });
  </script>
</body>

</html>

NPM

npm install
npm start

If it starts click here http://localhost:8080

andreuccia commented 7 years ago

Okey in this way, with the dummy test it works, in my project i have different file structure and i am working with angular js for the FrontEnd, I think it's something related to the "lazy load" of the libs

maertz commented 6 years ago

I assume the issue is gone due inactivity, if not please open a new ticket to solve it.