refactor(EasingFunction): Simplified EasingFunction
EasingFunction has been simplified greatly, and I've added a MUCH needed annotation to relevant methods. Easing.EasingOptions has been deprecated, as well as any methods using them. Converting is as simple as deleting the "EasingOptions" part. A new signature is available for animateXY()! You are now able to pass one EasingFunction to animateXY() if you want both axes to be animated the same way. Quietly included are some gradle build updates, incrementing the appcompat version to 27.1.1, and using the new `javacompiler` to avoid deprecation of `javacompile`
This commit is contained in:
parent
89d18a7f67
commit
35c9fc937e
19 changed files with 532 additions and 829 deletions
|
@ -59,7 +59,7 @@ dependencies {
|
|||
implementation 'com.github.PhilJay:MPAndroidChart-Realm:v2.0.2@aar'
|
||||
|
||||
implementation project(':MPChartLib')
|
||||
implementation 'com.android.support:appcompat-v7:27.0.2'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
//compile 'io.realm:realm-android:0.87.5' // dependency for realm-database API (http://realm.io)
|
||||
//compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class HalfPieChartActivity extends DemoBase {
|
|||
|
||||
setData(4, 100);
|
||||
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuad);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
|
||||
|
|
|
@ -302,7 +302,7 @@ public class LineChartActivity1 extends DemoBase implements OnSeekBarChangeListe
|
|||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000, Easing.EasingOption.EaseInCubic);
|
||||
mChart.animateY(3000, Easing.EaseInCubic);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
|
|
@ -90,7 +90,7 @@ public class PieChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
|
||||
setData(4, 100);
|
||||
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuad);
|
||||
// mChart.spin(2000, 0, 360);
|
||||
|
||||
mSeekBarX.setOnSeekBarChangeListener(this);
|
||||
|
@ -179,8 +179,7 @@ public class PieChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
break;
|
||||
}
|
||||
case R.id.actionToggleSpin: {
|
||||
mChart.spin(1000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360, Easing.EasingOption
|
||||
.EaseInCubic);
|
||||
mChart.spin(1000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360, Easing.EaseInCubic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class PiePolylineChartActivity extends DemoBase implements OnSeekBarChang
|
|||
private PieChart mChart;
|
||||
private SeekBar mSeekBarX, mSeekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
|
||||
private Typeface tf;
|
||||
|
||||
@Override
|
||||
|
@ -97,7 +97,7 @@ public class PiePolylineChartActivity extends DemoBase implements OnSeekBarChang
|
|||
|
||||
setData(4, 100);
|
||||
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuad);
|
||||
// mChart.spin(2000, 0, 360);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
|
|
|
@ -62,10 +62,7 @@ public class RadarChartActivity extends DemoBase {
|
|||
|
||||
setData();
|
||||
|
||||
mChart.animateXY(
|
||||
1400, 1400,
|
||||
Easing.EasingOption.EaseInOutQuad,
|
||||
Easing.EasingOption.EaseInOutQuad);
|
||||
mChart.animateXY(1400, 1400, Easing.EaseInOutQuad);
|
||||
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setTypeface(mTfLight);
|
||||
|
@ -193,8 +190,7 @@ public class RadarChartActivity extends DemoBase {
|
|||
break;
|
||||
}
|
||||
case R.id.actionToggleSpin: {
|
||||
mChart.spin(2000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360, Easing.EasingOption
|
||||
.EaseInCubic);
|
||||
mChart.spin(2000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360, Easing.EaseInCubic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,6 @@ public class RealmDatabaseActivityBar extends RealmBaseActivity {
|
|||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.setFitBars(true);
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,6 @@ public class RealmDatabaseActivityBubble extends RealmBaseActivity {
|
|||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,6 @@ public class RealmDatabaseActivityCandle extends RealmBaseActivity {
|
|||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,6 @@ public class RealmDatabaseActivityHorizontalBar extends RealmBaseActivity {
|
|||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,6 @@ public class RealmDatabaseActivityLine extends RealmBaseActivity {
|
|||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,6 @@ public class RealmDatabaseActivityScatter extends RealmBaseActivity {
|
|||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
|
||||
// set data
|
||||
lineChart.setData(lineData);
|
||||
lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
lineChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
|
||||
|
||||
// BAR-CHART
|
||||
|
@ -128,6 +128,6 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
|
||||
barChart.setData(barData);
|
||||
barChart.setFitBars(true);
|
||||
barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
|
||||
barChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ android {
|
|||
buildToolsVersion '27.0.3'
|
||||
// resourcePrefix 'mpcht'
|
||||
defaultConfig {
|
||||
//noinspection MinSdkTooLow
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 27
|
||||
versionCode 3
|
||||
|
@ -35,6 +36,7 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
//provided 'io.realm:realm-android:0.87.5' // "optional" dependency to realm-database API
|
||||
implementation 'com.android.support:support-annotations:27.1.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation "org.mockito:mockito-core:1.10.19"
|
||||
}
|
||||
|
@ -42,9 +44,9 @@ dependencies {
|
|||
android.libraryVariants.all { variant ->
|
||||
def name = variant.buildType.name
|
||||
def task = project.tasks.create "jar${name.capitalize()}", Jar
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
artifacts.add('archives', task);
|
||||
task.dependsOn variant.javaCompiler
|
||||
task.from variant.javaCompiler.destinationDir
|
||||
artifacts.add('archives', task)
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
|
|
|
@ -3,135 +3,178 @@ package com.github.mikephil.charting.animation;
|
|||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing.EasingFunction;
|
||||
|
||||
/**
|
||||
* Object responsible for all animations in the Chart. ANIMATIONS ONLY WORK FOR
|
||||
* API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
||||
*
|
||||
* Object responsible for all animations in the Chart. Animations require API level 11.
|
||||
*
|
||||
* @author Philipp Jahoda
|
||||
* @author Mick Ashton
|
||||
*/
|
||||
public class ChartAnimator {
|
||||
|
||||
/** object that is updated upon animation update */
|
||||
private AnimatorUpdateListener mListener;
|
||||
|
||||
public ChartAnimator() {
|
||||
/** The phase of drawn values on the y-axis. 0 - 1 */
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected float mPhaseY = 1f;
|
||||
|
||||
}
|
||||
/** The phase of drawn values on the x-axis. 0 - 1 */
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected float mPhaseX = 1f;
|
||||
|
||||
public ChartAnimator() { }
|
||||
|
||||
@RequiresApi(11)
|
||||
public ChartAnimator(AnimatorUpdateListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* ################ ################ ################ ################
|
||||
*/
|
||||
/** CODE BELOW THIS RELATED TO ANIMATION */
|
||||
|
||||
/** the phase that is animated and influences the drawn values on the y-axis */
|
||||
protected float mPhaseY = 1f;
|
||||
|
||||
/** the phase that is animated and influences the drawn values on the x-axis */
|
||||
protected float mPhaseX = 1f;
|
||||
|
||||
/**
|
||||
* ################ ################ ################ ################
|
||||
*/
|
||||
/** METHODS FOR CUSTOM EASING */
|
||||
|
||||
/**
|
||||
* Animates the drawing / rendering of the chart on both x- and y-axis with
|
||||
* the specified animation time. If animate(...) is called, no further
|
||||
* calling of invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillisX
|
||||
* @param durationMillisY
|
||||
* @param easingX
|
||||
* @param easingY
|
||||
*/
|
||||
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easingX,
|
||||
EasingFunction easingY) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
|
||||
ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
|
||||
animatorY.setInterpolator(easingY);
|
||||
animatorY.setDuration(
|
||||
durationMillisY);
|
||||
ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
|
||||
animatorX.setInterpolator(easingX);
|
||||
animatorX.setDuration(
|
||||
durationMillisX);
|
||||
|
||||
// make sure only one animator produces update-callbacks (which then
|
||||
// call invalidate())
|
||||
if (durationMillisX > durationMillisY) {
|
||||
animatorX.addUpdateListener(mListener);
|
||||
} else {
|
||||
animatorY.addUpdateListener(mListener);
|
||||
}
|
||||
|
||||
animatorX.start();
|
||||
animatorY.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the rendering of the chart on the x-axis with the specified
|
||||
* animation time. If animate(...) is called, no further calling of
|
||||
* invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillis
|
||||
* @param easing
|
||||
*/
|
||||
public void animateX(int durationMillis, EasingFunction easing) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
@RequiresApi(11)
|
||||
private ObjectAnimator xAnimator(int duration, EasingFunction easing) {
|
||||
|
||||
ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
|
||||
animatorX.setInterpolator(easing);
|
||||
animatorX.setDuration(durationMillis);
|
||||
animatorX.setDuration(duration);
|
||||
|
||||
return animatorX;
|
||||
}
|
||||
|
||||
@RequiresApi(11)
|
||||
private ObjectAnimator yAnimator(int duration, EasingFunction easing) {
|
||||
|
||||
ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
|
||||
animatorY.setInterpolator(easing);
|
||||
animatorY.setDuration(duration);
|
||||
|
||||
return animatorY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates values along the X axis, in a linear fashion.
|
||||
*
|
||||
* @param durationMillis animation duration
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateX(int durationMillis) {
|
||||
animateX(durationMillis, Easing.Linear);
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates values along the X axis.
|
||||
*
|
||||
* @param durationMillis animation duration
|
||||
* @param easing EasingFunction
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateX(int durationMillis, EasingFunction easing) {
|
||||
|
||||
ObjectAnimator animatorX = xAnimator(durationMillis, easing);
|
||||
animatorX.addUpdateListener(mListener);
|
||||
animatorX.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the rendering of the chart on the y-axis with the specified
|
||||
* animation time. If animate(...) is called, no further calling of
|
||||
* invalidate() is necessary to refresh the chart.
|
||||
* Animates values along both the X and Y axes, in a linear fashion.
|
||||
*
|
||||
* @param durationMillis
|
||||
* @param easing
|
||||
* @param durationMillisX animation duration along the X axis
|
||||
* @param durationMillisY animation duration along the Y axis
|
||||
*/
|
||||
public void animateY(int durationMillis, EasingFunction easing) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
|
||||
ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
|
||||
animatorY.setInterpolator(easing);
|
||||
animatorY.setDuration(durationMillis);
|
||||
animatorY.addUpdateListener(mListener);
|
||||
animatorY.start();
|
||||
@RequiresApi(11)
|
||||
public void animateXY(int durationMillisX, int durationMillisY) {
|
||||
animateXY(durationMillisX, durationMillisY, Easing.Linear, Easing.Linear);
|
||||
}
|
||||
|
||||
/**
|
||||
* ################ ################ ################ ################
|
||||
* Animates values along both the X and Y axes.
|
||||
*
|
||||
* @param durationMillisX animation duration along the X axis
|
||||
* @param durationMillisY animation duration along the Y axis
|
||||
* @param easing EasingFunction for both axes
|
||||
*/
|
||||
/** METHODS FOR PREDEFINED EASING */
|
||||
@RequiresApi(11)
|
||||
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easing) {
|
||||
|
||||
ObjectAnimator xAnimator = xAnimator(durationMillisX, easing);
|
||||
ObjectAnimator yAnimator = yAnimator(durationMillisY, easing);
|
||||
|
||||
if (durationMillisX > durationMillisY) {
|
||||
xAnimator.addUpdateListener(mListener);
|
||||
} else {
|
||||
yAnimator.addUpdateListener(mListener);
|
||||
}
|
||||
|
||||
xAnimator.start();
|
||||
yAnimator.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates values along both the X and Y axes.
|
||||
*
|
||||
* @param durationMillisX animation duration along the X axis
|
||||
* @param durationMillisY animation duration along the Y axis
|
||||
* @param easingX EasingFunction for the X axis
|
||||
* @param easingY EasingFunction for the Y axis
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easingX,
|
||||
EasingFunction easingY) {
|
||||
|
||||
ObjectAnimator xAnimator = xAnimator(durationMillisX, easingX);
|
||||
ObjectAnimator yAnimator = yAnimator(durationMillisY, easingY);
|
||||
|
||||
if (durationMillisX > durationMillisY) {
|
||||
xAnimator.addUpdateListener(mListener);
|
||||
} else {
|
||||
yAnimator.addUpdateListener(mListener);
|
||||
}
|
||||
|
||||
xAnimator.start();
|
||||
yAnimator.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates values along the Y axis, in a linear fashion.
|
||||
*
|
||||
* @param durationMillis animation duration
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateY(int durationMillis) {
|
||||
animateY(durationMillis, Easing.Linear);
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates values along the Y axis.
|
||||
*
|
||||
* @param durationMillis animation duration
|
||||
* @param easing EasingFunction
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateY(int durationMillis, EasingFunction easing) {
|
||||
|
||||
ObjectAnimator animatorY = yAnimator(durationMillis, easing);
|
||||
animatorY.addUpdateListener(mListener);
|
||||
animatorY.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the drawing / rendering of the chart on both x- and y-axis with
|
||||
* the specified animation time. If animate(...) is called, no further
|
||||
* calling of invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillisX
|
||||
* @param durationMillisY
|
||||
* @param easingX
|
||||
* @param easingY
|
||||
* @param durationMillisX animation duration along the X axis
|
||||
* @param durationMillisY animation duration along the Y axis
|
||||
* @param easingX EasingFunction for the X axis
|
||||
* @param easingY EasingFunction for the Y axis
|
||||
*
|
||||
* @deprecated Use {@link #animateXY(int, int, EasingFunction, EasingFunction)}
|
||||
* @see #animateXY(int, int, EasingFunction, EasingFunction)
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public void animateXY(int durationMillisX, int durationMillisY, Easing.EasingOption easingX,
|
||||
Easing.EasingOption easingY) {
|
||||
|
||||
|
@ -164,9 +207,14 @@ public class ChartAnimator {
|
|||
* animation time. If animate(...) is called, no further calling of
|
||||
* invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillis
|
||||
* @param easing
|
||||
* @param durationMillis animation duration
|
||||
* @param easing EasingFunction
|
||||
*
|
||||
* @deprecated Use {@link #animateX(int, EasingFunction)}
|
||||
* @see #animateX(int, EasingFunction)
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public void animateX(int durationMillis, Easing.EasingOption easing) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
|
@ -184,9 +232,14 @@ public class ChartAnimator {
|
|||
* animation time. If animate(...) is called, no further calling of
|
||||
* invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillis
|
||||
* @param easing
|
||||
* @param durationMillis animation duration
|
||||
* @param easing EasingFunction
|
||||
*
|
||||
* @deprecated Use {@link #animateY(int, EasingFunction)}
|
||||
* @see #animateY(int, EasingFunction)
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public void animateY(int durationMillis, Easing.EasingOption easing) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
|
@ -200,111 +253,48 @@ public class ChartAnimator {
|
|||
}
|
||||
|
||||
/**
|
||||
* ################ ################ ################ ################
|
||||
*/
|
||||
/** METHODS FOR ANIMATION WITHOUT EASING */
|
||||
|
||||
/**
|
||||
* Animates the drawing / rendering of the chart on both x- and y-axis with
|
||||
* the specified animation time. If animate(...) is called, no further
|
||||
* calling of invalidate() is necessary to refresh the chart.
|
||||
* Gets the Y axis phase of the animation.
|
||||
*
|
||||
* @param durationMillisX
|
||||
* @param durationMillisY
|
||||
*/
|
||||
public void animateXY(int durationMillisX, int durationMillisY) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
|
||||
ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
|
||||
animatorY.setDuration(
|
||||
durationMillisY);
|
||||
ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
|
||||
animatorX.setDuration(
|
||||
durationMillisX);
|
||||
|
||||
// make sure only one animator produces update-callbacks (which then
|
||||
// call invalidate())
|
||||
if (durationMillisX > durationMillisY) {
|
||||
animatorX.addUpdateListener(mListener);
|
||||
} else {
|
||||
animatorY.addUpdateListener(mListener);
|
||||
}
|
||||
|
||||
animatorX.start();
|
||||
animatorY.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the rendering of the chart on the x-axis with the specified
|
||||
* animation time. If animate(...) is called, no further calling of
|
||||
* invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillis
|
||||
*/
|
||||
public void animateX(int durationMillis) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
|
||||
ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
|
||||
animatorX.setDuration(durationMillis);
|
||||
animatorX.addUpdateListener(mListener);
|
||||
animatorX.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the rendering of the chart on the y-axis with the specified
|
||||
* animation time. If animate(...) is called, no further calling of
|
||||
* invalidate() is necessary to refresh the chart.
|
||||
*
|
||||
* @param durationMillis
|
||||
*/
|
||||
public void animateY(int durationMillis) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
|
||||
ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
|
||||
animatorY.setDuration(durationMillis);
|
||||
animatorY.addUpdateListener(mListener);
|
||||
animatorY.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the y-phase that is used to animate the values.
|
||||
*
|
||||
* @return
|
||||
* @return float value of {@link #mPhaseY}
|
||||
*/
|
||||
public float getPhaseY() {
|
||||
return mPhaseY;
|
||||
}
|
||||
|
||||
/**
|
||||
* This modifys the y-phase that is used to animate the values.
|
||||
* Sets the Y axis phase of the animation.
|
||||
*
|
||||
* @param phase
|
||||
* @param phase float value between 0 - 1
|
||||
*/
|
||||
public void setPhaseY(float phase) {
|
||||
if (phase > 1f) {
|
||||
phase = 1f;
|
||||
} else if (phase < 0f) {
|
||||
phase = 0f;
|
||||
}
|
||||
mPhaseY = phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the x-phase that is used to animate the values.
|
||||
* Gets the X axis phase of the animation.
|
||||
*
|
||||
* @return
|
||||
* @return float value of {@link #mPhaseX}
|
||||
*/
|
||||
public float getPhaseX() {
|
||||
return mPhaseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* This modifys the x-phase that is used to animate the values.
|
||||
* Sets the X axis phase of the animation.
|
||||
*
|
||||
* @param phase
|
||||
* @param phase float value between 0 - 1
|
||||
*/
|
||||
public void setPhaseX(float phase) {
|
||||
if (phase > 1f) {
|
||||
phase = 1f;
|
||||
} else if (phase < 0f) {
|
||||
phase = 0f;
|
||||
}
|
||||
mPhaseX = phase;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,30 @@
|
|||
|
||||
package com.github.mikephil.charting.animation;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
/**
|
||||
* Easing options.
|
||||
*
|
||||
*
|
||||
* @author Daniel Cohen Gindi
|
||||
* @author Mick Ashton
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@RequiresApi(11)
|
||||
public class Easing {
|
||||
|
||||
public interface EasingFunction extends TimeInterpolator {
|
||||
@Override
|
||||
float getInterpolation(float input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use EasingOption instead of EasingFunction to avoid crashes below Android
|
||||
* 3.0
|
||||
* Enum holding EasingOption constants
|
||||
*
|
||||
* @deprecated Use Easing.Linear instead of Easing.EasingOption.Linear
|
||||
*/
|
||||
@Deprecated
|
||||
public enum EasingOption {
|
||||
Linear,
|
||||
EaseInQuad,
|
||||
|
@ -43,679 +56,362 @@ public class Easing {
|
|||
EaseInOutBounce,
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the EasingFunction of the given EasingOption
|
||||
*
|
||||
* @param easing EasingOption to get
|
||||
* @return EasingFunction
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public static EasingFunction getEasingFunctionFromOption(EasingOption easing) {
|
||||
switch (easing) {
|
||||
default:
|
||||
case Linear:
|
||||
return Easing.EasingFunctions.Linear;
|
||||
return Easing.Linear;
|
||||
case EaseInQuad:
|
||||
return Easing.EasingFunctions.EaseInQuad;
|
||||
return Easing.EaseInQuad;
|
||||
case EaseOutQuad:
|
||||
return Easing.EasingFunctions.EaseOutQuad;
|
||||
return Easing.EaseOutQuad;
|
||||
case EaseInOutQuad:
|
||||
return Easing.EasingFunctions.EaseInOutQuad;
|
||||
return Easing.EaseInOutQuad;
|
||||
case EaseInCubic:
|
||||
return Easing.EasingFunctions.EaseInCubic;
|
||||
return Easing.EaseInCubic;
|
||||
case EaseOutCubic:
|
||||
return Easing.EasingFunctions.EaseOutCubic;
|
||||
return Easing.EaseOutCubic;
|
||||
case EaseInOutCubic:
|
||||
return Easing.EasingFunctions.EaseInOutCubic;
|
||||
return Easing.EaseInOutCubic;
|
||||
case EaseInQuart:
|
||||
return Easing.EasingFunctions.EaseInQuart;
|
||||
return Easing.EaseInQuart;
|
||||
case EaseOutQuart:
|
||||
return Easing.EasingFunctions.EaseOutQuart;
|
||||
return Easing.EaseOutQuart;
|
||||
case EaseInOutQuart:
|
||||
return Easing.EasingFunctions.EaseInOutQuart;
|
||||
return Easing.EaseInOutQuart;
|
||||
case EaseInSine:
|
||||
return Easing.EasingFunctions.EaseInSine;
|
||||
return Easing.EaseInSine;
|
||||
case EaseOutSine:
|
||||
return Easing.EasingFunctions.EaseOutSine;
|
||||
return Easing.EaseOutSine;
|
||||
case EaseInOutSine:
|
||||
return Easing.EasingFunctions.EaseInOutSine;
|
||||
return Easing.EaseInOutSine;
|
||||
case EaseInExpo:
|
||||
return Easing.EasingFunctions.EaseInExpo;
|
||||
return Easing.EaseInExpo;
|
||||
case EaseOutExpo:
|
||||
return Easing.EasingFunctions.EaseOutExpo;
|
||||
return Easing.EaseOutExpo;
|
||||
case EaseInOutExpo:
|
||||
return Easing.EasingFunctions.EaseInOutExpo;
|
||||
return Easing.EaseInOutExpo;
|
||||
case EaseInCirc:
|
||||
return Easing.EasingFunctions.EaseInCirc;
|
||||
return Easing.EaseInCirc;
|
||||
case EaseOutCirc:
|
||||
return Easing.EasingFunctions.EaseOutCirc;
|
||||
return Easing.EaseOutCirc;
|
||||
case EaseInOutCirc:
|
||||
return Easing.EasingFunctions.EaseInOutCirc;
|
||||
return Easing.EaseInOutCirc;
|
||||
case EaseInElastic:
|
||||
return Easing.EasingFunctions.EaseInElastic;
|
||||
return Easing.EaseInElastic;
|
||||
case EaseOutElastic:
|
||||
return Easing.EasingFunctions.EaseOutElastic;
|
||||
return Easing.EaseOutElastic;
|
||||
case EaseInOutElastic:
|
||||
return Easing.EasingFunctions.EaseInOutElastic;
|
||||
return Easing.EaseInOutElastic;
|
||||
case EaseInBack:
|
||||
return Easing.EasingFunctions.EaseInBack;
|
||||
return Easing.EaseInBack;
|
||||
case EaseOutBack:
|
||||
return Easing.EasingFunctions.EaseOutBack;
|
||||
return Easing.EaseOutBack;
|
||||
case EaseInOutBack:
|
||||
return Easing.EasingFunctions.EaseInOutBack;
|
||||
return Easing.EaseInOutBack;
|
||||
case EaseInBounce:
|
||||
return Easing.EasingFunctions.EaseInBounce;
|
||||
return Easing.EaseInBounce;
|
||||
case EaseOutBounce:
|
||||
return Easing.EasingFunctions.EaseOutBounce;
|
||||
return Easing.EaseOutBounce;
|
||||
case EaseInOutBounce:
|
||||
return Easing.EasingFunctions.EaseInOutBounce;
|
||||
return Easing.EaseInOutBounce;
|
||||
}
|
||||
}
|
||||
|
||||
private static class EasingFunctions {
|
||||
|
||||
/**
|
||||
* ########## ########## ########## ########## ########## ##########
|
||||
* PREDEFINED EASING FUNCTIONS BELOW THIS
|
||||
*/
|
||||
|
||||
public static final EasingFunction Linear = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// return elapsed / (float) duration;
|
||||
// }
|
||||
private static final float DOUBLE_PI = 2f * (float) Math.PI;
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return input;
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction Linear = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInQuad = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return input * input;
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutQuad = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return -input * (input - 2f);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutQuad = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input *= 2f;
|
||||
|
||||
if (input < 1f) {
|
||||
return 0.5f * input * input;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInQuad = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return position * position;
|
||||
// }
|
||||
return -0.5f * ((--input) * (input - 2f) - 1f);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return input * input;
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInCubic = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return (float) Math.pow(input, 3);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutCubic = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input--;
|
||||
return (float) Math.pow(input, 3) + 1f;
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutCubic = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input *= 2f;
|
||||
if (input < 1f) {
|
||||
return 0.5f * (float) Math.pow(input, 3);
|
||||
}
|
||||
};
|
||||
input -= 2f;
|
||||
return 0.5f * ((float) Math.pow(input, 3) + 2f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutQuad = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return -position * (position - 2.f);
|
||||
// }
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInQuart = new EasingFunction() {
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return -input * (input - 2f);
|
||||
public float getInterpolation(float input) {
|
||||
return (float) Math.pow(input, 4);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutQuart = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input--;
|
||||
return -((float) Math.pow(input, 4) - 1f);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutQuart = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input *= 2f;
|
||||
if (input < 1f) {
|
||||
return 0.5f * (float) Math.pow(input, 4);
|
||||
}
|
||||
};
|
||||
input -= 2f;
|
||||
return -0.5f * ((float) Math.pow(input, 4) - 2f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutQuad = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (duration / 2.f);
|
||||
// if (position < 1.f)
|
||||
// {
|
||||
// return 0.5f * position * position;
|
||||
// }
|
||||
// return -0.5f * ((--position) * (position - 2.f) - 1.f);
|
||||
// }
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInSine = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return -(float) Math.cos(input * (Math.PI / 2f)) + 1f;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutSine = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return (float) Math.sin(input * (Math.PI / 2f));
|
||||
}
|
||||
};
|
||||
|
||||
float position = input / 0.5f;
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutSine = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return -0.5f * ((float) Math.cos(Math.PI * input) - 1f);
|
||||
}
|
||||
};
|
||||
|
||||
if (position < 1.f) {
|
||||
return 0.5f * position * position;
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInExpo = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return (input == 0) ? 0f : (float) Math.pow(2f, 10f * (input - 1f));
|
||||
}
|
||||
};
|
||||
|
||||
return -0.5f * ((--position) * (position - 2.f) - 1.f);
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutExpo = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return (input == 1f) ? 1f : (-(float) Math.pow(2f, -10f * (input + 1f)));
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutExpo = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0) {
|
||||
return 0f;
|
||||
} else if (input == 1f) {
|
||||
return 1f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInCubic = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return position * position * position;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return input * input * input;
|
||||
input *= 2f;
|
||||
if (input < 1f) {
|
||||
return 0.5f * (float) Math.pow(2f, 10f * (input - 1f));
|
||||
}
|
||||
};
|
||||
return 0.5f * (-(float) Math.pow(2f, -10f * --input) + 2f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutCubic = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// position--;
|
||||
// return (position * position * position + 1.f);
|
||||
// }
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInCirc = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return -((float) Math.sqrt(1f - input * input) - 1f);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
input--;
|
||||
return (input * input * input + 1.f);
|
||||
}
|
||||
};
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutCirc = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input--;
|
||||
return (float) Math.sqrt(1f - input * input);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutCubic = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (duration / 2.f);
|
||||
// if (position < 1.f)
|
||||
// {
|
||||
// return 0.5f * position * position * position;
|
||||
// }
|
||||
// position -= 2.f;
|
||||
// return 0.5f * (position * position * position + 2.f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
|
||||
float position = input / 0.5f;
|
||||
if (position < 1.f) {
|
||||
return 0.5f * position * position * position;
|
||||
}
|
||||
position -= 2.f;
|
||||
return 0.5f * (position * position * position + 2.f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInQuart = new EasingFunction() {
|
||||
|
||||
public float getInterpolation(float input) {
|
||||
return input * input * input * input;
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutCirc = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
input *= 2f;
|
||||
if (input < 1f) {
|
||||
return -0.5f * ((float) Math.sqrt(1f - input * input) - 1f);
|
||||
}
|
||||
};
|
||||
return 0.5f * ((float) Math.sqrt(1f - (input -= 2f) * input) + 1f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutQuart = new EasingFunction() {
|
||||
|
||||
public float getInterpolation(float input) {
|
||||
input--;
|
||||
return -(input * input * input * input - 1f);
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInElastic = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0) {
|
||||
return 0f;
|
||||
} else if (input == 1) {
|
||||
return 1f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutQuart = new
|
||||
EasingFunction() {
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
float position = input / 0.5f;
|
||||
if (position < 1.f) {
|
||||
return 0.5f * position * position * position * position;
|
||||
}
|
||||
position -= 2.f;
|
||||
return -0.5f * (position * position * position * position - 2.f);
|
||||
}
|
||||
};
|
||||
float p = 0.3f;
|
||||
float s = p / DOUBLE_PI * (float) Math.asin(1f);
|
||||
return -((float) Math.pow(2f, 10f * (input -= 1f))
|
||||
*(float) Math.sin((input - s) * DOUBLE_PI / p));
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInSine = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return -(float) Math.cos(position * (Math.PI / 2.f)) + 1.f;
|
||||
// }
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return -(float) Math.cos(input * (Math.PI / 2.f)) + 1.f;
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutElastic = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0) {
|
||||
return 0f;
|
||||
} else if (input == 1) {
|
||||
return 1f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutSine = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return (float) Math.sin(position * (Math.PI / 2.f));
|
||||
// }
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return (float) Math.sin(input * (Math.PI / 2.f));
|
||||
float p = 0.3f;
|
||||
float s = p / DOUBLE_PI * (float) Math.asin(1f);
|
||||
return 1f
|
||||
+ (float) Math.pow(2f, -10f * input)
|
||||
* (float) Math.sin((input - s) * DOUBLE_PI / p);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutElastic = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0) {
|
||||
return 0f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutSine = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return -0.5f * ((float) Math.cos(Math.PI * position) - 1.f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return -0.5f * ((float) Math.cos(Math.PI * input) - 1.f);
|
||||
input *= 2f;
|
||||
if (input == 2) {
|
||||
return 1f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInExpo = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// return (elapsed == 0) ? 0.f : (float) Math.pow(2.f, 10.f * (elapsed
|
||||
// / (float) duration - 1.f));
|
||||
// }
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return (input == 0) ? 0.f : (float) Math.pow(2.f, 10.f * (input - 1.f));
|
||||
float p = 1f / 0.45f;
|
||||
float s = 0.45f / DOUBLE_PI * (float) Math.asin(1f);
|
||||
if (input < 1f) {
|
||||
return -0.5f
|
||||
* ((float) Math.pow(2f, 10f * (input -= 1f))
|
||||
* (float) Math.sin((input * 1f - s) * DOUBLE_PI * p));
|
||||
}
|
||||
};
|
||||
return 1f + 0.5f
|
||||
* (float) Math.pow(2f, -10f * (input -= 1f))
|
||||
* (float) Math.sin((input * 1f - s) * DOUBLE_PI * p);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutExpo = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// return (elapsed == duration) ? 1.f : (-(float) Math.pow(2.f, -10.f *
|
||||
// elapsed
|
||||
// / (float) duration) + 1.f);
|
||||
// }
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInBack = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
final float s = 1.70158f;
|
||||
return input * input * ((s + 1f) * input - s);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return (input == 1f) ? 1.f : (-(float) Math.pow(2.f, -10.f * (input + 1.f)));
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutBack = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
final float s = 1.70158f;
|
||||
input--;
|
||||
return (input * input * ((s + 1f) * input + s) + 1f);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutBack = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
float s = 1.70158f;
|
||||
input *= 2f;
|
||||
if (input < 1f) {
|
||||
return 0.5f * (input * input * (((s *= (1.525f)) + 1f) * input - s));
|
||||
}
|
||||
};
|
||||
return 0.5f * ((input -= 2f) * input * (((s *= (1.525f)) + 1f) * input + s) + 2f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutExpo = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// if (elapsed == 0)
|
||||
// {
|
||||
// return 0.f;
|
||||
// }
|
||||
// if (elapsed == duration)
|
||||
// {
|
||||
// return 1.f;
|
||||
// }
|
||||
//
|
||||
// float position = elapsed / (duration / 2.f);
|
||||
// if (position < 1.f)
|
||||
// {
|
||||
// return 0.5f * (float) Math.pow(2.f, 10.f * (position - 1.f));
|
||||
// }
|
||||
// return 0.5f * (-(float) Math.pow(2.f, -10.f * --position) +
|
||||
// 2.f);
|
||||
// }
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInBounce = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
return 1f - EaseOutBounce.getInterpolation(1f - input);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0)
|
||||
{
|
||||
return 0.f;
|
||||
}
|
||||
if (input == 1f)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
float position = input / 0.5f;
|
||||
if (position < 1.f)
|
||||
{
|
||||
return 0.5f * (float) Math.pow(2.f, 10.f * (position - 1.f));
|
||||
}
|
||||
return 0.5f * (-(float) Math.pow(2.f, -10.f * --position) + 2.f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInCirc = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// return -((float) Math.sqrt(1.f - position * position) - 1.f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return -((float) Math.sqrt(1.f - input * input) - 1.f);
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseOutBounce = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
float s = 7.5625f;
|
||||
if (input < (1f / 2.75f)) {
|
||||
return s * input * input;
|
||||
} else if (input < (2f / 2.75f)) {
|
||||
return s * (input -= (1.5f / 2.75f)) * input + 0.75f;
|
||||
} else if (input < (2.5f / 2.75f)) {
|
||||
return s * (input -= (2.25f / 2.75f)) * input + 0.9375f;
|
||||
}
|
||||
};
|
||||
return s * (input -= (2.625f / 2.75f)) * input + 0.984375f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutCirc = new EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// position--;
|
||||
// return (float) Math.sqrt(1.f - position * position);
|
||||
// }
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
input--;
|
||||
return (float) Math.sqrt(1.f - input * input);
|
||||
@SuppressWarnings("unused")
|
||||
public static final EasingFunction EaseInOutBounce = new EasingFunction() {
|
||||
public float getInterpolation(float input) {
|
||||
if (input < 0.5f) {
|
||||
return EaseInBounce.getInterpolation(input * 2f) * 0.5f;
|
||||
}
|
||||
};
|
||||
return EaseOutBounce.getInterpolation(input * 2f - 1f) * 0.5f + 0.5f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutCirc = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (duration / 2.f);
|
||||
// if (position < 1.f)
|
||||
// {
|
||||
// return -0.5f * ((float) Math.sqrt(1.f - position * position)
|
||||
// - 1.f);
|
||||
// }
|
||||
// return 0.5f * ((float) Math.sqrt(1.f - (position -= 2.f) *
|
||||
// position)
|
||||
// + 1.f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
float position = input / 0.5f;
|
||||
if (position < 1.f)
|
||||
{
|
||||
return -0.5f * ((float) Math.sqrt(1.f - position * position) - 1.f);
|
||||
}
|
||||
return 0.5f * ((float) Math.sqrt(1.f - (position -= 2.f) * position)
|
||||
+ 1.f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInElastic = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// if (elapsed == 0)
|
||||
// {
|
||||
// return 0.f;
|
||||
// }
|
||||
//
|
||||
// float position = elapsed / (float) duration;
|
||||
// if (position == 1)
|
||||
// {
|
||||
// return 1.f;
|
||||
// }
|
||||
//
|
||||
// float p = duration * .3f;
|
||||
// float s = p / (2.f * (float) Math.PI) * (float)
|
||||
// Math.asin(1.f);
|
||||
// return -((float) Math.pow(2.f, 10.f * (position -= 1.f)) *
|
||||
// (float)
|
||||
// Math
|
||||
// .sin((position * duration - s) * (2.f * Math.PI) / p));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0)
|
||||
{
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
float position = input;
|
||||
if (position == 1)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
float p = .3f;
|
||||
float s = p / (2.f * (float) Math.PI) * (float) Math.asin(1.f);
|
||||
return -((float) Math.pow(2.f, 10.f * (position -= 1.f)) * (float)
|
||||
Math
|
||||
.sin((position - s) * (2.f * Math.PI) / p));
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutElastic = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// if (elapsed == 0)
|
||||
// {
|
||||
// return 0.f;
|
||||
// }
|
||||
//
|
||||
// float position = elapsed / (float) duration;
|
||||
// if (position == 1)
|
||||
// {
|
||||
// return 1.f;
|
||||
// }
|
||||
//
|
||||
// float p = duration * .3f;
|
||||
// float s = p / (2 * (float) Math.PI) * (float) Math.asin(1.f);
|
||||
// return (float) Math.pow(2, -10 * position)
|
||||
// * (float) Math.sin((position * duration - s) * (2.f *
|
||||
// Math.PI) / p) +
|
||||
// 1.f;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0)
|
||||
{
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
float position = input;
|
||||
if (position == 1)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
float p = .3f;
|
||||
float s = p / (2 * (float) Math.PI) * (float) Math.asin(1.f);
|
||||
return (float) Math.pow(2, -10 * position)
|
||||
* (float) Math.sin((position - s) * (2.f * Math.PI) / p) +
|
||||
1.f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutElastic = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// if (elapsed == 0)
|
||||
// {
|
||||
// return 0.f;
|
||||
// }
|
||||
//
|
||||
// float position = elapsed / (duration / 2.f);
|
||||
// if (position == 2)
|
||||
// {
|
||||
// return 1.f;
|
||||
// }
|
||||
//
|
||||
// float p = duration * (.3f * 1.5f);
|
||||
// float s = p / (2.f * (float) Math.PI) * (float)
|
||||
// Math.asin(1.f);
|
||||
// if (position < 1.f)
|
||||
// {
|
||||
// return -.5f
|
||||
// * ((float) Math.pow(2.f, 10.f * (position -= 1.f)) * (float)
|
||||
// Math
|
||||
// .sin((position * duration - s) * (2.f * Math.PI) / p));
|
||||
// }
|
||||
// return (float) Math.pow(2.f, -10.f * (position -= 1.f))
|
||||
// * (float) Math.sin((position * duration - s) * (2.f *
|
||||
// Math.PI) / p) *
|
||||
// .5f
|
||||
// + 1.f;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input == 0)
|
||||
{
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
float position = input / 0.5f;
|
||||
if (position == 2)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
float p = (.3f * 1.5f);
|
||||
float s = p / (2.f * (float) Math.PI) * (float) Math.asin(1.f);
|
||||
if (position < 1.f)
|
||||
{
|
||||
return -.5f
|
||||
* ((float) Math.pow(2.f, 10.f * (position -= 1.f)) * (float) Math
|
||||
.sin((position * 1f - s) * (2.f * Math.PI) / p));
|
||||
}
|
||||
return (float) Math.pow(2.f, -10.f * (position -= 1.f))
|
||||
* (float) Math.sin((position * 1f - s) * (2.f * Math.PI) / p) *
|
||||
.5f
|
||||
+ 1.f;
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInBack = new EasingFunction()
|
||||
{
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// final float s = 1.70158f;
|
||||
// float position = elapsed / (float) duration;
|
||||
// return position * position * ((s + 1.f) * position - s);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
final float s = 1.70158f;
|
||||
float position = input;
|
||||
return position * position * ((s + 1.f) * position - s);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutBack = new EasingFunction()
|
||||
{
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// final float s = 1.70158f;
|
||||
// float position = elapsed / (float) duration;
|
||||
// position--;
|
||||
// return (position * position * ((s + 1.f) * position + s) + 1.f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
final float s = 1.70158f;
|
||||
float position = input;
|
||||
position--;
|
||||
return (position * position * ((s + 1.f) * position + s) + 1.f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutBack = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float s = 1.70158f;
|
||||
// float position = elapsed / (duration / 2.f);
|
||||
// if (position < 1.f)
|
||||
// {
|
||||
// return 0.5f * (position * position * (((s *= (1.525f)) + 1.f)
|
||||
// *
|
||||
// position - s));
|
||||
// }
|
||||
// return 0.5f * ((position -= 2.f) * position
|
||||
// * (((s *= (1.525f)) + 1.f) * position + s) + 2.f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
float s = 1.70158f;
|
||||
float position = input / 0.5f;
|
||||
if (position < 1.f)
|
||||
{
|
||||
return 0.5f * (position * position * (((s *= (1.525f)) + 1.f) *
|
||||
position - s));
|
||||
}
|
||||
return 0.5f * ((position -= 2.f) * position
|
||||
* (((s *= (1.525f)) + 1.f) * position + s) + 2.f);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInBounce = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// return 1.f - EaseOutBounce.ease(duration - elapsed,
|
||||
// duration);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return 1.f - EaseOutBounce.getInterpolation(1f - input);
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseOutBounce = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// float position = elapsed / (float) duration;
|
||||
// if (position < (1.f / 2.75f))
|
||||
// {
|
||||
// return (7.5625f * position * position);
|
||||
// }
|
||||
// else if (position < (2.f / 2.75f))
|
||||
// {
|
||||
// return (7.5625f * (position -= (1.5f / 2.75f)) * position +
|
||||
// .75f);
|
||||
// }
|
||||
// else if (position < (2.5f / 2.75f))
|
||||
// {
|
||||
// return (7.5625f * (position -= (2.25f / 2.75f)) * position +
|
||||
// .9375f);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return (7.5625f * (position -= (2.625f / 2.75f)) * position +
|
||||
// .984375f);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
float position = input;
|
||||
if (position < (1.f / 2.75f))
|
||||
{
|
||||
return (7.5625f * position * position);
|
||||
}
|
||||
else if (position < (2.f / 2.75f))
|
||||
{
|
||||
return (7.5625f * (position -= (1.5f / 2.75f)) * position + .75f);
|
||||
}
|
||||
else if (position < (2.5f / 2.75f))
|
||||
{
|
||||
return (7.5625f * (position -= (2.25f / 2.75f)) * position + .9375f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (7.5625f * (position -= (2.625f / 2.75f)) * position +
|
||||
.984375f);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final EasingFunction EaseInOutBounce = new
|
||||
EasingFunction() {
|
||||
// @Override
|
||||
// public float ease(long elapsed, long duration) {
|
||||
// if (elapsed < duration / 2.f)
|
||||
// {
|
||||
// return EaseInBounce.ease(elapsed * 2, duration) * .5f;
|
||||
// }
|
||||
// return EaseOutBounce.ease(elapsed * 2 - duration, duration) *
|
||||
// .5f +
|
||||
// .5f;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input < 0.5f)
|
||||
{
|
||||
return EaseInBounce.getInterpolation(input * 2) * .5f;
|
||||
}
|
||||
return EaseOutBounce.getInterpolation(input * 2 - 1f) * .5f +
|
||||
.5f;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package com.github.mikephil.charting.animation;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
/**
|
||||
* Interface for creating custom made easing functions. Uses the
|
||||
* TimeInterpolator interface provided by Android.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public interface EasingFunction extends TimeInterpolator {
|
||||
|
||||
@Override
|
||||
float getInterpolation(float input);
|
||||
}
|
|
@ -3,7 +3,6 @@ package com.github.mikephil.charting.charts;
|
|||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -15,8 +14,10 @@ import android.graphics.Paint.Align;
|
|||
import android.graphics.RectF;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore.Images;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
@ -26,7 +27,7 @@ import android.view.ViewParent;
|
|||
|
||||
import com.github.mikephil.charting.animation.ChartAnimator;
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.animation.EasingFunction;
|
||||
import com.github.mikephil.charting.animation.Easing.EasingFunction;
|
||||
import com.github.mikephil.charting.components.Description;
|
||||
import com.github.mikephil.charting.components.IMarker;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
|
@ -60,7 +61,6 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Philipp Jahoda
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Entry>>> extends
|
||||
ViewGroup
|
||||
implements ChartInterface {
|
||||
|
@ -209,9 +209,9 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
setWillNotDraw(false);
|
||||
// setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
mAnimator = new ChartAnimator();
|
||||
else
|
||||
} else {
|
||||
mAnimator = new ChartAnimator(new AnimatorUpdateListener() {
|
||||
|
||||
@Override
|
||||
|
@ -220,6 +220,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
postInvalidate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// initialize the utils
|
||||
Utils.init(getContext());
|
||||
|
@ -836,11 +837,27 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
* @param easingX a custom easing function to be used on the animation phase
|
||||
* @param easingY a custom easing function to be used on the animation phase
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easingX,
|
||||
EasingFunction easingY) {
|
||||
mAnimator.animateXY(durationMillisX, durationMillisY, easingX, easingY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the drawing / rendering of the chart on both x- and y-axis with
|
||||
* the specified animation time. If animate(...) is called, no further
|
||||
* calling of invalidate() is necessary to refresh the chart. ANIMATIONS
|
||||
* ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER.
|
||||
*
|
||||
* @param durationMillisX
|
||||
* @param durationMillisY
|
||||
* @param easing a custom easing function to be used on the animation phase
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easing) {
|
||||
mAnimator.animateXY(durationMillisX, durationMillisY, easing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the rendering of the chart on the x-axis with the specified
|
||||
* animation time. If animate(...) is called, no further calling of
|
||||
|
@ -850,6 +867,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
* @param durationMillis
|
||||
* @param easing a custom easing function to be used on the animation phase
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateX(int durationMillis, EasingFunction easing) {
|
||||
mAnimator.animateX(durationMillis, easing);
|
||||
}
|
||||
|
@ -863,6 +881,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
* @param durationMillis
|
||||
* @param easing a custom easing function to be used on the animation phase
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateY(int durationMillis, EasingFunction easing) {
|
||||
mAnimator.animateY(durationMillis, easing);
|
||||
}
|
||||
|
@ -883,7 +902,11 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
* @param durationMillisY
|
||||
* @param easingX a predefined easing option
|
||||
* @param easingY a predefined easing option
|
||||
*
|
||||
* @deprecated Use {@link #animateXY(int, int, EasingFunction, EasingFunction)}
|
||||
* @see #animateXY(int, int, EasingFunction, EasingFunction)
|
||||
*/
|
||||
@Deprecated
|
||||
public void animateXY(int durationMillisX, int durationMillisY, Easing.EasingOption easingX,
|
||||
Easing.EasingOption easingY) {
|
||||
mAnimator.animateXY(durationMillisX, durationMillisY, easingX, easingY);
|
||||
|
@ -897,7 +920,11 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
*
|
||||
* @param durationMillis
|
||||
* @param easing a predefined easing option
|
||||
*
|
||||
* @deprecated Use {@link #animateX(int, EasingFunction)}
|
||||
* @see #animateX(int, EasingFunction)
|
||||
*/
|
||||
@Deprecated
|
||||
public void animateX(int durationMillis, Easing.EasingOption easing) {
|
||||
mAnimator.animateX(durationMillis, easing);
|
||||
}
|
||||
|
@ -910,7 +937,11 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
*
|
||||
* @param durationMillis
|
||||
* @param easing a predefined easing option
|
||||
*
|
||||
* @deprecated Use {@link #animateY(int, EasingFunction)}
|
||||
* @see #animateY(int, EasingFunction)
|
||||
*/
|
||||
@Deprecated
|
||||
public void animateY(int durationMillis, Easing.EasingOption easing) {
|
||||
mAnimator.animateY(durationMillis, easing);
|
||||
}
|
||||
|
@ -929,6 +960,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
*
|
||||
* @param durationMillis
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateX(int durationMillis) {
|
||||
mAnimator.animateX(durationMillis);
|
||||
}
|
||||
|
@ -941,6 +973,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
*
|
||||
* @param durationMillis
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateY(int durationMillis) {
|
||||
mAnimator.animateY(durationMillis);
|
||||
}
|
||||
|
@ -954,6 +987,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
* @param durationMillisX
|
||||
* @param durationMillisY
|
||||
*/
|
||||
@RequiresApi(11)
|
||||
public void animateXY(int durationMillisX, int durationMillisY) {
|
||||
mAnimator.animateXY(durationMillisX, durationMillisY);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.animation.Easing.EasingFunction;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.data.ChartData;
|
||||
|
@ -477,7 +478,7 @@ public abstract class PieRadarChartBase<T extends ChartData<? extends IDataSet<?
|
|||
* @param toangle
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {
|
||||
public void spin(int durationmillis, float fromangle, float toangle, EasingFunction easing) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < 11)
|
||||
return;
|
||||
|
@ -487,7 +488,7 @@ public abstract class PieRadarChartBase<T extends ChartData<? extends IDataSet<?
|
|||
ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
|
||||
toangle);
|
||||
spinAnimator.setDuration(durationmillis);
|
||||
spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));
|
||||
spinAnimator.setInterpolator(easing);
|
||||
|
||||
spinAnimator.addUpdateListener(new AnimatorUpdateListener() {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue