Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 381
Clifton Labrum Avatar asked Feb 05 '17 05:02

Clifton Labrum


People also ask

How do you change the size of a pie chart?

To change the size manually, click the chart, and then drag the sizing handles to the size that you want. To use specific height and width measurements, on the Format tab, in the Size group, enter the size in the Height and Width box. .

Does a pie chart have to equal 100 %?

Pie charts are designed to show parts of a whole, so any sum below or above 100% doesn't represent the entire picture. Finally, when it comes to legends, pie charts don't generally need one. It's cleaner to label your data directly.

What does the size of the pie chart represent?

Each categorical value corresponds with a single slice of the circle, and the size of each slice (both in area and arc length) indicates what proportion of the whole each category level takes.


1 Answers

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.

like image 113
Clifton Labrum Avatar answered Oct 18 '22 07:10

Clifton Labrum