Reputation: 2625
Am using Core Plot to display a line chart. The label for plot gets cut when it is near (though not outside) the border as seen below
though, as you can see in the XCode Storyboard (below pic) that the border of each graph is well above (height) and there doesn't seem to be a reason why the label of the plot is getting cut.
I have set the graph Hosting View's frame to match the frame size in XCode.
self.graphHostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc]
initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y,
self.view.frame.size.width, self.view.frame.size.height)];
self.graph = [[CPTXYGraph alloc] initWithFrame:self.graphHostView.bounds];
Also, how do I get rid of the label name in X-Axis (the leftmost 1.0 and rightmost 5.0)?
EDITED
@EricSkroch , I tried the following :
CASE 1 Setting plotAreaFrame.paddingTop=20.0 plotAreaFrame.paddingBottom=15.0
CASE 2 graph.paddingTop=20.0 graph.paddingBottom=15.0 (didn't set anything for plotAreaFrame)
CASE 3 Setting both the above (plotAreaFrame & graph padding) plotAreaFrame.paddingTop=20.0 plotAreaFrame.paddingBottom=15.0 graph.paddingTop=20.0 graph.paddingBottom=15.0
CASE 4 - Seems to be the best output! (though the top is still cropped) Setting top padding to 0 for both plotArea & frame graph.paddingTop=0.0 plotAreaFrame.paddingTop=0.0
CASE 5 If I try to increase either plotAreaFrame or graph's top-padding, this is what i get graph.paddingTop=5.0
Upvotes: 2
Views: 892
Reputation: 27381
Add some padding to the graph and/or plot area frame (paddingLeft
, paddingRight
, etc.). This will push the plot area in away from the edges of the graph leaving room for the labels.
Upvotes: 2