Russell Ghana
Russell Ghana

Reputation: 3113

MPAndroidChart remove legend

I am using MPAndroidChart library and I want to remove the values in in the top right corner of the PieChart, how can I do this ?

Upvotes: 12

Views: 7401

Answers (4)

AJAY KACHHIYAPATEL
AJAY KACHHIYAPATEL

Reputation: 169

Add this code into xml file:

<com.github.mikephil.charting.charts.PieChart
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/pie_chart">
</com.github.mikephil.charting.charts.PieChart>

Write this into .java file:

pieChart = findViewById(R.id.pie_chart);
     
Legend l = pieChart.getLegend();
l.setEnabled(false);

Upvotes: 0

Philipp Jahoda
Philipp Jahoda

Reputation: 51411

The values you are talking about belong to the Legend.

To disable them (prevent them from being displayed), call

Legend l = chart.getLegend();
l.setEnabled(false);

Upvotes: 29

dursss
dursss

Reputation: 11

you can set like this

linechart.setData();
...
linechert.getLegend().setEnable(false);

gone Legend should be at the back of setData()

Upvotes: 1

Muhannad Fakhouri
Muhannad Fakhouri

Reputation: 1544

try pieChart.setDrawSliceText(false)

Upvotes: 0

Related Questions