本文介绍了AChartEngine,点击获取情节值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用achartengine编码一个简单的时间表。我想要做的是通过点击图表上的点来获取已经绘制的值,这可能吗?

I used achartengine for coding a simple time chart. What I want to do is get the values that are already plotted by clicking on the point on the graph, is this possible?

推荐答案

假设mChartView是您的GraphicalView:

Assuming that mChartView is your GraphicalView:

mChartView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
                  double[] xy = mChartView.toRealPoint(0);

                  if (seriesSelection == null) {
                    Toast.makeText(GraficoMensile.this, "No chart element was clicked", Toast.LENGTH_SHORT)
                        .show();
                  } else {
                    Toast.makeText(
                            GraficoMensile.this,
                        "Chart element in series index " + seriesSelection.getSeriesIndex()
                            + " data point index " + seriesSelection.getPointIndex() + " was clicked"
                            + " closest point value X=" + seriesSelection.getXValue() + ", Y=" + seriesSelection.getValue()
                            + " clicked point value X=" + (float) xy[0] + ", Y=" + (float) xy[1], Toast.LENGTH_SHORT).show();
                  }
                }
              }); 

来源:

这篇关于AChartEngine,点击获取情节值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:55