Is it possible to set color of bar based on values of X axis for a horizontal bar graph?
If you know the color of each bar, you could specify those colors and set the BarDataSet; since colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array.
For example:
BarDataSet barDataSet = new BarDataSet(yValues, "");
barDataSet.setColors(barColors);
where barColors is the list of colors to be used by the bar chart's bars.
@iRuth Hi! What I intend to do is, I want the bar to be coloured red if the value of X is, say between a specific range or coloured green for a different range. Can something like this be achieved with MPAndroid?
@PreetiR08, yes you can achieve that with this library. You need to specify a list of colors that would be used by your list of X values. So if you have 10 X values, for each value of X, you would populate your list of colors with either a green, a red or whatever color you need. This ensures that the index of the X value in the list of X values matches with the index of the color in the list of colors. And then set the colors on your barDataSet as I indicated above (barDataSet.setColors(barColors);).
@iRuth Thanks! That worked! :+1: