gpt4 book ai didi

objective-c - 核心情节: how to remove CPTGraph padding?

转载 作者:行者123 更新时间:2023-12-03 17:49:26 27 4
gpt4 key购买 nike

我无法消除 CPTGraph 边框和内部 CPTlotAreaFrame 之间的间隙。

此示例中的深灰色是 CPTGraph,浅灰色是 CTPlotAreaFrame。它们的帧大小均为 { 150, 150 }

enter image description here

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

最佳答案

设置图表本身的填充。 CPTGraph 从每边 20 像素的填充开始。

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

关于objective-c - 核心情节: how to remove CPTGraph padding?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31664716/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com