Problems changing CPXYGraph.paddingBottom dynamically

68 views
Skip to first unread message

Peter B

unread,
Nov 2, 2010, 10:13:23 AM11/2/10
to coreplot-discuss
Hi,

First time posting on Google Groups, so apologies if this is in the
wrong group.

I'm loving CorePlot and have _almost_ got it doing what I need for my
iPhone app.

My app allows the graph data to be manually edited (in another view),
which requires me to resize the graph when it next displays.

My problem is that the x axis labelling and tickmarks go below the
graph (in paddingBottom) if the minumum y value is 0, but they appear
on the graph if the minimum y value is negative. (In my case the min y
will never be positive)

In viewWillAppear I calculate the range from the data and reset the y
axis range (setting the yRange property of the defaultPlotSpace). I
also call [myCPXYGraph reloadData].

Both these together work fine and the graph is re-scaled and
displayed.

Then I try and set the bottomPadding to (say) 80 or 5 depending on
whether the x labels will be plotted below the graph or on it, it all
goes to hell.

Basically the scales show up right, but with extra space in the graph
area above the top of the y scale and tickmarks. Or moving the other
way, the graph draws out the top of the screen.

It looks like I haven't understood the relationship between axes and
plotSpaces, or something.

Is there something I can flush or recalculate? Or do I have to
recreate a new graph entirely each time the screen is refreshed?

I can send screenshots / more code if necessary, but it basically
boils down to the fact that if I change the padding after the graph
has first been drawn then it sort of half updates the rest of the
objects within the graph.....

Thanks very a great bit of software. I appreciate the complexity of
what you folks are trying to do with this. I've tried a lot of things
to fix this in the last few days and will continue in the meantime.

Best wishes

Peter

Drew McCormack

unread,
Nov 2, 2010, 10:23:05 AM11/2/10
to coreplot...@googlegroups.com
Hi Peter,

A couple of things: You might be better off with a floating axis, if your axes are moving around too much. A floating axis doesn't cross at a fixed value, but is positioned relative to the whole view. See CPTestApp for an example.

If you are sticking with your current system, it seems you might be setting the padding on the wrong layer. You can try the graph layer, but also the plotAreaFrame layer. It definitely should be possible to make it work.

Drew

> --
> You received this message because you are subscribed to the Google Groups "coreplot-discuss" group.
> To post to this group, send email to coreplot...@googlegroups.com.
> To unsubscribe from this group, send email to coreplot-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/coreplot-discuss?hl=en.
>

Peter B

unread,
Nov 2, 2010, 2:09:17 PM11/2/10
to coreplot-discuss
Hi Drew,

Thanks v much for the quick and helpful reply. I've had a quick go
with the floating axes and think that for what I'm doing I need to
keep the x axis crossing at zero, so I think I need to go with the
second solution.

My first attempts to change the bottom padding on the plotAreaFrame
layer produced a similar problem, but with the extra unwanted space
now appearing within the plot layer! I'll keep tinkering - you've
given me some new avenues to try. If I can't get any further I'll code
up a quick minimal demo of the problem - as it's always easier to get
to the bottom of these things with a minimum test case.

Thanks again for taking the time to respond. The good thing is that in
trying to work this out I've learned a lot more about CorePlot and
found a few features I didn't know it had - so it's all good stuff.

Cheers

Peter

Eric

unread,
Nov 2, 2010, 7:22:27 PM11/2/10
to coreplot-discuss
There have been several similar threads about this recently. Here's
the most recent one: http://groups.google.com/group/coreplot-discuss/browse_thread/thread/3d4f05ace3c07e48#

Eric

Peter B

unread,
Nov 5, 2010, 6:18:00 AM11/5/10
to coreplot-discuss
Hi Eric,

Thanks for the reply. Looking through the posts you linked I couldn't
find a solution that worked for me. I'm sure that the answer will be
somewhere in the order in which views are updated or my having missed
a the right view to alter. Due to time pressure I've solved it by
destroying the graph and recreating it completely in viewWillAppear().
As the graphs are not complex there is no appreciable penalty (except
for a lingering feeling of guilt over the inelegance of my code ;-)

When I next use CorePlot I'll put in the time to really get to
understand how the sizing of views cascades and how to do this
'properly'....

Thanks again for the reply, and for the great software.

Best wishes

Peter

Eric

unread,
Dec 10, 2010, 7:55:31 PM12/10/10
to coreplot-discuss
Where are you setting the padding? You'll get different results
depending on which layer gets the padding.

Can you post the relevant code and/or a picture?

Eric
Reply all
Reply to author
Forward
0 new messages