amCharts 4(v4)在饼图中显示值而不是百分比

时间:2018-05-22 14:15:21

标签: javascript graph amcharts

再次探索Amcharts V4,我将在amcharts v3中显示带有这样的数值的图例(相信是标准的)

  

“传奇”:{           “位置”:“左”,           “fontSize”:22,         },

但是在文档的V4中,关于Legend值的会话没有完成,当我声明标准是百分比时

  

pieChart.legend = new am4charts.Legend()

Image of a legend in Amcharts V3 and Amcharts V4

提前感谢=)

2 个答案:

答案 0 :(得分:0)

对我有用的是将值传递给图例,如下所示:

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

这假设您的数据类似

const data = [{
  category: "hotdogs",
  value: 33
}]

答案 1 :(得分:0)

您可以通过以下方式更改amCharts v4饼图中的模板文本:

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