0
votes

I'm using automatic labeling (CPTAxisLabelingPolicyAutomatic) with the CPTCalendarFormatter formatter to format my x axis - so far so good.

However, my graph is full width in it's container and because of that, the 2 labels at the edges of the plot are being clipped. See below:

enter image description here

Is there a simple way to format the padding on the first and last label, so that they sit within the graph, rather than extending beyond it?

Thanks!

2

2 Answers

2
votes

If I understand your question, you want the labels to fit under the graph, (not extend beyond the edges of the graph).

As I see it you have two options:

  1. Expand plot range as others have mentioned before, or
  2. Define the positions of your labels yourself.

Example of how to set your own label positions:

CPTXYAxisSet *axisSet; //your graph's axis set;
NSSet *labelPositions; //some set containing positions of all labels stored as NSNumbers

[axisSet.xAxis setLabelingPolicy:CPTAxisLabelingPolicyLocationsProvided];
[axisSet.xAxis setMajorTickLocations:labelPositions];
0
votes

Set some padding on the plot area frame to leave room for the labels:

graph.plotAreaFrame.paddingLeft  = 20.0;
graph.plotAreaFrame.paddingRight = 20.0;