aChartEngine:在图形领域得到任何点的坐标 [英] aChartEngine: getting coordinates of any point on the graph area

查看:219
本文介绍了aChartEngine:在图形领域得到任何点的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用achartengine显示行graphs.And我被困在试图让一个点触摸的坐标(不上线图的坐标,但任何地方的图形区域)我。所以我觉得 getSeriesAndPointForScreenCoordinate(...)不会在这种情况下帮助。

I am using achartengine to display line graphs.And i am stuck at trying to get the coordinates of a point on touch (not the coordinates on the line graph but anywhere in the graph area). so i think getSeriesAndPointForScreenCoordinate(...) wont help in this case.

有什么建议?

推荐答案

尝试使用这种code:

try using this code :

myXYPlot.setOnTouchListener(新OnTouchListener(){

myXYPlot.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

            switch (event.getAction()) {
            case MotionEvent.ACTION_MOVE:
                displaycoordinates(event);
                break;

            case MotionEvent.ACTION_DOWN:
                displaycoordinates(event); 
                break;                  
            default:
                break;
            }
            return true;
        }           
    });              
}

在这里displaycoordinates()定义如下:

where displaycoordinates() is defined below:

public void displaycoordinates(MotionEvent event) {
    // TODO Auto-generated method stub

    float x = event.getX();
    float y = event.getY();

    PointF point = new PointF(x,y);

    NumberFormat nf = new DecimalFormat("#0.00");

    Double j = getXval(x);
    String xval = nf.format(j);

    Double k = getYval(y);
    String yval = nf.format(x);

    if(j>=condition1 && k>=condition2 && j<=condition3 && k<=condition4)
    {
        toast = Toast.makeText(getApplicationContext(), xval+"xval"+yval+" yval", 0);
        toast.show();
    }

}

这篇关于aChartEngine:在图形领域得到任何点的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆