简体   繁体   English

Amcharts饼图仅在悬停时显示国家

[英]Amcharts Pie Chart show country only on hover

In this demo http://www.amcharts.com/demos/simple-pie-chart/#theme-light it shows the country and percent both at first view and on hover. 在此演示http://www.amcharts.com/demos/simple-pie-chart/#theme-light中 ,该视图在首次显示和悬停时都显示了国家/地区和百分比。 I would like only the percent to be shown at first view, and show country: percent only on hover. 我希望只在第一视图中显示百分比,并在国家/地区显示:仅在悬停时显示百分比。

Is this possible? 这可能吗? Many thanks for any help! 非常感谢您的帮助!

You can use chart property labelText to specify what is being shown for slice labels. 您可以使用图表属性labelText指定要显示的切片标签内容。

To show only percents, you would need to set it to "[[percents]]%" . 要仅显示百分比,您需要将其设置为"[[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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM