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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With