Coreplot on iOS - How to remove the default padding so the chart fills the view completely without axis labels
Asked Answered
T

2

5

I am trying to put 6 Coreplot charts on an iPad in landscape mode so each chart is 128pixels in height (ie. 768/6)

The issue I am having is that if I set all the padding to 0 the chart still has lots of padding around the chart being plotted.

Is there a way to remove this default padding from the chart?

Thanks in advance Damien

The pink marks in the image are the padding I want to remove

https://i.sstatic.net/nXzFv.png

or

http://s10.postimage.org/d2rl0ajsn/Image13.png


Here is the chart without the theme applied (The padding is still present) I added a pink border so you can see the actual size

Here is the chart without the theme applied (The padding is still present) I added a pink border so you can see the actual size

I also tried setting the padding to -20.0 and the same padding was present but the visible chart area was cutting the chart off.

There seems to be an outer frame which is setting this padding and holding the chart area..

Thyroxine answered 10/4, 2012 at 9:35 Comment(4)
Try by setting paddings of plotareaframe as zero.Clerc
I have already done that but that only drops the padding to about 20px graph.plotAreaFrame.paddingTop = 0.0; graph.plotAreaFrame.paddingRight = 0.0; graph.plotAreaFrame.paddingBottom = 0.0; graph.plotAreaFrame.paddingLeft = 0.0;Thyroxine
Thanks for the input Unicorn, I am a new user as I have been a read only user for quite some time so they wont let me do lots of things like post images etc so i added links to images to the original question..Thyroxine
I think the padding is due to the CPTTheme applied to your graph. Remove that code and run again.Clerc
S
8

The default padding on the graph itself (not the plot area frame) is 20 pixels on each side. You can change that, too.

graph.paddingLeft = 0.0;
graph.paddingTop = 0.0;
graph.paddingRight = 0.0;
graph.paddingBottom = 0.0;
Slavic answered 10/4, 2012 at 23:51 Comment(1)
Legend works a charm! I do not know why that was so hard to find!!Thyroxine
H
2

HINT:

Temporarily set the background color of the different views to wild colors so that you can see the affect of various padding values.

self.graph.plotAreaFrame.backgroundColor = [[UIColor yellowColor] CGColor];

self.graph.plotAreaFrame.paddingTop = 2.0f;
self.graph.plotAreaFrame.paddingRight = 8.0f;
self.graph.plotAreaFrame.paddingBottom = 30.0f;
self.graph.plotAreaFrame.paddingLeft = 42.0f;


self.graph.backgroundColor = [[UIColor greenColor] CGColor];

self.graph.paddingTop = 2.0f;
self.graph.paddingRight = 2.0f;
self.graph.paddingBottom = 2.0f;
self.graph.paddingLeft = 2.0f;

// Tie the graph we've created with the hosting view.
self.hostingView.hostedGraph = self.graph;
self.hostingView.backgroundColor = [UIColor redColor];
Homocercal answered 15/2, 2013 at 15:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.