HighCharts 饼图数据标签未完全显示

问题描述 投票:0回答:1

当我使用饼图显示数据时,数据的标签显示不完全。尤其是当数据密集的部分只能显示几个标签时。 A label is missing in the upper left corner

我的要求是能够显示所有标签。即使数据比较密集,也可以显示所有标签。标签最好不要重叠。

highcharts pie-chart chart.js-datalabels
1个回答
0
投票

有时数据标签不会显示,因为没有足够的空间来渲染它们。为了确保所有这些都被渲染,我们必须做两件事:

  1. dataLabels.allowOverlap 属性设置为 true。
  2. 确保有足够的空间供数据标签渲染。

在您的情况下,只需稍微增加 dataLabels.distance 属性即可:

 dataLabels: {
  distance: 50
 }

演示:https://jsfiddle.net/BlackLabel/ptmLw12r/

API参考:

https://api.highcharts.com/highcharts/plotOptions.pie.dataLabels.distance

https://api.highcharts.com/highcharts/plotOptions.series.dataLabels.allowOverlap

© www.soinside.com 2019 - 2024. All rights reserved.