Reputation: 1239
I can't get rid of the gaps between CPTGraph border and CPTPlotAreaFrame inside.
The dark gray color on this example is CPTGraph and the light gray is CPTPlotAreaFrame. Both of them have frame size of { 150, 150 }
.
What is the property that controls CPTGraph padding? CPTPlotAreaFrame's paddingBottom
and others control internal padding of CPTPlotAreaFrame.
Here's the code.
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:hostingView];
CPTXYGraph *graph = [[CPTXYGraph alloc] initWithFrame:NSRectToCGRect(hostingView.bounds)];
graph.fill = [CPTFill fillWithColor:[CPTColor grayColor]];
graph.axisSet = nil;
hostingView.hostedGraph = graph;
// both of these are { 150.0, 150.0 }
NSLog(@"%f %f", graph.frame.size.width, graph.frame.size.height);
NSLog(@"%f %f", graph.plotAreaFrame.frame.size.width, graph.plotAreaFrame.frame.size.height);
graph.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor lightGrayColor]];
graph.plotAreaFrame.masksToBorder = NO;
graph.plotAreaFrame.borderLineStyle = nil;
CPTPieChart *piePlot = [[CPTPieChart alloc] init];
piePlot.dataSource = self.viewModel;
piePlot.pieRadius = MIN( CPTFloat(0.7) * (hostingView.frame.size.height - CPTFloat(2.0) * graph.paddingLeft) / CPTFloat(2.0),
CPTFloat(0.7) * (hostingView.frame.size.width - CPTFloat(2.0) * graph.paddingTop) / CPTFloat(2.0) );
piePlot.identifier = self.title;
piePlot.startAngle = CPTFloat(M_PI_4);
piePlot.sliceDirection = CPTPieDirectionCounterClockwise;
piePlot.labelRotationRelativeToRadius = YES;
piePlot.labelRotation = CPTFloat(-M_PI_2);
piePlot.labelOffset = -50.0;
piePlot.delegate = self;
[graph addPlot:piePlot];
Upvotes: 0
Views: 153
Reputation: 27381
Set the padding on the graph
itself. A CPTGraph
starts with 20 pixels of padding on each side.
graph.paddingLeft = 0.0;
graph.paddingTop = 0.0;
graph.paddingRight = 0.0;
graph.paddingBottom = 0.0;
Upvotes: 1