Mpandroidchart: Fling Gesture Not Recognized if Max Visible X range is set.

Created on 4 Mar 2015  路  4Comments  路  Source: PhilJay/MPAndroidChart

Hello.

I'm trying to implement an update based on a Fling gesture, where new values are added to the graph as the user swipes left and right. However, onFling is not called back when a max visible X-range is set. This is my current setup:

mLineChart.setBackgroundColor(getResources().getColor(android.R.color.white));
mLineChart.setDragEnabled(true);
mLineChart.setTouchEnabled(true);
mLineChart.setOnChartGestureListener(mOnChartGestureListener);
mLineChart.setOnChartValueSelectedListener(mOnChartValueSelectedListener);

.........
.........
mLineChart.setData(lineData);
mLineChart.setVisibleXRange(7);

Is there another callback that we should use when performing a fling gesture with a Maximum visible X val set? Thanks.

bug

Most helpful comment

The reason therefore is, that I do not want to permanently recognize a fling-gesture or single tap when the chart is zoomed in and panned / dragged.

Therefore, gestures do not work in zoomed mode.

If you want to disable this, you will have to modify the library.

Look out for these lines

if(mTouchMode == NONE) { // remove the if
    mGestureDetector.onTouchEvent(event);
}

in the BarLineChartTouchListener.java file and simply remove the "if" condition.

All 4 comments

The reason therefore is, that I do not want to permanently recognize a fling-gesture or single tap when the chart is zoomed in and panned / dragged.

Therefore, gestures do not work in zoomed mode.

If you want to disable this, you will have to modify the library.

Look out for these lines

if(mTouchMode == NONE) { // remove the if
    mGestureDetector.onTouchEvent(event);
}

in the BarLineChartTouchListener.java file and simply remove the "if" condition.

But why does the BarLineChartTouchListener.java file cannot be unlocked to make the modification suggested by the author?

@royseberg the suggestion was to basically clone the repository into your own project and just change those lines. Maybe this should be allowed in some manner without having to do that, though.

any chance to have an option to on/off the condition if(mTouchMode == NONE). It would be very useful

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndroidJiang picture AndroidJiang  路  3Comments

tsengvn picture tsengvn  路  3Comments

galex picture galex  路  3Comments

andreyfel picture andreyfel  路  3Comments

rohitkumarbhagat picture rohitkumarbhagat  路  3Comments