How do I install local amcharts?

1

In this example it works perfect.

var chartData = [ {
    "country": "USA",
    "visits": 4252
  }, {
    "country": "China",
    "visits": 1882
  }, {
    "country": "Japan",
    "visits": 1809
  }, {
    "country": "Germany",
    "visits": 1322
  }, {
    "country": "UK",
    "visits": 1122
  }, {
    "country": "France",
    "visits": 1114
  }, {
    "country": "India",
    "visits": 984
  }, {
    "country": "Spain",
    "visits": 711
  }, {
    "country": "Netherlands",
    "visits": 665
  }, {
    "country": "Russia",
    "visits": 580
  }, {
    "country": "South Korea",
    "visits": 443
  }, {
    "country": "Canada",
    "visits": 441
  }, {
    "country": "Brazil",
    "visits": 395
  }, {
    "country": "Italy",
    "visits": 386
  }, {
    "country": "Australia",
    "visits": 384
  }, {
    "country": "Taiwan",
    "visits": 338
  }, {
    "country": "Poland",
    "visits": 328
} ];

AmCharts.makeChart( "chartdiv", {
  "type": "pie",
  "language": "es",
  "startDuration": 1,
  "theme": "light",
  "dataProvider": chartData,
  "valueField": "visits",
  "titleField": "country",
  "outlineAlpha": 0.4,
  "depth3D": 15,
  "balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
  "angle": 30,
  "export": {
    "enabled": true
  },
} );
#chartdiv {
  width: 100%;
  height: 500px;
}
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/pie.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.21.6/plugins/export/lang/es.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>

<div id="chartdiv" style="width: 640px; height: 400px;"></div>

But if I download those libraries, I keep them in a folder like / amcharts and call them like this:

<script src="/amcharts/amcharts.js" type="text/javascript"></script>
<script src="/amcharts/pie.js" type="text/javascript"></script>
<script src="/amcharts/export.min.js" type="text/javascript"></script>
<link href="/amcharts/export.css" rel="stylesheet" type="text/css" />
<script src="/amcharts/es.js" type="text/javascript"></script>
<script src="/amcharts/light.js" type="text/javascript"></script>

This generates the following error:

    
asked by Pablo Contreras 12.09.2017 в 04:41
source

1 answer

5

One of the problems that I think is causing you that is the folder of your place where you have the amcharts . I recommend that you download your sources and unzip them in your folder amcharts but with its logical folder structure.

It would look like this:

In addition you will have to square the src of each js and css with its corresponding route, being for example amcharts.js in this way

<script src="amcharts/amcharts.js"></script>

or the export.min.js in this other way since it is in a subfolder:

<script src="amcharts/plugins/export/export.min.js"></script>

Remember to also remove the% initial / you have in each of your routes because otherwise you will search from the root

I leave here also a test that I have done in local is a rar that has a folder with an index and the folder amcharts.

link

    
answered by 14.09.2017 / 11:06
source