如何在两行中呈现饼图标题

时间:2015-01-22 09:28:11

标签: java amcharts

我希望Slice的标题分为两行,比如捷克共和国 捷克 共和国 我试过但似乎在我的情况下不起作用。我有小空间来显示图表

var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",  
"theme": "none",
"legend": {
    "markerType": "circle",
    "position": "right",
    "marginRight": 80,      
    "autoMargins": false
},
"dataProvider": [{
    "country": "Czech Republic",
    "litres": 256.9
}, {
    "country": "Ireland",
    "litres": 131.1
}, {
    "country": "Germany",
    "litres": 115.8
}, {
    "country": "Australia",
    "litres": 109.9
}, {
    "country": "Austria",
    "litres": 108.3
}, {
    "country": "UK",
    "litres": 65
}, {
    "country": "Belgium",
    "litres": 40
}],
"valueField": "litres",
"titleField": "country",
 "titleField": "country"
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
"exportConfig": {
    "menuTop":"0px",
    "menuItems": [{
        "icon": '/lib/3/images/export.png',
        "format": 'png'
    }]
}

});

1 个答案:

答案 0 :(得分:0)

您可以在数据提供程序中定义换行符,如下所示:

"dataProvider": [{
    "country": "Czech<br>Republic",
    "litres": 256.9
}

或者您可以使用labeladius-property获取饼图内的标签:

"labelRadius": -35

您可以使用此JSFiddle中的labelRadius来查看它是如何工作的。
文档为here