I implemented corePlot
in my xcode
project. I'm trying to "explode" a slice of the pie chart with animation. Here is the method I'm using:
- (void)radialOffsetForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)idx
{
if (myIndex == idx) {
return 20;
}
return 0;
}
I have another method which calls [pieChart reloadRadialOffset];
.
For example:
- (void)thisMethod {
[pieChart reloadRadialOffset];
}
How can I animate the reloadRadialOffsets
?
In your question is bit confusing. Your question title says "how to reaptedly call a mathod using timer" and at the end of your question it changes to "How can I animate the reloadRadialOffsets?".
For repeatedly calling a method you can use any of the following options
option 1.
option 2:
[self performSelector:@seletor(animatePie) withObject:nil afterDelay:1.0];
and in your method
Here the repeated method will be called agian with a delay once the animation is complete.
When you wanted to stop the animation call
When timer is used it will be fired once the interval is elapsed.
For animation
You can use
or user
You can use below code. In this UIViewAnimationOptionRepeat is helpful for repeat animation what you want to achieve..
//Still you want to call method using timer
Hope it helps you...!
I just added an example to the "Simple Pie Chart" demo in the Plot Gallery example app. I added two properties to the controller to hold the index of the selected slice and the desired offset value. Since the offset is a
CGFloat
it is easily animated using Core Animation orCPTAnimation
.Set the index to
NSNotFound
to indicate that no slice should be selected. You could also use an array or set of indices if you want to highlight more than one slice at a time.Trigger the animation to offset the slice:
The plot datasource needs the radial offset method:
The
sliceOffset
property needs a custom setter to trigger the plot to update the offsets during the animation: