How to get bar click event on MPcharts horizontal charts in android?

I am using the MPAndroidChart library .

I used horizontal bar graphs on the toolbar.

I want to move on to another action by clicking on the specific panel of this diagram.

How can i do this?

+5
source share
1 answer

It is very simple, all you have to do is use OnChartValueSelectedListener and start a new Activity from the callback methods.

You can find an example of how this works here .

Basically, implement a listener in your class that contains a diagram:

 public class SomeClass implements OnChartValueSelectedListener { 

Set the listener to the graph:

 chart.setOnChartValueSelectedListener(this); 

Run the new action in the callback:

 @Override public void onValueSelected(Entry e, int dataSetIndex, Highlight h) { // start new activity } 
+6
source

All Articles