1

enter image description here

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:

  1. Align the entry text to be at the center outside the slice. [Look at 1 & 3]
  2. 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
Rameswar Prasad
  • 1,331
  • 17
  • 35
  • I think you should file this as an issue on GitHub. If you want some answers please provide us with the code you used to generate the chart in the above image. – Damiaan Dufaux Jul 21 '18 at 07:36
  • Most likely the labels are being rotated on the same radius. It would explain why they appear to be at different distances from the chart at different angles. You won’t be able to fix that through the api I wouldn’t think. – Brian Jul 21 '18 at 10:00
  • @Brian Tested, it's not with rotation angle, better I'd raise an issue on Github. – Rameswar Prasad Jul 21 '18 at 14:07
  • Show your code how you are setting Charts value so we can help you on this. – CodeChanger Jul 23 '18 at 06:55
  • @CodeChanger Updated with code – Rameswar Prasad Jul 23 '18 at 08:47
  • I have check your code and screen shot of your Donut chart your chart missing arrow connected with values and so it looks perfect as per value plotted. Please check arrow with donut chart – CodeChanger Jul 23 '18 at 10:13
  • @CodeChanger Correct. What I want is disable the arrows/value lines and align the values properly outside the slice. There's no way to disable the value lines other than making it appear transparent. Do you know any way around to achieve this? I have already raised an issue in Github though. – Rameswar Prasad Jul 23 '18 at 10:41
  • I think thats not possible and we can not fix them as its rotate with your chart to every time need to calculate new value for it. Still you can ask to library owner for this feature. – CodeChanger Jul 23 '18 at 11:45

1 Answers1

-3

change the yValuePosition to .insideSlice