I need a piechart for my App to display some data in different sections. the piechart is ready and it also works fine but i need a clickable event when touched on a particular s
You could try this:
Override onTouchEvent in MyGraphView and check the action. Normally for ACTION_DOWN you should return true and on ACTION_UP handle the click.
When you handle the click, extract the relative event coordinates from the center of the chart, something like
float relX = event.getX() - (rectf.right - rectf.left) * 0.5f;
float relY = event.getY() - (rectf.bottom - rectf.top) * 0.5f;
Then you need to find the angle:
float angleInRad = (float)Math.atan2(relY, relX);
Now you've got the angle but in radians and in the range -PI..PI. So:
int degree = (int)((angleInRad + Math.PI) * 180 / Math.PI);
Now just find which interval (from value_degree) contains this value.
Also note that since the coordinate system is upside down, you might need to use -relY instead of relY. Just try it and change it if needed.