Mpandroidchart: How to programmatically select values in PieChart?

Created on 26 Nov 2014  路  11Comments  路  Source: PhilJay/MPAndroidChart

hi ,
i have a listview. i want click on item of listview then selected section of piechart.
how can i do?

Regards fatemeh

Most helpful comment

You can use the method public void highlightValues(Highlight[] highs) to highlight values.

Example

Highlight h = new Highlight(x-index, dataSetIndex); // dataset index for piechart is always 0
chart.highlightValues(new Highlight[] { h });

All 11 comments

i down it.....:-)

You can use the method public void highlightValues(Highlight[] highs) to highlight values.

Example

Highlight h = new Highlight(x-index, dataSetIndex); // dataset index for piechart is always 0
chart.highlightValues(new Highlight[] { h });

@PhilJay
Thanks alot

I try this, but it not trigger OnChartValueSelectedListener() , what should I do ? @PhilJay

If you want to trigger the listener, call highlightTouch(...)

@PhilJay
Hi!
I click a value on the graph and it gets selected. When I then call highlightValues(...) or highlightTouch(...) it gets deselected, but the next click on the graphic is ignored. It looks like it's waiting for that click to deselect the value...

Is there a way around this behavior?

Thanks!

@Manhazito Hi !

Did you find the solution ?
I have the same problem ... I still need to click twice on the slice to re-select it ...

thx

@jeanbaptisteODE
I did not! :-/

@jeanbaptisteODE
@Manhazito
mChart.highlightValue(null); worked for me

Hello Everyone,

How to set text format in Reverse like in circle wise,Please check attached image i want to set text like this in app using MPchart Lib in android.
capture

I leave a comment for you guys.
I could call onValueSelected() in my RecyclerView Adapter.

pieChart.highlightValue(highlight, true);

 @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        holder.rl_root.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Highlight highlight = new Highlight((float)position, 0.0f, 0);
                //pieChart.highlightValue(highlight); //doesn't call onValueSelected()
                pieChart.highlightValue(highlight, true); //call onValueSelected()
            }
        });

    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

AiTheAnswer picture AiTheAnswer  路  3Comments

galex picture galex  路  3Comments

andreyfel picture andreyfel  路  3Comments

manucheri picture manucheri  路  3Comments

Giammaofwar picture Giammaofwar  路  3Comments