Android Jetpack Compose中如何制作无标签重叠的完美饼图
如何编写如图所示的饼图代码?

我尝试过MPAndroidChart等多个库,但都无法解决标签重叠问题。
我目前使用MPAndroidChart的实现代码如下:
val ds = PieDataSet(entries, "") ds.colors = Utils.colors.map { it.toArgb() } ds.yValuePosition = PieDataSet.ValuePosition.OUTSIDE_SLICE ds.xValuePosition = PieDataSet.ValuePosition.OUTSIDE_SLICE ds.sliceSpace = 1.5f ds.valueTextColor = Black33.toArgb() ds.valueTextSize = 12f ds.isUsingSliceColorAsValueLineColor = true ds.valueLinePart1Length = 1f ds.valueLinePart2Length = 1f ds.valueLinePart1OffsetPercentage = 100f ds.valueTypeface = opensans ds.valueFormatter = object : ValueFormatter() { override fun getFormattedValue(value: Float): String { return "%.1f%%".format(value) } } chart.setEntryLabelTextSize(13f) chart.setEntryLabelTypeface(nunito) chart.minAngleForSlices = 25f chart.isRotationEnabled = true val d = PieData(ds) chart.data = d chart.invalidate()
我尝试通过设置minAngleForSlices来缓解问题,但这并非理想解决方案。
内容的提问来源于stack exchange,提问作者Kartik Sharma
相关产品推荐
相关产品推荐

