Iam working on an android app and using AChartEngine for bar charting. Everything is working as it should except that I can't figure out which bar in the graph is touched (not clicked). It seems that .getCurrentSeriesAndPoint() isn't working within the OnTouchListener. It's everytime returning NULL. When I'm using OnClickListener everything is working fine, but I need to know which bar is touched (Action_Down and Action_Up) not clicked.
Is .getCurrentSeriesAndPoint() not working in a TouchListener in general? Is there a workaround or another way to realize which bar is touched?
mChartView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:{
Toast.makeText(MainActivity.this, "DOWN", Toast.LENGTH_SHORT) .show();
if(seriesSelection != null) touchedBar = seriesSelection.getPointIndex();
break;}
case MotionEvent.ACTION_UP:{
Toast.makeText(MainActivity.this, "UP", Toast.LENGTH_LONG) .show();
touchedBar = 0;
break;}
default: break;
}
mRenderer.removeAllRenderers();
r.setColor(Color.RED);
r.setSelectedBar(ClickedBar);
mRenderer.addSeriesRenderer(r);
mChartView.repaint();
return true;
}
});
kind regards Christian