Nadimuddin :
I set OnChartValueSelectedListener
for BarChart but when I click on any bar or anywhere in the BarChart only onNothingSelected()
is calling and onValueSelected
is not calling, not even once. I want to get a call back that will tell me which bar has been selected.
I tried setting setOnChartGestureListener() but that also doesn't work. Please help me to fix the issue.
mBarChart.setOnChartValueSelectedListener(this);
mBarChart.setHighlightFullBarEnabled(true);
ArrayList<BarEntry> yValsProp1 = new ArrayList<>();
for (int i = 0; i < mFeeAmount.size(); i++) {
float f1 = mFeeAmount.get(i).floatValue();
float f2 = mFineAmount.get(i).floatValue();
yValsProp1.add(new BarEntry(i, new float[]{f1, f2}));
}
//Setting data to the bar
BarDataSet barDataSet = new BarDataSet(yValsProp1, " ");
barDataSet.setColors(getColors());
barDataSet.setHighlightEnabled(false);
barDataSet.setDrawValues(true);
BarData barData = new BarData(barDataSet);
barData.setBarWidth(0.55f);
mBarChart.setScaleEnabled(false);
mBarChart.getDescription().setEnabled(false);
mBarChart.getLegend().setEnabled(false);
//hiding Axis lines
mBarChart.getAxisLeft().setDrawAxisLine(false);
mBarChart.getAxisRight().setDrawAxisLine(false);
mBarChart.setFitBars(false);
mBarChart.setDrawValueAboveBar(true);
mBarChart.setData(barData);
mBarChart.setClipValuesToContent(false);
mBarChart.setVisibleXRange(6, 6);
mBarChart.getLegend().setForm(Legend.LegendForm.CIRCLE);
mBarChart.invalidate();
Nadimuddin :
I got where I was doing wrong, I just removed this line
barDataSet.setHighlightEnabled(false);
by default it will be true.