我使用 AchartEngine 制作一个 pie chart,如下:
Pie Chart 图像
我给所有的颜色部分都添加了onclick事件,但是有时候绿色部分不能点击。
mChartView = ChartFactory.getPieChartView(this, adc.buildCategoryDataset("Project budget", values), renderer);
mChartView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
if (seriesSelection == null) {
Toast
.makeText(GeneratedChartDemo.this, "No chart element was clicked", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
GeneratedChartDemo.this,
"Chart element data point index " + seriesSelection.getPointIndex()
+ " was clicked" + " point value=" + seriesSelection.getValue(),
Toast.LENGTH_SHORT).show();
}
}
});
哪里出错或者是丢失什么呢?