Achart Engine Onclick Not Working Sometimes Error?
I am working on a pie chart and I am using AchartEngine.
I have a pie chart:
I added onclick to slices, but sometimes only the green onlick fragment won't 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, am I missing something?
EDIT
Thanks to Dan who helped me solve the problem.
+3
source to share