Search code examples
androidandroidplot

How to get XYPlot axis with OnTouchListener


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?


Solution

  • 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)