7

In AChartEngine Bar Chart, is it possible that the bars are drawn over grid lines? How to do that? Currently grid lines are drawn over bars which make it a bit awkward.

Sample Image is attached below.enter image description here

Krushna Chulet
  • 1,625
  • 1
  • 10
  • 9
Fahad Abid Janjua
  • 1,024
  • 3
  • 14
  • 35

3 Answers3

4

You cannot change which one is drawn first and which one next.

However, you can change the color of the grid lines. For instance, you can set a color that is a bit transparent, such as it doesn't really look like it is drawn above the bars.

Dan D.
  • 32,246
  • 5
  • 63
  • 79
1

Even tough this is not a perfect answer, it is possible to achieve that behaviour, by making some changes to the method 'draw' of the class XYChart.

I am not sure this will not cause any other issues, but for me it has been working. Basically the idea consists in drawing the labels and grid before drawing the chart line.

I moved all the code starting and ending in:

        boolean showLabels = mRenderer.isShowLabels() && hasValues;
        ...
           drawText(canvas, mRenderer.getChartTitle(), x + size, top + height / 2, paint, 0);
         }
        }

to before this line:

boolean hasValues = false;

Also, I commented the && hasValues part. Note that this is definitely not reliable code, just a slight hack.

dwbrito
  • 5,194
  • 5
  • 32
  • 48
  • Unfortunately, yes, it harms other parts like axis and custom labels. It can be solved but with more reorganization of the code. – Gábor Oct 11 '14 at 09:50
0

Up to AChartEngine 1.2.0 it is not possible. You cannot bring the grid lines over a chart.

iNoob
  • 3,364
  • 2
  • 26
  • 33
  • This is a simple statement of apparent fact directly responding to the yes/no question asked, hence very much an answer. If someone wants to dispute it's **accuracy** then do so in a comment - but don't falsely flag it as a non-answer. – Chris Stratton Apr 08 '14 at 21:18