I want to set a specific color for a bar in BarChart
from MPAndroidChart
. I do everything according to a documentation, but the color isn't changing.
Here's my code:
barChart = (BarChart) findViewById(R.id.bar_chart);
List<BarEntry> entries = new ArrayList<BarEntry>();
entries.add(new BarEntry(1.0f, 10.0f)); //tmp values
BarDataSet dataSet = new BarDataSet(entries, "bars");
dataSet.setColor(R.color.red); //color from resourses
BarData barData = new BarData(dataSet);
barChart.setData(barData);
barChart.invalidate();
The funny thing is that before I tried to change the color of the bar, the bar was blue, after I tried to change its color, it became grey (no matter, what color it must be). I don't understand why doesn't the color change.
I also tried to override getColor
method in the BarDataSet
class, but result is the same -- bar is grey.