2828public class BarLineChartTouchListener <T extends BarLineChartBase <? extends BarLineScatterCandleData <? extends BarLineScatterCandleDataSet <? extends Entry >>>>
2929 extends SimpleOnGestureListener implements OnTouchListener {
3030
31- // private static final long REFRESH_MILLIS = 20;
31+ // private static final long REFRESH_MILLIS = 20;
3232
3333 /** the original touch-matrix from the chart */
3434 private Matrix mMatrix = new Matrix ();
@@ -84,7 +84,7 @@ public boolean onTouch(View v, MotionEvent event) {
8484 mGestureDetector .onTouchEvent (event );
8585 }
8686
87- if (!mChart .isDragEnabled () && !mChart .isScaleEnabled ( ))
87+ if (!mChart .isDragEnabled () && ( !mChart .isScaleXEnabled () && ! mChart . isScaleYEnabled () ))
8888 return true ;
8989
9090 // Handle touch events here...
@@ -140,7 +140,7 @@ public boolean onTouch(View v, MotionEvent event) {
140140
141141 mChart .disableScroll ();
142142
143- if (mChart .isScaleEnabled ())
143+ if (mChart .isScaleXEnabled () || mChart . isScaleYEnabled ())
144144 performZoom (event );
145145
146146 } else if (mTouchMode == NONE
@@ -168,18 +168,19 @@ public boolean onTouch(View v, MotionEvent event) {
168168 }
169169
170170 // Perform the transformation, update the chart
171- // if (needsRefresh())
172- mMatrix = mChart .getViewPortHandler ().refresh (mMatrix , mChart , true );
171+ // if (needsRefresh())
172+ mMatrix = mChart .getViewPortHandler ().refresh (mMatrix , mChart , true );
173173
174174 return true ; // indicate event was handled
175175 }
176176
177- // private boolean needsRefresh() {
178- // if (System.currentTimeMillis() - mChart.getLastDrawMillis() > REFRESH_MILLIS) {
179- // return true;
180- // } else
181- // return false;
182- // }
177+ // private boolean needsRefresh() {
178+ // if (System.currentTimeMillis() - mChart.getLastDrawMillis() >
179+ // REFRESH_MILLIS) {
180+ // return true;
181+ // } else
182+ // return false;
183+ // }
183184
184185 /**
185186 * ################ ################ ################ ################
@@ -248,9 +249,10 @@ private void performZoom(MotionEvent event) {
248249 // scale
249250
250251 mMatrix .set (mSavedMatrix );
251- mMatrix .postScale (scale , scale , t .x , t .y );
252+ mMatrix .postScale ((mChart .isScaleXEnabled ()) ? scale : 1f ,
253+ (mChart .isScaleYEnabled ()) ? scale : 1f , t .x , t .y );
252254
253- } else if (mTouchMode == X_ZOOM ) {
255+ } else if (mTouchMode == X_ZOOM && mChart . isScaleXEnabled () ) {
254256
255257 float xDist = getXDist (event );
256258 float scaleX = xDist / mSavedXDist ; // x-axis
@@ -259,7 +261,7 @@ private void performZoom(MotionEvent event) {
259261 mMatrix .set (mSavedMatrix );
260262 mMatrix .postScale (scaleX , 1f , t .x , t .y );
261263
262- } else if (mTouchMode == Y_ZOOM ) {
264+ } else if (mTouchMode == Y_ZOOM && mChart . isScaleYEnabled () ) {
263265
264266 float yDist = getYDist (event );
265267 float scaleY = yDist / mSavedYDist ; // y-axis
0 commit comments