2

I'm trying to get the axis of an XYPlot using a custom OnTouchListener:

mPlot.setOnTouchListener(new View.OnTouchListener(){
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                float touchX = event.getX();
                float touchY = event.getY();
                Log.d(TAG, touchX+":"+touchY);
                return false;
            }
        });

The problem is that I'm getting the pixel values.

Is there any method or workaround to get the exact axis of the plot?

kike
  • 4,255
  • 5
  • 23
  • 41

2 Answers2

2

I checked some androidplot doc and apaprently XYPlot object has these methods, maybe they're what you need

public Number screenToSeriesX(float x)

public Number screenToSeriesY(float y)
lelloman
  • 13,883
  • 5
  • 63
  • 85
  • Thanks a lot for your answer. It works but these methods are deprecated for newer versions where we should use screenToSeriesX() and screenToSeriesY(). – kike Jun 08 '17 at 13:33
0

Try this:

int touchX = (int) event.getX();
int touchY = (int) event.getY();

For more info on how Android Screen Coordinates work : link

dustblue
  • 557
  • 5
  • 14