daleijn
daleijn

Reputation: 738

How to increase the distance between the columns in the legend Core plot pieChart

I want to have 2 columns legend under the diagram, and I would like that they are on the sides of the screen, not on the left. This how it's look like now: enter image description here

How can I do it?

Upvotes: 0

Views: 481

Answers (2)

daleijn
daleijn

Reputation: 738

It's done only just by one line of code: theLegend.columnMargin = 90.0; Or theLegend.columnWidths = arrOfWidths;

Upvotes: 0

Eric Skroch
Eric Skroch

Reputation: 27381

Core Plot legends have many options to customize the layout, including the size of the color swatch, the spacing between rows and columns, and the number of rows and/or columns in the grid. See the CPTLegend docs for the details.

The legend itself is just a CPTLayer (Core Animation CALayer subclass). The Core Plot graph provides convenience properties for positioning the legend (legendAnchor and legendDisplacement). If these don't provide enough control, you can position the legend layer anywhere you want using annotations. Use a layer annotation to tie the location to a specific graph layer (fixed screen position) or a plot space annotation so it moves with the plot data.

Upvotes: 1

Related Questions