开发者

How do remove the border around a core-plot graph

I am trying to remove the border around a core plot graph on the iPhone - but seem to be struggling on what should be simple in my mind.开发者_如何学Go

Pointers please!


You should be able to nil out the borderLineStyle on the graph's plotArea to remove the border:

graph.plotAreaFrame.borderLineStyle = nil;    // don't draw a border

You could also create your own theme, using the ones in the framework as examples, and simply not set the borderLineStyle in that.


None of the answers worked for me. This did the job:

graph.paddingLeft = 0;
graph.paddingRight = 0;
graph.paddingTop = 0;
graph.paddingBottom = 0;
graph.plotAreaFrame.borderWidth = 0;
graph.plotAreaFrame.cornerRadius = 0;


OK I found out how to do it - quite simple really!

CPLineStyle *borderLineStyle = [CPLineStyle lineStyle];
borderLineStyle.lineColor = [CPColor whiteColor];
borderLineStyle.lineWidth = 1.0;

graph.plotArea.borderLineStyle = borderLineStyle;

where graph is your graph object - the reason I had a border in the first place was because I used CPPlainWhiteTheme.

Hope this helps others - is there a better way?


You can set any line style to nil. This will cause the line to not be drawn at all.


In CorePlot 1.0, the structure of CPTGraph has changed slightly. The code for removing the border line of a graph, assuming that graph is of type GPTGraph or a subclass of CPTGraph, is

graph.plotAreaFrame.borderLineStyle = nil;


The correct way with borderLineStyle = nil after applyTheme:

CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:hostView.bounds];

// Set padding for plot area
[graph applyTheme:[CPTTheme themeNamed:kCPTPlainWhiteTheme]];
graph.plotAreaFrame.borderLineStyle = nil;


If, like me, you are looking to not just remove the border line, but to make a plot that takes up the entire hosting view, the answer from Thomas Johannesmeyer got me on the right track.

Here's what I did:

CPTGraphHostingView* hostingView = [[CPTGraphHostingView alloc] initWithFrame: frame];
CGRect bounds = hostingView.bounds;

CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:bounds];
hostingView.hostedGraph     = graph;

graph.paddingTop    = CPTFloat(0.0);
graph.paddingRight  = CPTFloat(0.0);
graph.paddingBottom = CPTFloat(0.0);
graph.paddingLeft   = CPTFloat(0.0);

graph.plotAreaFrame.paddingTop    = CPTFloat(0.0);
graph.plotAreaFrame.paddingRight  = CPTFloat(0.0);
graph.plotAreaFrame.paddingBottom = CPTFloat(0.0);
graph.plotAreaFrame.paddingLeft   = CPTFloat(0.0);
graph.plotAreaFrame.masksToBorder = NO;

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x          = axisSet.xAxis;
x.labelingPolicy      = CPTAxisLabelingPolicyNone;
x.title = nil;
CPTXYAxis *y          = axisSet.yAxis;
y.labelingPolicy      = CPTAxisLabelingPolicyNone;
y.title = nil;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜