Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangKuixun committed Oct 26, 2018
1 parent 44d392e commit c9f4fcc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,14 +717,12 @@ protected float[] getMarkerPosition(Highlight high) {

/**
* ################ ################ ################ ################
* ANIMATIONS ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER.
* 动画只适用于API 11级(Android 3.0.x)和更高。
*/
/** CODE BELOW THIS RELATED TO ANIMATION */
/** 下面的代码与动画有关 */

/**
* Returns the animator responsible for animating chart values.
*
* @return
* 返回负责动画的动画图表值。
*/
public ChartAnimator getAnimator() {
return mAnimator;
Expand Down Expand Up @@ -769,17 +767,17 @@ public void setDragDecelerationFrictionCoef(float newValue) {
* ################ ################ ################ ################
* 动画只适用于API 11 (Android 3.0.x) 或者更高.
*/
/** CODE BELOW FOR PROVIDING EASING FUNCTIONS */
/** 提供缓和功能的代码 */

/**
* 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.
* 指定时间内在X轴和Y轴上绘制/渲染图表时的动画。
* <p>
* 如果调用了 animate(...),没有紧跟调用 invalidate() 来刷新图表。
* 动画只适用于API 11级(Android 3。x)和更高。
*
* @param durationMillisX
* @param durationMillisY
* @param easingX a custom easing function to be used on the animation phase
* @param durationMillisX X轴持续时间
* @param durationMillisY Y轴持续时间
* @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)
Expand All @@ -789,10 +787,10 @@ public void animateXY(int durationMillisX, int durationMillisY, EasingFunction e
}

/**
* 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.
* 指定时间内在X轴和Y轴上绘制/渲染图表时的动画。
* <p>
* 如果调用了 animate(...),则不需要调用 invalidate() 来刷新图表。
* 动画只适用于API 11级(Android 3。x)和更高。
*
* @param durationMillisX
* @param durationMillisY
Expand All @@ -804,10 +802,10 @@ public void animateXY(int durationMillisX, int durationMillisY, EasingFunction e
}

/**
* 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. ANIMATIONS ONLY WORK FOR
* API LEVEL 11 (Android 3.0.x) AND HIGHER.
* 指定时间内在X轴上绘制图表时的动画。
* <p>
* 如果调用了 animate(...),则不需要调用 invalidate() 来刷新图表。
* 动画只适用于API 11级(Android 3。x)和更高。
*
* @param durationMillis
* @param easing a custom easing function to be used on the animation phase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
import java.util.ArrayList;
import java.util.List;

/**
* 折线图数据集
*/
public class LineDataSet extends LineRadarDataSet<Entry> implements ILineDataSet {

/**
* Drawing mode for this line dataset
* 折线图的绘制模式
**/
private LineDataSet.Mode mMode = Mode.LINEAR;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public int getFillColor() {
}

/**
* 设置填充颜色
* 设置填充折线绘制区域颜色
* <p>
* 设置用于填充线下区域的颜色。最终设置“fillDrawable”。
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public interface IDataSet<T extends Entry> {
void setDrawIcons(boolean enabled);

/**
* Returns true if y-icon drawing is enabled, false if not
* 如果启用了绘制 y-icon,则返回true,如果不是,则返回false
*
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ public boolean onTouch(View v, MotionEvent event) {

mChart.disableScroll();

float x = mChart.isDragXEnabled() ? event.getX() - mTouchStartPoint.x : 0.f;
float y = mChart.isDragYEnabled() ? event.getY() - mTouchStartPoint.y : 0.f;
// float x = mChart.isDragXEnabled() ? event.getX() - mTouchStartPoint.x : 0.f;
// float y = mChart.isDragYEnabled() ? event.getY() - mTouchStartPoint.y : 0.f;

performDrag(event, x, y);
performDrag(event);

} else if (mTouchMode == X_ZOOM || mTouchMode == Y_ZOOM || mTouchMode == PINCH_ZOOM) {

Expand Down Expand Up @@ -313,29 +313,41 @@ private void saveTouchStart(MotionEvent event) {
*
* @param event
*/
private void performDrag(MotionEvent event, float distanceX, float distanceY) {
private void performDrag(MotionEvent event) {

mLastGesture = ChartGesture.DRAG;

mMatrix.set(mSavedMatrix);

OnChartGestureListener l = mChart.getOnChartGestureListener();

float dX, dY;

// check if axis is inverted
if (inverted()) {

// if there is an inverted horizontalbarchart
if (mChart instanceof HorizontalBarChart) {
distanceX = -distanceX;
dX = -(event.getX() - mTouchStartPoint.x);
dY = event.getY() - mTouchStartPoint.y;
} else {
distanceY = -distanceY;
dX = event.getX() - mTouchStartPoint.x;
dY = -(event.getY() - mTouchStartPoint.y);
}
} else {
dX = event.getX() - mTouchStartPoint.x;
dY = event.getY() - mTouchStartPoint.y;
}

mMatrix.postTranslate(distanceX, distanceY);
MPPointD point = mChart.getTransformer(YAxis.AxisDependency.LEFT).getValuesByTouchPoint(mTouchStartPoint.x, mTouchStartPoint.y);
// 如果向右滑,而且手指不在有效区域内
if (dX < 0 && point.x > mChart.getRealCount()) {
return;
}
mMatrix.postTranslate(dX, dY);

if (l != null)
l.onChartTranslate(event, distanceX, distanceY);
l.onChartTranslate(event, dX, dY);
}

/**
Expand Down Expand Up @@ -680,10 +692,10 @@ public void computeScroll() {
MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x,
mDecelerationCurrentPoint.y, 0);

float dragDistanceX = mChart.isDragXEnabled() ? mDecelerationCurrentPoint.x - mTouchStartPoint.x : 0.f;
float dragDistanceY = mChart.isDragYEnabled() ? mDecelerationCurrentPoint.y - mTouchStartPoint.y : 0.f;
// float dragDistanceX = mChart.isDragXEnabled() ? mDecelerationCurrentPoint.x - mTouchStartPoint.x : 0.f;
// float dragDistanceY = mChart.isDragYEnabled() ? mDecelerationCurrentPoint.y - mTouchStartPoint.y : 0.f;

performDrag(event, dragDistanceX, dragDistanceY);
performDrag(event);

event.recycle();
mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false);
Expand Down

0 comments on commit c9f4fcc

Please sign in to comment.