-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Animations
Philipp Jahoda edited this page Apr 7, 2015
·
14 revisions
All chart types support animations that can be used to create / build up the chart in an awesome looking way. Three different kinds of animation methods exist that animate either both, or x- and y-axis separately:
-
animateX(int durationMillis): Animates the charts values on the horizontal axis, meaning that the chart will build up within the specified time from left to right. -
animateY(int durationMillis): Animates the charts values on the vertical axis, meaning that the chart will build up within the specified time from bottom to top. -
animateXY(int xDuration, int yDuration): Animates both horizontal and vertical axis, resulting in a left/right bottom/top build-up.
mChart.animateX(3000); // animate horizontal 3000 milliseconds
// or:
mChart.animateY(3000); // animate vertical 3000 milliseconds
// or:
mChart.animateXY(3000, 3000); // animate horizontal and vertical 3000 millisecondsIf animate(...) (of any kind) is called, no further calling of invalidate() is necessary to refresh the chart.
Animation easing
This library allows you to apply nice easing functions to your animations. You can choose between the following predefined easing functions:
public enum EasingOption {
Linear,
EaseInQuad,
EaseOutQuad,
EaseInOutQuad,
EaseInCubic,
EaseOutCubic,
EaseInOutCubic,
EaseInQuart,
EaseOutQuart,
EaseInOutQuart,
EaseInQuint,
EaseOutQuint,
EaseInOutQuint,
EaseInSine,
EaseOutSine,
EaseInOutSine,
EaseInExpo,
EaseOutExpo,
EaseInOutExpo,
EaseInCirc,
EaseOutCirc,
EaseInOutCirc,
EaseInElastic,
EaseOutElastic,
EaseInOutElastic,
EaseInBack,
EaseOutBack,
EaseInOutBack,
EaseInBounce,
EaseOutBounce,
EaseInOutBounce,
}Call any animation method with an easing function:
// animate both axes with easing
mChart.animateXY(3000, 3000, AnimationEasing.EasingOption.EaseOutBack); You can also create your own easing functions by implementing the EasingFunction interface:
/**
* Interface for creating custom made easing functions.
*/
public static interface EasingFunction {
/**
* Called each time the animation state is updated.
*
* @param elapsed - the time that has passed so far
* @param duration - the total animation duration
* @return
*/
public float ease(long elapsed, long duration);
}