3

I want to draw the slice text outside the slices in pie chart, like in this image:

slice text outside slices

How can I achieve this?

Thanks :)

Hasya
  • 9,792
  • 4
  • 31
  • 46
leonidster
  • 61
  • 1
  • 5

5 Answers5

9

Try this

pieChartDataSet.xValuePosition = .OutsideSlice
David
  • 11,245
  • 3
  • 41
  • 46
1

I haven't used pie charts myself yet in ios-charts, but just looking at this (unfortunately incomplete) documentation , I would suggest trying to alter some of the values in the PieChartDataSet.

In Particular, xValuePosition, yValuePosition or ValuePosition.

In the bar chart class it is done like so barChartView.xAxis.labelPosition = .Bottom, hence my thinking it may be one of the above values. So have a play around and hopefully that helps you out! :)

Documentation: Charts Docs - PieChartDataSet

fordrof
  • 107
  • 6
1

you can try with this lines

charDataSet.valueFont = .systemFont(ofSize: 18)
charDataSet.valueLinePart1OffsetPercentage = 0.8
charDataSet.valueLinePart1Length = 0.05
charDataSet.valueLinePart2Length = 0.05
charDataSet.valueLineWidth = 0
charDataSet.yValuePosition = .outsideSlice

chart.transparentCircleRadiusPercent = 0
chart.holeColor = nil
chart.holeRadiusPercent = 0.8
chart.legend.enabled = false
chart.animate(xAxisDuration: 1)
chart.drawSlicesUnderHoleEnabled = false

regards

Andres Gomez
  • 458
  • 3
  • 12
0

When you are working with iOS chart , feature which you are expecting is not yet available.

Please refer.

Either you move with other library or still you could make max as per attached image.

enter image description here

You can download this code.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Hasya
  • 9,792
  • 4
  • 31
  • 46
0

To do this you can try the following. If using PieChart it will draw the value outside of the slice with some line pointing to the right slice.

dataSet.yValuePosition = .outsideSlice

Above will give you the following result

PieChart Demo

Anuran Barman
  • 1,556
  • 2
  • 16
  • 31