Skip to content Skip to sidebar Skip to footer

Amchart Json Url Pie Chart Does Not Occur

First of all I am very new to using JavaScript. I am trying to create a pie chart using the Amchart library, but the chart does not appear. It's not Cors. Microsoft has been added

Solution 1:

Your dataLoader definition has way too many properties. From your code, it only needs url and the optional format property; the rest of the properties belong to the chart itself.

Fixed code below:

AmCharts.makeChart("chartdiv",
{
        "type": "pie",
        "theme": "black",
        "dataLoader": {
            "url": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/218423/data1.json",
            "format": "json"
        },
        "angle": 20.7,
        "balloonText": "[[title]]<br><span style='font-size:14px' <b>[[value]]</b> ([[percents]]%)</span>",
        "depth3D": 9,
        "labelRadius": 16,
        "labelText": "[[percents]]%",
        "labelTickAlpha": 0,
        "outlineAlpha": 0.49,
        "outlineThickness": 1,
        "titleField": "country",
        "valueField": "visits",
        "handDrawScatter": 0,
        "handDrawThickness": 0,
        "theme": "black",
        "allLabels": [],
        "balloon": {},
        "legend": {
            "enabled": true,
            "align": "center",
            "markerType": "circle"
        }
});

Note that you also need to host the data on your server due to CORS restrictions on codepen (where the URL is pointing to).

Post a Comment for "Amchart Json Url Pie Chart Does Not Occur"