John Doe
John Doe

Reputation: 91

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?

Upvotes: 9

Views: 7749

Answers (2)

Sulthan
Sulthan

Reputation: 130210

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.

Upvotes: 17

Alex
Alex

Reputation: 714

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

Upvotes: 7

Related Questions