1

I use the library MPAndroidChart to draw a pie chart.

I want to show only the slice text(X) and not the value of the slice(Y). The only way that I have found is to Override the Valuesformatter and send always an empty string.

data.setValueFormatter(new ValueFormatter()
        {
            @Override
            public String getFormattedValue(float value)
            {
                //return formatter_currency.format(value) + " " + currency;         
                return ""; // Display only categories name.
            }
        });

But in this way all the names doesn't fit the slice correctly(there is the empty string under it).

There is a way to achieve this?

Philipp Jahoda
  • 50,880
  • 24
  • 180
  • 187
Blodhgard
  • 9,130
  • 3
  • 24
  • 36

1 Answers1

8

Yes, there is a way.

Call:

pieChart.setDrawSliceText(false)

to disable drawing the x-labels for the chart-slices.

If you want to disable the y-values, call:

dataSet.setDrawValues(false)

EDIT: setDrawSliceText() is now deprecated use setDrawEntryLabels() instead.

JFreeman
  • 974
  • 1
  • 10
  • 26
Philipp Jahoda
  • 50,880
  • 24
  • 180
  • 187
  • Hi Philipp! I want to draw only the X-labels. For example if a slice have X = "Name" and Y = 10 in the slice I would see only "Name" – Blodhgard Mar 29 '15 at 22:01
  • I just tested it and there might be a bug in the API. I fixed it in the latest commit. – Philipp Jahoda Mar 29 '15 at 22:09
  • dataSet.setDrawValues(false); delete X and also Y values. However thanks for the good work, I just switched from acharengine to your library :D I wait for your update – Blodhgard Mar 29 '15 at 22:21
  • @PhilippJahoda It seems the Jar library hasn't been update yet. I just download the newest jar, the problem still exists. – Hong Apr 07 '15 at 05:38
  • @PhilipJahoda Hey Philip is there anyway to draw the labels outside of the pie chart instead of in the actual pie slices ?? – Doug Ray Mar 08 '16 at 20:18
  • @PhilippJahoda..Can you please answer this question ? [ http://stackoverflow.com/questions/41283022/how-to-get-selected-pie-slice-text-and-value-on-onvalueselected-in-mpandroid-cha ] – anonymous Dec 23 '16 at 04:38