MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Text Color for X-axis lables

Open rutvijkumarshah opened this issue 11 years ago • 14 comments

@PhilJay Thanks for this awesome library.

I could not find a way to change color of x-axis lables. I was able to change text color of y axis values using mChart.setValueTextColor(getResources().getColor(android.R.color.white));

But this changes text color of only y-axis values in Bar Chart.

rutvijkumarshah avatar Jan 24 '15 04:01 rutvijkumarshah

Closing this issue. There is a way to set text color for XLables using following code : XLabels labels = mChart.getXLabels(); labels.setTextColor(getResources().getColor(android.R.color.white));

rutvijkumarshah avatar Jan 24 '15 04:01 rutvijkumarshah

@rutvijkumarshah I'm not finding .getXLabels()

Is this on an older version?

surfer190 avatar Mar 26 '16 13:03 surfer190

@surfer190 , yeah its with old version, I filed the issue one year ago.

rutvijkumarshah avatar Mar 26 '16 15:03 rutvijkumarshah

@rutvijkumarshah It isn't working. then how to set color for x-axis Labels for Pie-Chart ?

Rohittt728 avatar Jan 13 '17 13:01 Rohittt728

Try it.

Chart.getXAxis().setTextColor(Color.Blue);

OR

XAxis xLabels = Chart.getXAxis(); xLabels.setTextColor(Color.Blue);

vishalsgithub avatar Feb 16 '17 05:02 vishalsgithub

getXAxis() - deprecated, and throws RuntimeException("PieChart has no XAxis"). What is the new way to change x-axis text color?

AlexandrSushkov avatar Feb 20 '17 16:02 AlexandrSushkov

if you want to change the text color of lables try it..

mChart.setEntryLabelColor(Color.BLUE);

or if you want to change value color try it..

PieData data = new PieData(dataSet); data.setValueTextColor(Color.RED);

i hope it works..

vishalsgithub avatar Feb 21 '17 05:02 vishalsgithub

Thanks! It helped me, and saved a lot of time.

AlexandrSushkov avatar Feb 21 '17 10:02 AlexandrSushkov

legend will do

goodlifechris avatar Jan 27 '18 10:01 goodlifechris

    pieChart.getLegend().setTextColor(Color.WHITE);

goodlifechris avatar Jan 27 '18 10:01 goodlifechris

I have this issue now on a linechart, the text color of my x-labels changes to a dark purple but will not change to any other color.

MasonDarcy avatar Jul 26 '20 01:07 MasonDarcy

I have this issue now on a linechart, the text color of my x-labels changes to a dark purple but will not change to any other color.

I know its a late reply but surely it will help others as it is common mistake Use below line for that

ContextCompat.getColor(context, R.color.red_color)

The mistake is that you are providing the id of color ( by giving only R.color.some_color) not the actual color

babbar01 avatar Oct 24 '20 15:10 babbar01

is it possible to give multiple colours to labels in pie chart? like this: frnWb

anshul2502 avatar May 18 '21 15:05 anshul2502

is it possible to give multiple colours to labels in pie chart? like this: frnWb

I would also love to be able to have each label with a different color, to match the color of the bar.

saldous avatar Apr 29 '22 18:04 saldous