Reputation: 71
I want to draw the slice text outside the slices in pie chart, like in this image:
How can I achieve this?
Thanks :)
Upvotes: 3
Views: 2760
Reputation: 1676
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
Upvotes: 0
Reputation: 9898
When you are working with iOS chart , feature which you are expecting is not yet available.
Either you move with other library or still you could make max as per attached image.
Upvotes: 0
Reputation: 458
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
Upvotes: 1
Reputation: 91
Try this
pieChartDataSet.xValuePosition = .OutsideSlice
Upvotes: 9
Reputation: 117
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
Upvotes: 1