How To Draw a Scatter Plot graph scrollable only horizontally?

329 views
Skip to first unread message

rustyshelf

unread,
May 17, 2012, 10:56:47 PM5/17/12
to coreplot-discuss
I want to draw a graph that fits in a 320x200 rectangle, but is 5000
pixels long. eg: so you can keep scrolling horizontally to see more of
it. So the Y axis fits fine in 200 pixels, and I don't want that to be
scrollable, I just want the user to be able to scroll horizontally. I
also want to disable zooming.

The first thing I tried was creating a graph view that is 5000,200 and
putting it in a UIScrollView that has it's content size set to that,
but it's display size set to 320,200. I also turned user interaction
off on the graph. This gives me the exact effect I want, but the
performance is a bit cruddy with a view that long on an iPhone. What I
really want to know is does core-plot already support that, and if so
what am I missing? I've dug around the documentation and played with
various properties, but I can't figure out how to get the desired
effect.

Drew McCormack

unread,
May 18, 2012, 10:17:08 AM5/18/12
to coreplot...@googlegroups.com
Check out the CPTTestApp. It uses the built in scrolling.
Basically, you set the userInteractionAllowed property to YES on the graph.
Then, you make sure you set the appropriate globalRangeX and globalRangeY values on the plotRange, which will limit how far the user can scroll.

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.
>

rustyshelf

unread,
May 18, 2012, 9:15:00 PM5/18/12
to coreplot...@googlegroups.com
That works great, thanks. So final question, is there any easy way to disable zooming of the chart, or do I have to go in and change some of the source code to turn it off?


On Friday, May 18, 2012 11:47:08 PM UTC+9:30, Drew McCormack wrote:
Check out the CPTTestApp. It uses the built in scrolling.
Basically, you set the userInteractionAllowed property to YES on the graph.
Then, you make sure you set the appropriate globalRangeX and globalRangeY values on the plotRange, which will limit how far the user can scroll.

Drew

On 18/05/2012, at 4:56 AM, rustyshelf wrote:

> I want to draw a graph that fits in a 320x200 rectangle, but is 5000
> pixels long. eg: so you can keep scrolling horizontally to see more of
> it. So the Y axis fits fine in 200 pixels, and I don't want that to be
> scrollable, I just want the user to be able to scroll horizontally. I
> also want to disable zooming.
>
> The first thing I tried was creating a graph view that is 5000,200 and
> putting it in a UIScrollView that has it's content size set to that,
> but it's display size set to 320,200. I also turned user interaction
> off on the graph. This gives me the exact effect I want, but the
> performance is a bit cruddy with a view that long on an iPhone. What I
> really want to know is does core-plot already support that, and if so
> what am I missing? I've dug around the documentation and played with
> various properties, but I can't figure out how to get the desired
> effect.
>
> --
> You received this message because you are subscribed to the Google Groups "coreplot-discuss" group.
> To post to this group, send email to coreplot-discuss@googlegroups.com.
> To unsubscribe from this group, send email to coreplot-discuss+unsubscribe@googlegroups.com.

rustyshelf

unread,
May 18, 2012, 9:35:15 PM5/18/12
to coreplot...@googlegroups.com
My apologies, completely missed:
hostingView.allowPinchScaling = NO;

Problem solved, thanks and cudos to the developers of such a great graphing library :) 
Reply all
Reply to author
Forward
0 new messages