Fahad Abid Janjua
Fahad Abid Janjua

Reputation: 1024

Chart above grid lines in AChartEngine Bar Chart

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

Upvotes: 7

Views: 1081

Answers (3)

dwbrito
dwbrito

Reputation: 5254

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.

Upvotes: 1

user2431172
user2431172

Reputation: 21

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

Upvotes: 0

Dan D.
Dan D.

Reputation: 32391

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.

Upvotes: 4

Related Questions