Amcharts 饼图仅在悬停时显示国家/地区
Amcharts Pie Chart show country only on hover
在此演示中 http://www.amcharts.com/demos/simple-pie-chart/#theme-light 它会在首次查看和悬停时显示国家和百分比。我希望在第一次查看时只显示百分比,并且只在悬停时显示国家/地区:百分比。
这可能吗?
非常感谢您的帮助!
您可以使用图表 属性 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>
在此演示中 http://www.amcharts.com/demos/simple-pie-chart/#theme-light 它会在首次查看和悬停时显示国家和百分比。我希望在第一次查看时只显示百分比,并且只在悬停时显示国家/地区:百分比。
这可能吗? 非常感谢您的帮助!
您可以使用图表 属性 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>