does anyone know, how to reset selected item in MPAndroid Charts - PieChart? I need to be able to click on one item for example "ten tousand" times, but every second time it gives me onNothingSelected() event not onValueSelected()
I need call only onValueSelected() event.
Can someone help?
Thank you
Wow, I really wanted the answer and.. finally, I solved this problem.
The answer is very simple.
chart.getOnTouchListener().setLastHighlighted(null);
chart.highlightValues(null);
Before set highlightValues as null, You need to also initialize the last touched highlighted value too!
I don't know if you solved your problem. But, in case someone have the same problem, here is one solution using Bar Charts:
// global variables
protected static Entry entry;
protected static int index;
protected static Highlight highlight;
// function where the listener is defined
protected void manipulateChart(){
final BarChart mChart = (BarChart) findViewById(R.id.your_chart);
// listener
mChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
// set global variables
entry = e;
index = dataSetIndex;
highlight = h;
mChart.highlightValues(null);
// ... your code ...
}
}
@Override
public void onNothingSelected() {
onValueSelected(entry, index, highlight);
}
});
}
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