在此演示http://www.amcharts.com/demos/simple-pie-chart/#theme-light中,它会在第一次观看和悬停时显示国家/地区和百分比。我想只在第一个视图中显示百分比,并显示country:百分比仅在悬停时。
这可能吗? 非常感谢您的帮助!
答案 0 :(得分:0)
您可以使用图表属性labelText
来指定切片标签的显示内容。
要仅显示百分比,您需要将其设置为"[[percents]]%"
。
var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme": "light",
"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
}, {
"country": "UK",
"litres": 99
}, {
"country": "Belgium",
"litres": 60
}, {
"country": "The Netherlands",
"litres": 50
}],
"valueField": "litres",
"titleField": "country",
"labelText": "[[percents]]%"
});
<script src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="http://www.amcharts.com/lib/3/pie.js"></script>
<script src="http://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv" style="width: 100%; height: 350px;"></div>