Specify color for each month?
Is there any way to assign a certain color to a certain month? For ex:
if (mMonth == "Feb") { mMonthBar.setColor(Color.BLUE); }
I see that there is a way to theme or assign a template to a dataset, but I'm looking to customize in a way that each month or category has a consistent color.
This is something I would be happy to have as well.
Good point.
I am currently working on some kind of color-formatter interface that will allow the user to return a customized color based on theEntry at that position.
Yes you can do it. Just create an array of color template and set it accordingly to your needs along with the data.
Will it solve #383 ?
@PhilJay First I thank you for great library. To set individual bar color I tried the below way. BarData barData = new BarData(getXAxisValues(postData), getBarDataSet(postData)); ....
private List
//get the "value" field's value
ArrayList<BarDataSet> barDataSets = null;
barDataSets = new ArrayList<>();
for (int i = 0; i < postData.getData().size(); i++) {
ArrayList<BarEntry> barEntries = new ArrayList<>();
BarEntry entry = new BarEntry((float) postData.getData().get(i).getValue(), i);
barEntries.add(entry);
BarDataSet barDataSet = new BarDataSet(barEntries, "");
String possiblity = postData.getData().get(i).getPossiblity();
if(possiblity.equals("High")){
barDataSet.setColor(Color.parseColor("#00ff00"));
}else if(possiblity.equals("Low")){
barDataSet.setColor(Color.parseColor("#ff0000"));
}else{
barDataSet.setColor(Color.parseColor("#0000ff"));
}
barDataSet.setBarSpacePercent(10f);
barDataSets.add(barDataSet);
}
return barDataSets;
}
I can set color to individual bar. But couldn't set the x-axis label and couldn't get the bar's value. If we can set color based on entry value, my app would be unique chart with MPAndroidChart. I am waiting.