16

got the following code:

    graph = (LineChart) convertView.findViewById(R.id.graph);
    graph.getPaint(Chart.PAINT_LEGEND_LABEL).setColor(Color.BLUE);
    graph.getPaint(Chart.PAINT_YLABEL).setColor(Color.BLUE);
    graph.getPaint(Chart.PAINT_XLABEL).setColor(Color.BLUE);

But still the color of X/Y-value-lables and also the lable of the legend stay in black color. Do I miss something? Is there an other way to set the color of these?

This line for example works and results in blue value-lables for each data-point:

    graph.getPaint(Chart.PAINT_VALUES).setColor(Color.BLUE);

Thanks in advance!

Philipp Jahoda
  • 50,880
  • 24
  • 180
  • 187
Fabian
  • 748
  • 2
  • 11
  • 20

2 Answers2

49

Try this to set the colors of axis and legend:

chart.getAxisLeft().setTextColor(...); // left y-axis
chart.getXAxis().setTextColor(...);
chart.getLegend().setTextColor(...);
chart.getDescription().setTextColor(...);

If you want to set the color of the drawn values inside the chart, check out the setting colors documentation or the setting data documentation.

live-love
  • 48,840
  • 22
  • 240
  • 204
Philipp Jahoda
  • 50,880
  • 24
  • 180
  • 187
4

Incase for a pie chat to change its label colors you can do this

pieChart.getLegend().setTextColor(Color.WHITE);
Goodlife
  • 3,822
  • 2
  • 24
  • 23