Skip to content

Commit 205a056

Browse files
authored
Merge pull request #58 from bengarding/add-is-fling-enabled-option
Add isFlingEnabled option to the chart
2 parents 8ec5807 + 03401fc commit 205a056

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
8484
private boolean mScaleXEnabled = true;
8585
private boolean mScaleYEnabled = true;
8686

87+
/**
88+
* if true, fling gesture is enabled for the chart
89+
*/
90+
private boolean mFlingEnabled = false;
91+
8792
/**
8893
* paint object for the (by default) lightgrey background of the grid
8994
*/
@@ -1169,6 +1174,22 @@ public boolean isScaleYEnabled() {
11691174
return mScaleYEnabled;
11701175
}
11711176

1177+
/**
1178+
* Set this to true to enable fling gesture for the chart
1179+
*
1180+
* @param enabled
1181+
*/
1182+
public void setFlingEnabled(boolean enabled) { this.mFlingEnabled = enabled; }
1183+
1184+
/**
1185+
* Returns true if fling gesture is enabled for the chart, false if not.
1186+
*
1187+
* @return
1188+
*/
1189+
public boolean isFlingEnabled() {
1190+
return mFlingEnabled;
1191+
}
1192+
11721193
/**
11731194
* Set this to true to enable zooming in by double-tap on the chart.
11741195
* Default: enabled

MPChartLib/src/main/java/com/github/mikephil/charting/listener/BarLineChartTouchListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public boolean onTouch(View v, MotionEvent event) {
108108
}
109109
}
110110

111-
if (mTouchMode == NONE) {
111+
if (mChart.isFlingEnabled()) {
112112
mGestureDetector.onTouchEvent(event);
113113
}
114114

0 commit comments

Comments
 (0)