1
在我的Android應用程序中,我嘗試使用AChartEngine將觸摸添加到折線圖。我用這個簡單的例子:AChartEngine:如何識別折線圖?
我添加了一個點擊監聽器圖形
this.graphView = ChartFactory.getLineChartView(this, this.graphDataset,
this.graphRenderer);
....
this.graphView.setOnClickListener(buttonClickListenerGraph);
和buttonClickListenerGraph方法中,我這樣做:
SeriesSelection seriesSelection = this.graphView.getCurrentSeriesAndPoint();
if (seriesSelection == null) {
Toast.makeText(this, "No chart element", Toast.LENGTH_SHORT).show();
} else {
// display information of the clicked point
Toast.makeText(
this,
"Chart element in series index " + seriesSelection.getSeriesIndex()
+ " data point index " + seriesSelection.getPointIndex() + " was clicked"
+ " closest point value X=" + seriesSelection.getXValue() + ", Y="
+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show();
}
我也啓用單擊
this.graphRenderer.setClickEnabled(true);
其中graphRenderer是XYMultipleSeriesRenderer。
但這總是返回「沒有圖表元素」烤麪包。爲什麼它不認可系列和行?有人可以幫忙嗎?
http://stackoverflow.com/questions/15764800/android-achartengine-getcurrentseriesandpoint-not-working-for-disconnected-g – keshav 2014-08-30 06:31:11
@keshav的感謝!但我已經在使用更高版本的AChartengine,即1.2.0。所以,它應該在你發給我的鏈接中有修復。但它仍然無法正常工作。 – Jean 2014-09-02 09:35:48