问题
The Charts library I'm using: Daniel Gindi - Charts
If you look at the above image, the position offset of entries outside each slice are variable both in distance from the slice as well as in alignment.
What I want:
- Align the entry text to be at the center outside the slice. [Look at 1 & 3]
- Keep all the slice texts equidistant from the slice. [Look at 3 & 6]
What I tried so far:
I tried to play with valueLinePart1Length
and valueLinePart2Length
, but this just helped a little, didn't solve the problem completely. Also I went through all the variables of PieChartDataSet
.
Still haven't figured out how to fix this, can someone point out am I missing something or how to fix the issue.
Edit: Added code
let values: [Double] = [16, 6, 1, 3]
let chartEntries: [PieChartDataEntry] = pieChartEntries(for: values)
let pieChartDataSet = PieChartDataSet(values: chartEntries, label: nil)
pieChartDataSet.sliceSpace = 2
pieChartDataSet.colors = colors
pieChartDataSet.valueLineWidth = 0
pieChartDataSet.valueLinePart1Length = 0.4
pieChartDataSet.valueLinePart2Length = 0
pieChartDataSet.valueTextColor = .black
pieChartDataSet.yValuePosition = .outsideSlice
pieChartDataSet.valueLineVariableLength = false
let pieChartData = PieChartData(dataSet: pieChartDataSet)
pieChart.data = pieChartData
来源:https://stackoverflow.com/questions/51453836/pie-chart-entries-outside-slices-have-different-position-offsets