Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll finish listener of Line chart in mpandroidchart

How to listen to the scroll finish event in mpandroidchart.

I overrided the OnChartGestureListener and OnChartValueSelectedListener but it does not seems to work. onChartTranslate() method gets callback even after the scroll gets end.

onChartGestureStart() gets called when the user touches the chart and onChartGestureEnd() gets called once the user stops touching the chart.

So, i need to catch the event which gets called when the scroll gets finished.

So, Can you give a headsup on how to listen to the scroll end of linechart in mpandroidchart.

like image 652
Kanagalingam Avatar asked Dec 18 '18 09:12

Kanagalingam


1 Answers

this worked for me checked both the start and end of scroll in chart

chart.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
    if(!(chart.getLowestVisibleX() == chart.getXAxis().getAxisMinimum() || chart.getHighestVisibleX() == chart.getXAxis().getAxisMaximum())){
        // Do your work here
        Toast.makeText(getContext(),"Hello Scroll to end check working",Toast.LENGTH_LONG).show();
        return false;
    }
});
like image 198
Mahesh Chandra Avatar answered Sep 22 '22 11:09

Mahesh Chandra