如何在amCharts中为饼图添加标签?

时间:2015-11-10 04:10:54

标签: javascript amcharts

以下是用于生成饼图的函数。除了 addLabel 参数外,一切正常。

graphSentiChart:function(graphData) {
    if(graphData.length < 1){
      $('.dataContentStatsPie').html('No data available')
    }
    // $(".dataContentAllPie").empty();
    var piechart = AmCharts.makeChart("chartPie", {
        "type": "pie",
        "theme": "light",
        "autoMargins": true,
        "marginTop": 0,
        "marginBottom": 10,
        "marginLeft": 0,
        "marginRight": 0,
        "dataProvider": graphData,
        "titleField":"key",
        "valueField": "value",
        "addLabel": (0, 25, 'Total Tweets= 360'),
        "startDuration":0,
         "responsive": {
            "enabled":true
         },
         "legend":{
           "autoMargins":false,
           "marginLeft":20,
            "enabled": true,
            "spacing":20,
            "markerType":"circle",
            "horizontalGap" :20,

         },
          "labelsEnabled":false,
        //"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",

        "colorField": "color",
        "innerRadius": "60%",

        "export": {
            "enabled": true,
            "libs": {
                "path": "http://amcharts.com/lib/3/plugins/export/libs/"
            }

        }
    });

我没有在addLabel参数中给出,也没有显示标签。有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

amCharts addLabel中没有此类属性。有method,可用于向现有图表对象添加标签。

要在图表的JSON配置中指定标签,请使用allLabels

"allLabels": [{
  "x": 0,
  "y": 25,
  "text": "Total Tweets= 360"
}]