首页 文章

aChartEngine,如何从图表中获取值

提问于
浏览
2

我是android的新开发应用程序,所以我希望有人可以帮助我 . 我正在检查朋友的代码,他制作了一个B类来制作图表,在A类中他创建了一个GraphicalView并在类b中调用了GraphicalView方法来返回制作的图表 . 我想获得用户点击的图表的 Value ,我已经检查了aChartEngine的演示,但是在示例中他们在创建图表的代码中创建了setOnClickListener,所以我想知道是否有人知道我怎么能如果图表已在GraphicalView中制作,则获取此值,heare是其示例 .

class B{
    GraphicalView chart;
    public GraphicalView graf (){
        //heare is the code that generates the chart;
        return chart;
    }
}


class A{
    GraphicalView chartMade;
    b makeChart = new b();
    chartMade = makeChart.graf();
}

我想获得A类的 Value 观 .

1 回答

  • 1

    你的例子很模糊,所以我无法帮助你了解具体细节,但基本方法是覆盖GraphicalChartonTouchEvent() 来调用 getCurrentSeriesAndPoint() . 从这些数据中,您可以调用 getValue() 和/或 getXValue() 来获取图表的某些数据 .


    Addition
    在B类内部尝试添加:

    chartView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            SeriesSelection selection = ((GraphicalView) v).getCurrentSeriesAndPoint();
            Log.v("Touch", selection.getValue() + ", " + selection.getXValue());
            return false;
        }
    });
    

相关问题