2

Does anybody know a way to change or remove the background colors for the X labels in Achartengine for Android?

I went through the documentation and the demo source, but couldn't find a way to do this with the supplied functions. Maybe I just didn't see it, but else I probably need to import the source itself and modify it when drawing the labels.

Before doing that I was wondering if anybody came across this issue and found a solution. Please let me know if you do. :)

Thanks.

StingRay5
  • 2,388
  • 2
  • 20
  • 29

1 Answers1

2

So after a couple of hours working my way through the source code, I found out that the colors of the Label background is the same as the background of margins. So basically it is not possible to only change the background color of the Label.

The color of the margins can be set with:

renderer.setMarginsColor(int);

However, this somehow doesn't support transparency in colors, so it didn't fullfill my needs. In the draw() function of the XYChart class in the org.achartengine.chart package I found (somewhere around line 270 of the class):

drawBackground(mRenderer, canvas, x, bottom, width, height - bottom, paint, true, mRenderer.getMarginsColor());

This function draws the background color under the labels. I commented it out and it worked.

It works like a charm, as long as I don't need any graphs that do need that color.

Hopefully a future release will enable developers to do this without the need of editing the source.

StingRay5
  • 2,388
  • 2
  • 20
  • 29
  • If you want the graph to be transparent ie show the activity background as graph's background you can pass false as second last argument(instead of true). – Aneesh Garg Dec 19 '11 at 09:17
  • In 0.7 I've commented more than one line. It works great . Thank you StingRay5. I hope they fix it in the next release... – Osman.Gerwas Feb 02 '12 at 22:24
  • There is another way that doesn't need to edit the source, take a look at my post here http://stackoverflow.com/questions/8738545/how-to-set-the-background-image-for-achartengine-line-chart-in-android/10038958#10038958 – thanhbinh84 Apr 06 '12 at 03:59