I want to draw the slice text outside the slices in pie chart, like in this image:
How can I achieve this?
Thanks :)
I want to draw the slice text outside the slices in pie chart, like in this image:
How can I achieve this?
Thanks :)
Try this
pieChartDataSet.xValuePosition = .OutsideSlice
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
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
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.
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