Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS pie chart properties

I´m using Charts for iOS and have a pie chart. I would like to remove the inner circle and change the width for each pie inside the pie chart. I have not been able to find how to decrease the width for the pie chart and remove the inner circle.

The image is what I want to do.

Chart

I have tried on my PieChartView to change the draw properties but have not succeeded. Any ideas how to solve this?

like image 813
John Doe Avatar asked Oct 22 '16 08:10

John Doe


2 Answers

PieChartView has the following properties:

  1. holeRadiusPercent
  2. transparentCircleRadiusPercent

Set them both to 0.0 and you should achieve what you want.

You can also hide the hole explicitly by setting chartView.drawHoleEnabled = false

If you need more properties, just open the source code. It is heavily commented.

like image 108
Sulthan Avatar answered Oct 13 '22 00:10

Sulthan


Adding to @sulthan's response with some example code.

The CGSize of the chart view's frame can be modified to affect the chart width itself.

However, a CGSize which exceeds the CGSize of the chart's parent view may result in unpredictable layouts.

let chart = PieChartView( frame: self.view.frame)
// setup data...etc.

// style
chart.holeRadiusPercent = 0
chart.transparentCircleColor = UIColor.clear

// increase width
// width in excess of the parentView.size.width will cause layout issues
chart.frame.size = CGSize(width: 500, height: chart.frame.size.height)

Shameless plug: Learn more about iOS Pie charts at ioscharts.io/piechart

enter image description here

like image 27
Alex Avatar answered Oct 13 '22 01:10

Alex