首页 > 解决方案 > 在饼图外显示值

问题描述

我无法在饼图之外显示值。目前这些值重叠,有什么办法可以改进吗?请看下图。

chartDataSet.valueLinePart1Length = 0.5
chartDataSet.valueLinePart2Length = 1
//set.xValuePosition = .outsideSlice
chartDataSet.yValuePosition = .outsideSlice

图片

标签: swiftchartspie-chart

解决方案


func setupPiChart() {
    // This will align label text to top right corner
    let l = pieChartView.legend
    l.horizontalAlignment = .left
    l.verticalAlignment = .bottom
    l.orientation = .horizontal
    l.xEntrySpace = 10
    l.yEntrySpace = 0
    l.font = self.isPhone ? Typography.robotoRegular14 : Typography.robotoRegular18

    self.pieChartView.entryLabelFont = Typography.robotoRegular14
    self.pieChartView.drawHoleEnabled = false
    self.pieChartView.drawEntryLabelsEnabled = false
    self.pieChartView.notifyDataSetChanged()
}

推荐阅读