2017-07-04 66 views

回答

0

您可以添加标签到allLabels。另一种选择是add the label图表开始后:

chart.addListener("init", function (e) { 
    e.chart.addLabel(...); 
}); 

var chart = AmCharts.makeChart("chartdiv", { 
 
    "type": "pie", 
 
    "theme": "light", 
 
    "innerRadius": "40%", 
 
    "gradientRatio": [-0.4, -0.4, -0.4, -0.4, -0.4, -0.4, 0, 0.1, 0.2, 0.1, 0, -0.2, -0.5], 
 
    "dataProvider": [{ 
 
     "country": "Lithuania", 
 
     "litres": 501.9 
 
    }, { 
 
     "country": "Czech Republic", 
 
     "litres": 301.9 
 
    }, { 
 
     "country": "Ireland", 
 
     "litres": 201.1 
 
    }, { 
 
     "country": "Germany", 
 
     "litres": 165.8 
 
    }, { 
 
     "country": "Australia", 
 
     "litres": 139.9 
 
    }, { 
 
     "country": "Austria", 
 
     "litres": 128.3 
 
    }], 
 
    "balloonText": "[[value]]", 
 
    "valueField": "litres", 
 
    "titleField": "country", 
 
    "balloon": { 
 
     "drop": true, 
 
     "adjustBorderColor": false, 
 
     "color": "#FFFFFF", 
 
     "fontSize": 16 
 
    }, 
 
    "allLabels": [{ 
 
    "y": "47%", 
 
    "align": "center", 
 
    "size": 20, 
 
    "bold": true, 
 
    "color": "#555", 
 
    "text": "30%" 
 
    }], 
 
    "export": { 
 
     "enabled": true 
 
    } 
 
});
#chartdiv { 
 
\t width \t \t : 100%; 
 
\t height \t \t : 500px; 
 
\t font-size \t : 11px; 
 
} \t \t \t \t \t \t \t
<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/themes/light.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" /> 
 
<div id="chartdiv"></div> \t \t \t \t \t \t \t

+0

“文”:“30%”是一个静态值,我需要把图表的“动态”内值,从JS后端映射 –