更改圆形图,圆形图上的标签位置

时间:2019-03-29 14:07:58

标签: javascript amcharts amcharts4

我正在使用amcharts创建带有向下钻取的饼图。第一个饼图有两个项目,一个是68,另一个是3。标签3很好,但是84的标签无缘无故地越过了馅饼切片……在切片下面有足够的空间或切片的侧面。

这是现在的样子:

image

奇怪的是,当我向下钻取63时,标签很好...参见此处:

image

我是JS的新手,所以我一直在研究他们的文档,这里有一种方法可以将标签放在切片中,但是不能正常工作,因为在某些情况下切片会很薄...弯曲的标签几乎很好,但是当有很多切片时,标签重叠...也尝试更新css以使高度变大,这迫使标签向上移动...

var types = [{
  type: "Operations",
  value: 68,
  color: chart.colors.getIndex(0),
  subs: [{"type":"Compromised Websites","value":26},{"type":"Malicious Web Sites","value":24},{"type":"Potentially Unwanted Software","value":11},{"type":"Potentially Exploited Documents","value":7}]}, {
  type: "Staff Data",
  value: 3,
  color: chart.colors.getIndex(1),
  subs: [{"type":"Potentially Unwanted Software","value":3}]}
}];


var pieSeries = chart.series.push(new am4charts.PieSeries());
pieSeries.dataFields.value = "value";
pieSeries.dataFields.category = "type";
pieSeries.slices.template.propertyFields.fill = "color";
pieSeries.slices.template.propertyFields.isActive = "pulled";
pieSeries.slices.template.strokeWidth = 0;
pieSeries.labels.template.text = "{category}: {value.value}";
pieSeries.slices.template.tooltipText = "{category}: {value.value}";
pieSeries.ticks.template.adapter.add("hidden", hideSmall);
pieSeries.labels.template.adapter.add("hidden", hideSmall);

理想情况下,标签不会越过切片。

0 个答案:

没有答案