I want to draw a bar chart which contains five individual bars - I have used Achartengine. I am able to display all five bars in the same color but I want to differentiate o
I made a hack to achieve this effect.
Org.achartengine.SimpleSeriesRenderer
changed the class, I added an int[] colors
and a boolean multipleColorsEnabled
with its getters and setters.
So, I changed, org.achartengine.BarChart
in class, the method drawSeries, where is set the color of each bar in a loop, as follows:
int j = startIndex;
for (int i = 0; i < length; i += 2) {
if (seriesRenderer.isMultipleColorsEnabled()) {
paint.setColor(seriesRenderer.getColors()[j++]);
} else {
paint.setColor(seriesRenderer.getColor());
}
float x = points[i];
float y = points[i + 1];
drawBar(canvas, x, yAxisValue, x, y, halfDiffX, seriesNr,
seriesIndex, paint);
}
In the class that loads the data used:
seriesRenderer.setMultipleColorsEnabled(true);
seriesRenderer.setColors(myColors);