问题
i am working on a pie chart and i am using AchartEngine.
i have the pie chart like this:
Image of a Pie Chart
i have added the onclick to the slices but sometimes only the green slice onlick will not work.
this is my code:
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();
}
}
});
where am i going wrong have i missed something?
EDIT
Thanks to Dan who helped me in solving the problem.
回答1:
Did you add a selectable buffer?
mRenderer.setClickEnabled(true);
mRenderer.setSelectableBuffer(10);
Update: there was a bug that I fixed. You can download a version including this fix here.
来源:https://stackoverflow.com/questions/14499523/achart-engine-onclick-pie-chart-slice-not-working-sometimes-a-bug