Reputation: 707
I am using core plot to draw line chart which is showing weekly details of user.
Now what I want is, to swipe next week of graph like scroll view paging functionality (we can also see it on iPhone home screen)
Please refer below image for more details.
Please share any solution or any logic to implement above task.
Upvotes: 0
Views: 838
Reputation: 1576
You can implement this by placing your graph view inside UIScrollView
and allowing horizontal scroll. You also may want to enable UIScrollView
's pagination feature to achieve "iPhone home screen"-like effect that you're describing.
This part is pretty straightforward, but you may find this StackOverflow answer useful.
However, your performance may suffer if your graph doesn't have reasonable horizontal bounds — i.e if width
of your graph is too big to render at one time. You need to test this specifically with your set of data.
If this is indeed the case, one solution is to create separate "reusable" graph views for each week (like reusable UITableViewCell
s) and render them on-the-fly when user scrolls to the left or to the right. In other words, only render current, next & previous weeks' graphs and update this each time the user flips the page.
P.S. This doesn't relate to your question directly, but you may also want to take a look at JBChartView
by Jawbone. I prefer JBChartView
over Core Plot
because it's really well-written library for creating graphs that you can dig into and customise however you want (unlike from Core Plot
which is basically "a black box").
Upvotes: 0