Clifton Labrum
Clifton Labrum

Reputation: 14068

iOS Charts Pie Chart Size

I am using iOS Charts with Swift 3.

I have a 100 x 100 PieChartView that renders the pie chart, but it's not filling the view (an NSView, to be precise). The gray box is the view and there's a large gap between the pie and the edge.

enter image description here

I have confirmed that the view is 100 x 100:

print(graph.frame) //<-- (25.0, 65.0, 100.0, 100.0)

So I assume there is something I need to configure in the pie chart to allow it to be the full size in the view. Here's what I've tried so far to no avail:

graph.holeRadiusPercent = 0.7
graph.transparentCircleRadiusPercent = 0  
graph.legend.enabled = false
graph.chartDescription?.enabled = false
graph.minOffset = 0

Any ideas?

Upvotes: 13

Views: 8453

Answers (1)

Clifton Labrum
Clifton Labrum

Reputation: 14068

Found it! It turns out my graph was rendering the values in the pre-selection state. If I clicked on a pie segment, it would grow larger.

So by setting this property, the graph fills the available space:

ds.selectionShift = 0 //'ds' is my PieChartDataSet

I hope that helps someone else.

Upvotes: 45

Related Questions