amcharts / amcharts3-react

Official amCharts V3 React component
Apache License 2.0
118 stars 50 forks source link

AmCharts is not defined error when loading libraries from local server #57

Closed rcarausu closed 7 years ago

rcarausu commented 7 years ago

I'm working on a project where I'm using amcharts but can't seem to get it working when I want to download and use the libraries from my own server, like this:

<script src="amcharts/amcharts.js"></script>
<script src="amcharts/serial.js"></script>
<script src="amcharts/themes/light.js"></script>

But when importing the react component I get an error saying that AmCharts is not defined.

The thing is that it does work when adding the script tags from the CDN. so I have no clue of what might be failing.

I decided to use the 'create-react-app' to see if some weird dependency from my project but I get the same result so I guess that I might be doing something wrong. Here you can see my package.json and the import:

{
  "name": "amcharts_test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-scripts": "1.0.13",
    "@amcharts/amcharts3-react": "^3.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
import AmCharts from '@amcharts/amcharts3-react';

Thanks in advance.

rcarausu commented 7 years ago

Seems that I didn't add 'localhost:300' in src, it should be like

<script src="https://localhost:3000/amcharts/amcharts.js"></script>