核心情节:如何去除 CPTGraph 的填充?

Core Plot: how to remove CPTGraph padding?

我无法摆脱CPTGraph边框和里面的CPTPlotAreaFrame之间的空隙。

这个例子中的深灰色是CPTGraph,浅灰色是CPTPlotAreaFrame。它们的帧大小都是 { 150, 150 }.

控制 CPTGraph 填充的 属性 是什么? CPTPlotAreaFrame 的 paddingBottom 和其他控制 CPTPlotAreaFrame 的内部填充。

这是代码。

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];

graph 本身上设置填充。 CPTGraph 以每边 20 像素的填充开始。

graph.paddingLeft = 0.0;
graph.paddingTop = 0.0;
graph.paddingRight = 0.0;
graph.paddingBottom = 0.0;