最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - amCharts 4 (v4) Display values instead of percentage in pie chart - Stack Overflow

programmeradmin3浏览0评论

Once again exploring Amcharts V4 and i get to display legend in amcharts v3 with value numbers like this (believe is standard)

"legend":{ "position":"left", "fontSize": 22, },

But in V4 in the documentation the session about Legend values isn't pleted, and when i declare the standard is in percentage

pieChart.legend = new am4charts.Legend()

Image of a legend in Amcharts V3 and Amcharts V4

thanks in advance =)

Once again exploring Amcharts V4 and i get to display legend in amcharts v3 with value numbers like this (believe is standard)

"legend":{ "position":"left", "fontSize": 22, },

But in V4 in the documentation the session about Legend values isn't pleted, and when i declare the standard is in percentage

pieChart.legend = new am4charts.Legend()

Image of a legend in Amcharts V3 and Amcharts V4

thanks in advance =)

Share Improve this question asked May 22, 2018 at 14:15 Leandro MurtaLeandro Murta 531 gold badge2 silver badges8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You can change template text in amCharts v4 pie chart by :

pieSeries.labels.template.text = "{category}: {value}";
pieSeries.slices.template.tooltipText = "{category}: {value}";

what worked for me is passing in the value into the legend like so:

let pieSeries = chart.series.push(new am4charts.PieSeries());
pieSeries.legendSettings.labelText = '{category}';
pieSeries.legendSettings.valueText = '{value}';

this assumes your data is something like

const data = [{
  category: "hotdogs",
  value: 33
}]
发布评论

评论列表(0)

  1. 暂无评论